Hi,
I am implementing the UART on NRF52840. TX works but the RX doesnot. While debugging, I noticed that STARTRX task register is not getting set due to which the RXDRDY event is not getting detected. Below are the code snippets of Tx and Rx functions. Can you please help me resolve the issue.
Rx function:
uint8_t uart_rx_fun1()
{
uint8_t ret=0x00;
event_clear(UART0_REG->EVENTS_RXDRDY, UART_EVENT_RXDRDY);
//task_trigger(UART0_REG->TASKS_STARTRX,UART_TASK_START_RX);--RAMYA
NRF_UART0->TASKS_STARTRX = 1;
event_clear(UART0_REG->EVENTS_RXTO,UART_EVENT_RXTO);
uint32_t error_evt, rxdrdy_evt,rxto_evt;
do
{
error_evt=event_check(UART0_REG->EVENTS_ERROR,UART_EVENT_ERROR);
rxdrdy_evt=event_check(UART0_REG->EVENTS_RXDRDY, UART_EVENT_RXDRDY);
rxto_evt=event_check(UART0_REG->EVENTS_RXTO,UART_EVENT_RXTO);
}while(!(error_evt && rxdrdy_evt && rxto_evt));// wait till an event arrives
if(rxdrdy_evt)
{
event_clear(UART0_REG->EVENTS_RXDRDY, UART_EVENT_RXDRDY);
ret = UART0_REG->RXD;
}
return ret;
}
TX function
void uart_tx(uint8_t data_tx)
{
//clear the TXDRDY event
UART0_REG->EVENTS_TXDRDY=~UART_EVENT_TXDRDY;
//trigger the start task
UART0_REG->TASKS_STARTTX=1;//UART_TASK_START_TX;
UART0_REG->TXD = (uint32_t)(data_tx);//0x32;//
//EDIT: Doing in blocking mode
while(!UART0_REG->EVENTS_TXDRDY)
{
//do nothing
}
UART0_REG->TASKS_STOPTX=UART_TASK_STOP_TX;
}
Main
uint8_t tx_data[]="12345";
uint8_t* rx_data;
while(1)
{
for(int i=0; i<=sizeof(tx_data);i++)
{
uart_tx(tx_data[i]);
rx_data[i]=uart_rx_fun1();//uart_rx();
}
Thanks,
Ramya