I have wrote a code to process data received in a PICO from Raspi PI. I have a slider which sends number to the PICO(through UART) to set some values. If the slider is dragged slowly or clicked the values are received correctly. But when I try to slide the slider faster, data is sent but not everything is read by PICO Rx. I noticed that it receives only 32bytes and the rest of the data is not processed. Is there way I can read the whole data? I have UART read code below:

char Rec[] ="        ";
int k = 0;
ssd1306_t disp; 

// RX interrupt handler
void on_uart_rx() {
        Rec[k] = uart_getc(uart0);

1 Answer 1


Your draw_string commands are probably quite slow, so the serial buffer overflows, since you aren't fetching the serial characters in fast enough.

It is generally a bad idea to put a lot of code in an interrupt handler; it should do the minimum, and return. In this case, I'd probably just put the received characters in a buffer, nothing more. Then the main program can poll that buffer and when a complete message is detected, display it, and clear the buffer.

This means that the main program might be quite slow, and maybe the serial messages arrive faster than the main program can handle them - but that is a problem with your overall approach, you need a specific strategy for handling that. Maybe the receiver just discards the extra unwanted messages, or maybe each incoming message has to be acknowledged before another is sent - the choice is yours.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.