PSoC5LP Node to Node Uart Communication Issue

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
jaro_4346051
Level 2
Level 2
First like received First like given

I am currently working on a node to node communication project where the PSoC5LP is being used as a node. There is a 70.77888 MHz external crystal on each PSoC which ensures a consistent clock rate among the entire network.

Each node has a North and South full duplex Uart: baud rate of 115200, interrupt on byte received, no parity, and 1 stop bit. I have created my own software buffer system where there are two arrays that take turns buffering bytes for each Uart (ping pong), and a pointer will hold index 0 of whichever array is currently buffering bytes. This pointer is then used in the ISR which increments a single index for where to place the incoming byte. My two ISR routines are shown below with the associated buffers, pointers, and indices.

volatile uint8* NorthSerialBuffer;                  // north serial Rx Buffer pointer (extern in .h)

volatile uint8* SouthSerialBuffer;                  // south serial Rx Buffer pointer (extern in .h)

volatile uint8 NorthBuffer0[SERIAL_BUFFER_SIZE];    // north buffer 0

volatile uint8 NorthBuffer1[SERIAL_BUFFER_SIZE];    // north buffer 1

volatile uint8 SouthBuffer0[SERIAL_BUFFER_SIZE];    // south buffer 0

volatile uint8 SouthBuffer1[SERIAL_BUFFER_SIZE];    // south buffer 1

volatile uint16 NorthBufferIndex;                   // north buffer index (extern in .h)

volatile uint16 SouthBufferIndex;                   // south buffer index (extern in .h)

// north serial uart receive byte interrupt, stores a byte into NorthSerialBuffer and incrementes NorthBufferIndex

CY_ISR(ReceivedNorthByte) {

    NorthSerialBuffer[NorthBufferIndex++] = uComNoUart_RXDATA_REG;

}

// south serial uart receive byte interrupt, stores a byte into SouthSerialBuffer and incrementes SouthBufferIndex

CY_ISR(ReceivedSouthByte) {

    SouthSerialBuffer[SouthBufferIndex++] = uComSoUart_RXDATA_REG;

}

The issue I am having is when I use a cable to tie a node to itself, it will send and receive bytes with no errors (so far I haven't encountered an error or issue). But once I link nodes together they seem to be sending and receiving the correct bytes if the string of bytes is under around 20 bytes. But once I send bytes longer than 20 they eventually start to read bytes incorrectly. If there are no Uart errors with one node by itself, why would linking another node with the same code create so many issues with reception?

Also, I have been using the SouthBufferIndex and NorthBufferIndex volatile variables in order to determine where my software buffers are currently. Sometimes in blocking statements like while (NorthBufferIndex < 10) {}. Is using a busy wait like this bad practice even though it is a volatile variable?

0 Likes
3 Replies
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi jaro_4346051

Can you please attach your project? It would help us debug the issue faster.

Regards

Hari

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi jaro_4346051

Can you please probe the UART lines to check the data that is being transmitted? The waveform will help in confirming if the issue is with Transmitter or receiver. Also, since it is working when connected to the same board, it could be some timing issue. The waveform will help in debugging that as well.

Best regards

Hari

0 Likes