Microchip Technology DM164130-9 Manuel D’Utilisation

Page de 101
PICkit™ 3 Starter Kit User’s Guide
DS41628B-page 60
 2012 Microchip Technology Inc.
3.6
LESSON 5: VARIABLE SPEED ROTATE
3.6.1
Introduction
This lesson combines all of the previous lessons to produce a variable speed rotating 
LED display that is proportional to the ADC value. The ADC value and LED rotate 
speed are inversely proportional to each other.
3.6.2
Hardware Effects
Rotate the POT counterclockwise to see the LEDs shift faster. 
3.6.3
Summary
A crucial step in this lesson is to check if the ADC value is 0. If it does not perform the 
zero check, and the ADC result is zero, the LEDs will rotate at an incorrect speed. This 
is an effect of the delay value underflowing from 0 to 255.
FIGURE 3-4:
PROGRAM FLOW
3.6.4
New Registers
None
3.6.5
New Instructions
3.6.5.1
BOTH
3.6.5.1.1
call
The call is equivalent to adding functions in ‘C’. They are convenient since they allow 
the designer to create subroutines which can then be called from a main function. This 
improves the memory use efficiency and readability of your program. 
TABLE 3-24:
NEW INSTRUCTIONS FOR BOTH DEVICES
Instruction
English
Purpose
call label
Call a subroutine
Modular code
return
Return to previous call statement
Modular code
xorwf
XOR register with WREG
Toggle a register
Configure ADC
Get ADC measurement
Delay according to ADC result
Rotate LEDs
Configure I/O Port
Check if ADC result is ‘0’