I am using ATSAMD21 microcontroller as a slave which is connected to a Master MCU(ESP32) through UART. OS- For ATSAMD21 - FreeRTOS (IDE- MPLAB) and for ESP32 (FreeRTOS).
One of my application in SAMD21 controller is to read and write in a "while" loop in continuous manner. for ex-
while(1)
{
memset(ch,0,2);
SERCOM3_USART_Read(ch,2);
SERCOM3_USART_Write(th,2);
}
Note- Here 'ch' and 'th' are char[]. the issue what I am facing here - on reading it should not wait for the interrupt and should perform the next instruction which is "write". But here it is waiting till the master controller (ESP32) have send any character to the SAMD21 and then it perform the next "write" operation and again wait for the next message to get read.
I have changed something into the driver layer-
https://drive.google.com/file/d/1rNHuQp0irYJdlRmpt5qk-6NeG3qgAWmx/view?usp=sharing
Here I changed line no- 370 from-
while((SERCOM3_REGS->USART_INT.SERCOM_INTFLAG & SERCOM_USART_INT_INTFLAG_RXC_Msk) == 0U)
{
/* Do nothing */
}
to-
if((SERCOM3_REGS->USART_INT.SERCOM_INTFLAG & SERCOM_USART_INT_INTFLAG_RXC_Msk) == 0U)
{
/* Do nothing */
}
In this my problem is resolved but I am able to take only one byte of data at a time. If I am sending more then 1 byte it is taking series of last data.
How can I run my function in continuous manner for reading and writing through UART in this.