Introduction to Microcontrollers Lab Manual - Microchip
Introduction to Microcontrollers Lab Manual - Microchip
Introduction to Microcontrollers Lab Manual - Microchip
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
1.1 OBJECTIVE<br />
1.2 PRE-LAB<br />
<strong>Lab</strong> 1. Timers<br />
The lab covers the following concepts:<br />
• PIC24F hardware timer modules<br />
• Assembly language CALL and RCALL instructions<br />
• Using MPLAB IDE <strong>to</strong> measure code execution time<br />
1.2.1 Reference Material<br />
• PIC24FJ256GB110 Family Data Sheet (DS39897)<br />
• 16-Bit MCU and DSC Programmer’s Reference <strong>Manual</strong> (DS70157)<br />
• MPLAB IDE User’s Guide (DS51519)<br />
• PIC24F Reference <strong>Manual</strong> – Section 14. Timers (DS39704)<br />
1.2.2 Timers<br />
LABS<br />
The PIC24FJ256GB110 device offers five (5) 16-bit timers/counters designated as<br />
Timer1, Timer2, …<br />
With certain exceptions, all of the 16-bit timers have the same functional circuitry. The<br />
16-bit timers are classified in<strong>to</strong> three types <strong>to</strong> account for their functional differences:<br />
• Timer1 is a Type A timer<br />
• Timer2 and Timer4 are Type B timers<br />
• Timer3 and Timer5 are Type C timers<br />
Type B and Type C timers can be combined <strong>to</strong> form a 32-bit timer.<br />
Each timer module consists of the following readable/writable registers:<br />
• TMRx: 16-bit Timer Count register<br />
• PRx: 16-bit Timer Period register associated with the timer<br />
• TxCON: 16-bit Timer Control register associated with the timer<br />
Timers can be run from either an external clock connected <strong>to</strong> the TxCK pin, or the internal<br />
clock (Fosc/2). This lab will use the internal clock as the MX PIC24F EDU Module<br />
does not connect an external clock <strong>to</strong> the TxCLK pins.<br />
1.2.3 Subroutine CALL<br />
A subroutine CALL in assembly is a powerful <strong>to</strong>ol for reusing code and keeping your<br />
code clean and legible. Low-level functions can be abstracted in<strong>to</strong> higher level functions<br />
by the use of subroutine. This is similar <strong>to</strong> the use of a function in the 'C' language.<br />
In fact, 'C' functions make use of the RCALL assembly instruction.<br />
A CALL is similar <strong>to</strong> a GOTO or BRA instruction except that it s<strong>to</strong>res the address of the<br />
next instruction and allows you <strong>to</strong> return <strong>to</strong> it with the RETURN instruction.<br />
2011 <strong>Microchip</strong> Technology Inc. DS51963A-page 13