For the life of me, I can't figure out what is wrong with this code. This is just the start of a program where I check all the bytes in the serial port (DATAIN) --
if the total = 0 then it just loops and an LED is off.

If any of the bytes contain data (a 1 or greater) then the LED is on. Then, eventually on to do other stuff.

Maybe it's the way I set up the array as I've never used one in picbasic before.

The pause is in there so I can see the LED. Thanks for any help.


DATAIN VAR BYTE[13]
ADDUP VAR BYTE
TOTAL VAR BYTE

QUAL1 VAR BYTE
QUAL2 VAR BYTE

DATAIN= 0
TOTAL = 0
ADDUP = 0

QUAL1 = 170
QUAL2 = 255

START:


SerIn PORTA.0,N1200,[QUAL1,QUAL2],DATAIN

FOR TOTAL = 1 TO 13
ADDUP = ADDUP + DATAIN[TOTAL]
NEXT TOTAL

IF ADDUP = 0 THEN
LOW PORTA.1 'DATA RECEIVED LED OFF
GOTO START
ENDIF

IF ADDUP >= 1 THEN
HIGH PORTA.1 'DATA RECEIVED LED ON
ENDIF

PAUSE 3000

ADDUP = 0
TOTAL = 0
DATAIN = 0

GOTO START