Hi,
Perhaps if you give some more specifics we can help optimise your flow better.
What speed is the Pic24 running at, what lines are receiving the packet, how many bytes does the packet contain, how many bytes does your decoded packet consist of, how may instructions does your decode routine take, what is the max speed of the USART to Xbee.
My PIC24FJ48GA004 is running off of the 8MHz internal RC oscillator. My signal is a manchester-encoded timecode signal that I'm receiving on a pin I have configured to utilize the input capture function (with the PIC I am using, the pins do not have dedicated functions, but rather you have a group of functions and a group of pins, and you map them to each other with a set of commands). The signal is about 90 bytes--it's a linear timecode signal that represents data in hours:minutes:seconds:frames used in the film industry, and the useful data appears scattered across the 90 bits (there are a lot of interspersed bits containing "fluff" data that is not important to me). The signal is an audio signal, so it arrives at the PIC (after a comparator stage to get it logic-level) at a frequency in the low kHz.
My Baud rate for UART to Xbee is 9600. I noticed that setting a baud rate any higher messes something up with the Xbee (I of course programmed both the TX/RX UART for this higher Baud rate, and changed the Baud rate command given to the Xbee upon TX or RX initialization sequence).
The free time that I have is at bit 58 out of 90--from bit 0 to bit 58, I have been grabbing the bits that are important to me, and I have been building an array of integers (which are the decoded bits). At bit 58, I build an array of 8 characters based on my array of integers. Then I transmit. So far, the only thing I can think of is transmitting each character as it is put into the array, and not building the whole array of 8 characters, THEN transmitting everything. My code for transmitting exists at the end of my while(1){} loop (where *everything* is happening, all the decoding, etc), and consists of the following:
if (U1STAbits.TRMT==1)
{
U1TXREG = timecodeArray[0];
}
if (U1STAbits.TRMT==1)
{
U1TXREG = timecodeArray[1];
}
if (U1STAbits.TRMT==1)
{
U1TXREG = timecodeArray[2];
}
And so on until timecodeArray[7] is transmitted. I think I have written this code incorrectly. I want it to transmit character by character, but am unsure about the correct way to "wait" until the TXREG is empty, without stalling the whole loop.
If you've read this far, thank you, and I would appreciate any further guidance anybody has!