Hi,
I need to interface my SAMD20 with another module through UART.
My approach is to call usart_read_job() in the main loop, so that anytime a new byte is received, the usart_read_callback() is invoked (I'm using this because I don't know how many bytes I could receive at a time, so the callback could not always be triggered).
Within such callback, I just append the received byte to a buffer and call usart_read_job() again to catch new bytes.
To test correct functioning, I'm transmitting 5 bytes from a serial terminal (Docklight) to the SAMD20, and reading them back once the 5th byte is received.
Everything is ok when I insert the 5 bytes manually (one by one): when the SAMD20 receives the 8th byte, it sends back the content of the buffer, with correct values.
However, when I transmit a predefined 5 bytes packet at a time (which is more likely what the external module would do (e.g. when it sends 'ERROR' after a command), the only correct byte is the first one, while others are messed up.
I was suspecting that the callback execution could cause delays in UART bytes parsing, but I've tried to slow down the baud rate from 9600 to even 110, and the result is exactly the same.
Any idea? Thank you in advance!