6 Replies Latest reply on Jul 14, 2015 10:38 AM by kwang

    When is the puart rx callback called?

      Is it called immediately when anything is put into the uart rx buffer? Or does it wait until the buffer is either full or not receiving data to be called?

        • 1. Re: When is the puart rx callback called?
          BoonT_56

          I was checking out the uart-fw-upgrade source code in the sdk and found that the callback is called once for every byte received. It depends on what you set for the RX watermark.

          • 2. Re: When is the puart rx callback called?

            That's what I thought, but I'm getting some weird behavior. I'm sending a message to the uart rx pin that is 19 bytes long and I'm losing the last three bytes. Now I know the internal uart buffer is only 16 bytes, however, I figured since the callback fired every byte, it'd consume the bytes fast enough to not fill up the buffer and lose data. Since I'm only receiving the first 16 bytes, it seems like there is a large delay before the callback runs, causing the buffer to fill up before it can consume any bytes. I figured if the callback was firing once or twice as the buffer was filling that I would get 17 or 18 bytes, but I'm not. I tried lowering the baud rate so the data coming through the uart rx pin would come at a slower rate, it helped a little, but I ran into another bug where the data I send out through the uart tx pin starts losing bytes in the middle of the message. It seems since lowering the baud rate affects both pins, now the uart tx pin is receiving data from the chip too fast and losing data. I tried to enable flow control, but it appears to not be possible on the chip I have (BCM920737TAG). Are these bugs that I can't fix? Does anyone know of any work arounds?

            • 3. Re: When is the puart rx callback called?
              VictorZ_46

              The fifo size is 16 bytes.  If you need to send more than 16 bytes, you should use some flow control going back to the host saying that it can continue.  I think puart_control is using PUART_CONTROL_READ_CHUNK_SIZE for that purpose.

              if (bytes_read % PUART_CONTROL_READ_CHUNK_SIZE == 0)
              {
                 test_puart_write(PUART_CONTROL_EVENT_CONTINUE);
              }
              • 4. Re: When is the puart rx callback called?

                userc_19507 did you get a chance to test out what victorz wrote?

                • 5. Re: When is the puart rx callback called?

                  I didn't do exactly what he did, but I ended up implementing software flow control. Similar to his post, I just sent 16 bytes to the chip and had the chip respond over uart when it was done reading all 16 bytes and could receive another 16.

                  • 6. Re: When is the puart rx callback called?

                    thanks for sharing!