EasyManuals Logo

Microchip Technology PICkit 3 User Manual

Microchip Technology PICkit 3
102 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #58 background imageLoading...
Page #58 background image
PICkit™ 3 Starter Kit User’s Guide
DS41628B-page 58 2012 Microchip Technology Inc.
3.5.6 Assembly
3.5.6.1 ENHANCED MID-RANGE
It is important to note that the ADC result is left justified. This allows the swapf instruc-
tion to move the top four MSbs onto LATC.
EXAMPLE 3-21:
The dollar sign represents the current value of the address counter. The $-1 tells the
assembler to make the destination of the goto one less than the current address, in
other words, the previous instruction.
3.5.6.2 PIC18:
EXAMPLE 3-22:
Notice how it is $-2 instead of ‘1’. This is a very important difference. PIC18 instruction
words are two bytes long, and program memory in the PIC18 is byte addressable. The
previous instruction is two bytes back in address space. PIC18 instructions always
have an even numbered address.
3.5.7 C Language
3.5.7.0.1 Both Devices:
EXAMPLE 3-23:
Here, the ADRESH register is shifted to the right by four spaces. For an unsigned vari-
able, shifts are logical. For example:
;Start the ADC
nop ;requried ADC delay of 8uS => (1/(Fosc/4)) = (1/(500KHz/4)) = 8uS
banksel ADCON0
bsf ADCON0, GO ;start the ADC
btfsc ADCON0, GO ;this bit will be cleared when the conversion is complete
goto $-1 ;keep checking the above line until GO bit is clear
;Grab Results and write to the LEDs
swapf ADRESH, w ;Get the top 4 MSbs (remember that the ADC result is LEFT justified!)
Banksel LATC
movwf LATC ;move into the LEDs
bra MainLoop
TABLE 3-22: ADRESH BEFORE SHIFT
ADRESH – before shift
Bit # MSb (7) 654321LSb (0)
value 0 1011101
goto $-1 ;keep checking the above line until GO bit is clear
goto $-2 ;keep checking the above line until GO bit is clear
__delay_us(5); //wait for ADC charging cap to settle
GO = 1;
while (GO) continue; //wait for conversion to be finished
LATC = (ADRESH >> 4); //grab the top 4 MSbs

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Microchip Technology PICkit 3 and is the answer not in the manual?

Microchip Technology PICkit 3 Specifications

General IconGeneral
BrandMicrochip Technology
ModelPICkit 3
CategoryComputer Accessories
LanguageEnglish

Related product manuals