3 Replies Latest reply on Dec 13, 2019 2:11 AM by AH_96

    PSoC5LP Node to Node Uart Communication Issue


      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?