Re: Index a bit through a portion of a port
Hey Again-
With this thread : http://www.picbasic.co.uk/forum/showthread.php?t=14038 I have tried the following, but it does NOT compile. The errors are too many but the 1st couple are:
Syntax error, redefinition of label pLED, syntax error. So I think it may be a dumb thing on my part....
Pertinant code below:
'-----------------------------------------------------------------------------------------
'Additional I/O Definitions
error var PORTG.3 'ERROR output, ACTIVE LOW (LED)
heart var PORTG.0 'Heartbeat to know we are online - ACTIVE LOW
CTS Var PORTG.4 'Goes high to xmit on RS485
pLED[1] VAR PORTA.3 'Network activity LED1
pLED[2] VAR PORTA.4 'Network activity LED2
pLED[3] VAR PORTA.5 'Network activity LED3
pLED[4] VAR PORTA.6 'Network activity LED4
AC var PORTA.2 '110 VAC present or not - low if present
'------------------------------------------------------------------------------------------
'Variable List
i var byte 'Loop counter var
j var byte 'Loop counter var
rxbyte var byte 'serial receive byte
sync var byte 'data byte 1 - $54
chksum var word '16 bit checksum
bad_data var bit 'Bad data indicator
adval5 var word 'A2D conversion result 5v
adval24 var word 'A2D conversion result 24v
pkt_cntr var byte 'Variable to rotate the 4 LES indicating received packets
CRC16 var word 'CRC16 holder
Actual code:
start1:
' DEBUG "5 volt= ",DEC adval5 DIG 3,".",DEC3 adval5, 10, 13
if packetRcvd=1 then 'Packet has arrived!
pkt_cntr = pkt_cntr+1 'Increase the counter so we can turn on new LED
toggle pLED[pkt_cntr] 'Turns on new packet LED
' debug HDB2, HDB1, source_h, source_l, dest_h, dest_l, datab1, crc_high, crc_low, 10, 13
endif
if pkt_cntr=4 then pkt_cntr=0 'We have run through all 4 LEDs so reset counter
PacketRcvd=0 'Done processing packet data so reset flag
goto start1
Again, this is to test the theory but it does not work.
Any help??
Regards
"If we knew what we were doing, it wouldn't be called research"
- Albert Einstein
Bookmarks