55 code main loop interrupt service routine main

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: 0’ ADCON1 ; Configure ADC via ADCON1 STATUS, RP1 PIR1, ADIF ; Clear the ADIF flag (bit 6) STATUS,RP0 ; Access bank 1 PIE1, ADIE ; Enable AADC interrupt STATUS, RP0 ; Access bank 0 INTCON, PEIE ; Enable peripheral interrupts INTCON, GIE ; Enable global interrupts ADC.55 Code Main Loop & Interrupt Service Routine MAIN AD_ISR: *GO/DONE = 0 … call bsf goto … movf movwf movf movwf call bsf bcf retfie DELAY ADCON0,2 MAIN ; Wait for TACQ ; Start conversion (set GO) ADRESH,W TEMPH ADRESL,W TEMPL DELAY ADCON0,2 PIR1, ADIF ; Read A/D result (high byte) ; Write to TEMPH ; Read A/D result (low byte) ; Write to TEMPL ; Wait for TACQ ; Start conversion (set GO) ; Clear the interrupt ADC.56 ADC VDD An Example … with Push-button RA5/AN4 RA1/AN1 Vss PIC16F877 NOTE that in this case RA5 is a DIGITAL input and RA1 is an ANALOG input ADC.57 INIT_ADC: movlw movwf bsf movlw movwf movlw movwf bcf B’01001001’ ADCON0 ; Configure ADC via ADCON0 STATUS, RP0 ; Access bank 1 B’10000100’ ADCON1 ; Configure ADC via ADCON1 B’11111111’ ; Configure RA5 as an input pin TRISA STATUS, RP1 ADC.58...
View Full Document

This document was uploaded on 01/22/2014.

Ask a homework question - tutors are online