0% found this document useful (0 votes)
4 views

PIC ReportExp7

The report details an experiment conducted at An-Najah National University focusing on timers and interrupts in microcontrollers, highlighting their importance in task management. It outlines the setup, tools used, experimental results, and code implementation for managing actions triggered by button presses. The conclusions emphasize the effectiveness of these features in enhancing embedded systems design and performance.

Uploaded by

Jana Droubi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

PIC ReportExp7

The report details an experiment conducted at An-Najah National University focusing on timers and interrupts in microcontrollers, highlighting their importance in task management. It outlines the setup, tools used, experimental results, and code implementation for managing actions triggered by button presses. The conclusions emphasize the effectiveness of these features in enhancing embedded systems design and performance.

Uploaded by

Jana Droubi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

An-Najah National University ‫جامعة النجاح الوطنية‬

Faculty of Engineering and IT


‫كلية الهندسة وتكنولوجيا المعلومات‬

Computer Engineering Department


Microcontroller Lab (10636496)
Report Grading Sheet

Instructor Name: Experiment #: 7


Academic Year: 2024/2025 Performed on:
Semester: Second Submitted on:
Student Names:
1- Doaa Jararaa 2-Jana Droubi
3-Fayaha Odeh 4-
5- 6-
Evaluation Criterion CLO Grade Points
Abstract and Aims
Aims and idea of the experiment are clearly stated in 10
simple words
Introduction, Apparatus and Procedures
Introduction is complete and well-written, all
grammar/spelling correct, Appropriate background
information related to the principles of the experiment 15
is provided. The list of apparatus and procedures are
also provided
Experimental Results, Calculations and Discussion
Results analyzed correctly. Experimental findings
adequately and specifically summarized, in graphical,
tabular, and/or written form. Comparison of theoretical 50
predictions to experimental results, including
discussion of accuracy and error analysis as needed.
Conclusions
Conclusions summarize the major findings from the
experimental results with adequate specificity. 15
Highlighting the most important results
Appearance
Title page is complete, page numbers applied, content
is well organized, correct spelling, fonts are consistent, 10
good visual appeal. You have also to use reference for
the information you provide
Total
100
An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT
‫كلية الهندسة وتكنولوجيا المعلومات‬

Abstract and Aims:


This experiment looks at how timers and interrupts work in microcontrollers, which are essential
for keeping track of time and managing tasks. It explains how timers and interrupts are
programmed and set up in a microcontroller and shows how they help with task management.
The experiment provides useful insights for people interested in embedded systems and
microcontroller programming. Learning how to use timer interrupts to perform actions at specific
intervals. We did this by first using a button interrupt (CN) to rotate or count, then switching the
rotate action to a rotating action.

Introduction:
This experiment looks at how timers and interrupts work in microcontrollers, which are essential
for keeping track of time and managing tasks. It explains how timers and interrupts are
programmed and set up in a microcontroller and shows how they help with task management.
The experiment provides useful insights for people interested in embedded systems and
microcontroller programming. Learning how to use timer interrupts to perform actions at specific
intervals. We did this by first using a button interrupt (CN) to rotate or count, then switching the
rotate action to a rotating action.

Tools Used:
• ChipKIT Pro MX7 processor board with USB cable
• Microchip MPLAB X IDE
• MPLAB XC32++ Compiler
• MPLAB Harmony Framework

Experimental Results
o Project Initialize:
We began the experiment by setting up a new project and performing the necessary
configurations in the following sequence:
• Set the System Clock (SYSCLK) to 80 MHz.
• Configured the Peripheral Bus Clock (PBCLK) to 10 MHz, achieved by applying a
postscaler with a division factor of 8.

rimental Results
An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT
‫كلية الهندسة وتكنولوجيا المعلومات‬

o Project Initialize:
• Configured the key device settings.

• Set up the I/O pins, with digital output pins connected to LEDs on pins RG12 - RG15.
Change Notification interrupt 8 (CN8) was assigned to BTN1 on pin RG6, while CN9
was assigned to BTN2 on pin RG7.

o Timer Driver Configuration:


We then proceeded to enable and configure the timer driver by:

• Navigating to the options tab in MPLAB Harmony Configurator (MHC) and expanding
the configuration tree to access the drivers and timer settings.

• Enabling the "Use Timer Driver" option, setting the driver implementation to
"STATIC" and enabling interrupt mode.

• Selecting a single timer driver instance (1) and assigning it to timer0.

• Setting the timer period to 29297, calculated using formula (1) for a desired period
of 0.75 seconds, a prescaler value of 256, and a PBCLK of 10 MHz.

o Code Implementation :
• Finally, we developed code to manage the actions triggered by pressing BTN1 or
BTN2. The first segment, linked to BTN1, was implemented for counting, while the
second segment, linked to BTN2, was for rotating. Before these core
implementations,

• two preliminary checks were conducted to ensure the buttons (BTNs) were properly
connected to the change notifications (CNs) and functioning as expected. The LEDs
responded by turning on or off depending on which button (1 or 2) was pressed,
confirming proper functionality. Additionally, a timer-driven counter was used to
verify the timer's performance, with its status displayed through the LEDs.
An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT
‫كلية الهندسة وتكنولوجيا المعلومات‬

The code for the app.h:

The code for the app.C:


An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT
‫كلية الهندسة وتكنولوجيا المعلومات‬

In the above code, we have Two states:


1. Count Up: This state increments the count value by one and displays the
result on the LEDs. We use “appData.count += 0x1000” to directly show the
value on the LEDs (RG12-RG15).
2. Rotate: This state rotates the LEDs' lights each time it is executed.
An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT
‫كلية الهندسة وتكنولوجيا المعلومات‬

The code for system_interrupts.C


An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT
‫كلية الهندسة وتكنولوجيا المعلومات‬

In the predvious code, we have an ISR for the timer and CN interrupts for buttons
1 and 2. Each time a CN interrupt occurs, we check which button is pressed and set
a flag to 1 or 2 accordingly. When the timer interrupt occurs, we set the state to
perform the corresponding action based on the flag.

Conclusions:
The results of this experiment highlight the effectiveness of timers and change
notification interrupts in managing time-based events and quickly responding to
input changes. These features are highly valuable in embedded systems design,
enabling the development of advanced and reliable systems capable of executing
tasks with precision.

In conclusion, this experiment underscores the critical role that timers and change
notification interrupts play in embedded systems. Their ability to enhance the
functionality and performance of microcontroller-based systems further
demonstrates their significance in this field.

You might also like