Thank you very much! Just wanted to let everyone know that the solutions presented work great. I did find another issue with the processor that was putting out the RS232 to the 12F683 (incorrect clock freq which threw the timing out the door). The real key to the problem I was having was declaring the VAR value as a WORD and not BYTE - goes to show that you shouldn't take for granted even the little simple things.
I thought I'd post the final version of the code incase someone else needs help with something like this:
Next job is to figure out the settings to place the processor in sleep with a wake-up on interrupt from GPIO.2 when a serial input is recieved. I need to do some reading in the datasheet and search previous posts first. Its nice to know that there are some knowledgeable people out there if I run into problems!Code:@ DEVICE PIC12F683, MCLR_OFF, INTRC_OSC_NOCLKOUT, WDT_ON, BOD_OFF @ DEVICE PWRT_ON, FCMEN_OFF, IESO_OFF, PROTECT_OFF DEFINE ADC_BITS 10 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 200 ANSEL = %00111011 ADCON0 = %10000001 TRISIO = %0001111 OSCCON = %01100000 CMCON0 = %00000111 INTCON.7 = 0 INTCON.3 = 1 RESULT VAR word[3] value var byte holding var word i var byte MAIN: output GPIO.5 GPIO.5 = 1 Goto Main1 Main1: SERIN2 GPIO.2, 396, [WAIT("A"), value] if value = 1 then GPIO.5 = 0 else if value = 2 then gosub GETADC gosub display1 endif endif goto Main1 end display1: serout2 GPIO.2, 396, 10, [dec result[0], 13] serout2 GPIO.2, 396, 10, [dec result[1], 13] serout2 GPIO.2, 396, 10, [dec result[2], 13] return end GETADC: 'average ADC over 10 cycles holding = 0 for i = 1 to 10 adcin 0, result[2] holding = holding + result[2] pause 10 next i holding = holding/10 result[2] = holding holding = 0 for i = 1 to 10 adcin 1, result[1] holding = holding + result[1] pause 10 next i holding = holding/10 result[1] = holding holding = 0 for i = 1 to 10 adcin 3, result[0] holding = holding + result[0] pause 10 next i holding = holding/10 result[0] = holding return end end
Bob




Bookmarks