Hello All-
I have a unique problem and I am trying to think of a better way to perform a feddback indication for packets received on a project. The project is essentially a chain of serial to parallel ports and parallel to serial ports. The serial data comes in RS485 and is detected via interrupt (Thanks DT!) via DT_INTS-18.
What I want to do is provide a visual that I have received a packet of data by turning on one LED in a group of 4. Each time I get a packet of data, I will turn ON the next in the series of 4 but also turn off the LED preceeding . It looks like the useless circle swirl on Windoze 7 - except it is useful here.

I got it working using a less efficient use of variables, lookup, and arrays - all which is not effecient. I have worked with snippets from
http://www.picbasic.co.uk/forum/showthread.php?t=14038
http://www.picbasic.co.uk/forum/showthread.php?t=12667

And while they work, I don't want to set a timer to turn the LED off.

Code fragment:
'Define configuration bits - kewl new use of PBP3!
#CONFIG
__config _CONFIG1H, _OSC_ECIO6_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__config _CONFIG2L, _PWRT_ON_2L & _BOREN_OFF_2L
__config _CONFIG2H, _WDT_OFF_2H
__config _CONFIG3H, _CCP2MX_PORTE_3H & _LPT1OSC_OFF_3H & _MCLRE_OFF_3H
__config _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
#ENDCONFIG
'---------------------------------------------------------------------------------------
'Define the oscillator and setup the INCLUDE files
DEFINE OSC 20 '20 MHz oscillator, external
INCLUDE "DT_INTS-18.bas" 'Base Interrupt System
INCLUDE "ReEnterPBP-18.bas" 'Include if using PBP interrupts
'---------------------------------------------------------------------------------------
'OKAY, Lets set up the registers.....
OSCCON= %01110100 '16 MHz internal clock
ADCON0= %00000000 'Turns ON ADC
ADCON1= %00001101 'Vref is AVdd and AVss, ANO and AN1 are used, all others are digital
ADCON2= %10000101 'RIGHT justified, 0 TAD A2D aq time select, Fosc/16
PSPCON= %00000000 'Parallel slave port is general I/O
CMCON= %00000111 'Turns OFF comparators
CVRCON= %00000000 'Comparator voltage ref is OFF
HLVDCON=%00000000 'High Low Voltage Detect is DISABLED
CCP1CON=%00000000 'Turns OFF capture, compare, pwm
CCP2CON=%00000000 'Turns OFF capture, compare, pwm
CCP3CON=%00000000 'Turns OFF capture, compare, pwm
CCP4CON=%00000000 'Turns OFF capture, compare, pwm
CCP5CON=%00000000 'Turns OFF capture, compare, pwm

INTCON2=%00000000 'ENABLE pullups on PORTB
'---------------------------------------------------------------------------------------
'Direction registers
TRISA = %10000111 'Set PORTA for bit7 is clk in, 4 led out, 3 A/D in
TRISB = %11000000 'PORTB is OUTPUT, except B6&B7
TRISC = %10000000 'Set RC7 (RX), rest are outputs, low 6 bits not used
TRISD = %11111111 'Set PORTD for high order INPUTS
TRISE = %11111111 'Set PORTE for low order INPUTS
TRISF = %00000000 'PORTF is low order OUTPUT
TRISG = %00100100 'PORTG is mixed '-----------------------------------------------------------------------------------------
'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
L1 VAR PORTA.3 'Network activity LED1
L2 VAR PORTA.4 'Network activity LED2
L3 VAR PORTA.5 'Network activity LED3
L4 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
pcounter var byte 'Variable to rotate the 4 LES indicating received packets
pout var byte '1st LED in rotation variable
pled_old var byte 'Previous packet LED indicator to turn OFF
CRC16 var word 'CRC16 holder
'-------------------------------------------------------------------------------------

Pseudo-code here:
If packet_rcvd = 1 then
turn on L1
all others (L2, L3, L4) off
endif

If packet_rcvd = 1 then
turn on L2
all others off

And so on in a round-robin fashion.

I have tried addrerssing the ports such as:
'Subroutines here
Packet_LEDs:
l1=pout.1
l2=pout.2
l3=pout.3
l4=pout.4
return
and refrencing them in the program which does work but for the turning off of the LEDs.

A.0, A.1 are used for analog, A.3 is digital in, A.3-A.6 are the LEDs as listed in the variables, and A.7 is used for clock in.

What I am curious about is if I can address the ports directly using assembler (?) and just cycle a '1' through the memory (couldnt figure that out) in a cyclic way??
I also tried using bitwise manipulation but that didnt seem to work well either.

Curious if anyone has done this or has any ideas from which I can learn?? Then I can tackle the CRC16 debockle..........

Regards to All,
Ecoli