be80be
Well-Known Member
What would be the best way to say catch four adc values like low to high
I have this started it works good just don't no how to save four values
I have this started it works good just don't no how to save four values
Code:
list p=16f684 ; list directive to define processor
#include <P16F684.inc> ; processor specific variable definitions
errorlevel -302 ; Turn off banking message
; known tested (good) code
__CONFIG _CP_OFF & _CPD_OFF & _BOD_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _FCMEN_OFF & _IESO_OFF
CBLOCK 0x020
saveadc
endc
ORG 0x000 ; processor reset vector
goto Start ; go to beginning of program
ORG 0x004 ; interrupt vector location
Start:
bsf STATUS,RP0 ; select Register Page 1
movlw 0xFF
movwf TRISA ; Make PortA all input
clrf TRISC ; Make PortC all output
movlw 0x10 ; A2D Clock Fosc/8
movwf ADCON1
bcf STATUS,RP0 ; back to Register Page 0
bcf STATUS,RP0 ; address Register Page 2
bsf STATUS,RP1
movlw 0xFF ; we want all Port A pins Analog
movwf ANSEL
bcf STATUS,RP0 ; address Register Page 0
bcf STATUS,RP1
movlw 0x01
movwf ADCON0 ; configure A2D for Channel 0
MainLoop:
call adcdelay ;delay to charge cap
bsf ADCON0,GO ; start conversion
btfss ADCON0,GO ; this bit will change to zero when the conversion is complete
goto $-1
movf ADRESH,w ; Copy the display to the LEDs
movwf saveadc ;save value adc
movf saveadc
movwf PORTC
goto MainLoop
adcdelay:
nop ;1 cycle
return ;4 cycles (including call)
end
Last edited: