Aparently the PIC im using only has 368 bytes of ram. There isnt enough room to buffer 512 bytes of data.

I have been kinda trying to do that. I have a buffer in the form of an array (4 elements). When a byte is received it gets copied to a temp variable. Each one that arrives increases a counter. When the counter is between the lights address and the lights address plus 4 it copies the bytes into that buffer. Once the count reaches 512 then it moves the buffered bytes into the variables that control the PWM.

I suppose i could lose the temp variable meaning 1 less copy operation per byte. I actually added the buffer because its possible to send 1 byte at a time from the PC and i didnt want the PWM to update until all the data has been sent. It also syncs the lights better because the first one wont change until the last one is ready to change.

Because of the ram problem i need to process the first byte as soon as it comes in. One bit of that tells the light whether its using the line ID or the address so it knows which bytes to look for. Then im going to need an if statement to check if the byte is one of those that its looking out for. I can do everything else in the main loop if the datapos is 512.

I see why my origional code didnt work. The PWM part worked fine. I could fade the LEDs in and out etc. The problem was with serial. As soon as a byte arrived it stopped everything else processing to deal with the data. Simply accepting the byte and updating the PWM values even worked fine when sending 1024 bytes. The problems seem to start when if-thens and select cases are added. From what i know about this interrupt stuff i think i can still have all those ifs/selects but as long as they are in the main loop then the interrupt can break out half way through to update the outputs then carry on with the processing.

This all looks good but i thought thats what Darrel's code does. Darrel did mention that his code uses something like 70% of the processing power because of all the interrupts. Wouldnt i just get the same thing in PBP? From what ive heard ON INTERRUPT is even worse