ok, i see what your saying for interupt handling and i'll read more when i get fedup trying to sort the comms out...
here is a little test program i've done to try and debug the problem with the serial comms...
Code:
include "modedefs.bas"
include "bs1defs.bas"
Define CONF_WORD = 0x3d71
Define OSC 4 ' Set clock speed
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
SPBRG = 25 ' Set baud rate to 2400
RCSTA = %10010000 ' Enable serial port and continuous receive
TXSTA = %00100000 ' Enable transmit and asynchronous mode
RCSTA = %10010000 ' Enable serial port and continuous receive
TXSTA = %00100000 ' Enable transmit and asynchronous mode
ADT1 var word ' Create ADT1 to store curent ad conversion for AD channel 0
ADT2 var word ' Create ADT2 to store curent ad conversion for AD channel 1
ADT1MAX var word ' Create ADT1MAX to store curent ADC0 max val
ADT1MAX = 0
ADT2MAX var word ' Create ADT2MAX to store curent ADC1 max val
ADT2MAX = 0
ADT1VAL var word
ADT1VAL = 0
ADT2VAL var word
ADT2VAL = 0
ADV1 var word
TRISE = 255 ' Set PortE to all inputs
TRISD = 0 ' Set PortD to all outputs
TRISC = 0 ' Set PortC to all outputs
TRISB = 0 ' Set PortB to all outputs
TRISA = 255 ' Set PORTA to all input
ADCON1 = 0 ' PORTA is analog
HSEROUT [" initialised",10,13]
SEROUT PORTB.1,t9600,[" initialised",10,13]
Loop:
ADCIN 0, ADT1
HSEROUT [DEC5 ADT1,10,13]
SEROUT PORTB.1,t9600,[#ADT1,10]
goto Loop
end
From software UART i get...
software uart output is reporting incorrect stop bits when it sends the "initialising" stream...
I should re-point out, i'm experimenting in a PIC simulator untill i get the right output...
i have a pair of 16F877's due to arive tomarow and JDM programmer and max232 converts (serial and USB versions) due to arive at any time...
I know i've not included the half second pause for ADC...
so, what have i missed out from my initialisations?
Thanks
Bookmarks