I'm trying to receive an array from UART, but I only get the first 5 bytes.
I know that the receiver buffer is 4 words deep, but I need to receive the other bytes too. Maybe using a circular buffer, but I don't know how to uses this.
Can anyone help me to get all the bytes in the array?
This is my current code:
void __attribute__((__interrupt__, auto_psv)) _U1RXInterrupt(void) {
IFS0bits.U1RXIF = 0;
int i = 0;
while (U1STAbits.URXDA) {
array[i] = U1RXREG;
i++;
if (i == 10) {
break;
}
}
}
I'm sending each array position to a PC:
Sorry for my bad English.
Example :
Byte 1: 'S' :Startbyte
Byte 2: arrayByte[0]
Byte 3: arrayByte[1]
.......
Byte 11: arrayByte[9]
Byte 12: checksumm (maybe the LSB of the sum of all send Bytes)
The receiver will only start the receiption if the received Byte is an 'S'.
After the complete receiption of all Bytes the receiver had to calculate the checksumm again to be sure there are no Bytes lost.