ee3954_fall13_10_adc

48 example configure ad module configure ad interrupt

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: bsf movlw movwf bcf … … … … 0x1F 0x1F 0x000 B’01001001’ ADCON0 STATUS, RP0 B’10000000’ ADCON1 STATUS, RP0 ; Configure ADC via ADCON0 ; Access bank 1 ; Configure ADC via ADCON1 ; Switch back to bank 0 ADC.48 Example Configure A/D Module Configure A/D Interrupt* Wait for TACQ Start Conversion (set GO) Wait for conversion to complete Read A/D Result Wait for at least 2TAD before next acquisition ADC.49 Example Wait for TACQ Need a delay for about/at least 20μseconds: DELAY: NXT: movlw movwf decfsz goto return 0x05 COUNT COUNT NXT ;1 ;1 ; 1/2 ;2 ;2 DELAY duration including ‘call’ and return’: 5 + 3*COUNT 5 + 3*COUNT = 20 => 3*COUNT = 15 => COUNT = 5 ADC.50 Code Main Loop MAIN: CHECK: *GO/DONE = 0 … call DELAY bsf ADCON0,2 btfsc ADCON0,2 goto CHECK movf ADRESH,W movwf TEMPH bsf STATUS,RP0 movf ADRESL,W bcf STATUS,RP0 movwf TEMPL nop nop goto MAIN ; Wait for TACQ ; Start conversion (set GO) ; Wait for conversion to complete* ; use POLLING ; Read A/D result (high byte) ; Write to TEMPH ; Read A/D result (low byte) ; Write to TEMPL ; 1 Wait for 4 instruction cycles ;1 ;2 2TAD = 2*8TOSC = 2*8*0.25μs = 4μs = 4 instruction cycles ADC.51 Code Main Loop - Sample Period MAIN: CHECK: … call DELAY bsf ADCON0,2 btfsc ADCON0,2 goto CHECK movf ADRESH,W movwf TEMPH bsf STATUS,RP0 movf ADRESL,W movwf...
View Full Document

Ask a homework question - tutors are online