Hello Team,
This is regarding USART communication between a device (Example: Raspberry Pi) and LPC55S69 using Flexcomm2 interface.
I checked different sdk examples, and implemented my application in the similar manner, but still my application is not working as expected.
I have followed these steps,
I have Configured the relevant GPIO's (PIO1_24 as RX and PIO1_25 as TX) as given below
CLOCK_EnableClock(kCLOCK_Iocon);
CLOCK_EnableClock(kCLOCK_Gpio1);
// gpio_port_num=1, gpio_pin_num=24/25, gpio_pin_alt_func=0x01, enable_digital = 0x01
IOCON->PIO[gpio_port_num][gpio_pin_num] = ((IOCON->PIO[gpio_port_num][gpio_pin_num] &
/* Mask bits to zero which we are setting */
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_DIGIMODE_MASK)))
| IOCON_PIO_FUNC(gpio_pin_alt_func)
| IOCON_PIO_DIGIMODE(enable_digital));
Get the default configuration,
USART_GetDefaultConfig(&usart2_config);
usart2_config.baudRate_Bps = 921600U;
usart2_config.enableTx = false;
usart2_config.enableRx = true;
usart2_config.parityMode = kUSART_ParityDisabled;
usart2_config.stopBitCount = kUSART_OneStopBit;
Invoke uart init
// #define USART_IF2 USART2
USART_Init(USART_IF2, &usart2_config, CLOCK_GetFlexCommClkFreq(2U));
Create uart handle
USART_TransferCreateHandle(USART_IF2, &g_uartHandle, USART2_UserCallback, NULL);
Define receive buffer,
// #define BUFFER_SIZE 256
receiveXfer.data = receiveBuffer;
receiveXfer.dataSize = BUFFER_SIZE;
Invoke the non-blocking receive call,
if ((!rxOnGoing) && rxBufferEmpty)
{
USART_TransferGetReceiveCount(USART_IF2, &g_uartHandle, &rx_count);
USART_TransferReceiveNonBlocking(USART_IF2, &g_uartHandle, &receiveXfer, &receivedBytes);
}
When the above two functions are invoked in a while loop, then only I am seeing the data count (USART_TransferGetReceiveCount gives the correct data count).
Let's say Raspberry Pi is sending 10 bytes of data, USART_TransferGetReceiveCount is giving 10 bytes, but "USART_TransferReceiveNonBlocking" does not contain any data in the receive buffer.
Where as when the above two functions are invoked one time, there is no data count (zero) also seen.
The callback is defined like this,
void USART2_UserCallback(USART_Type *base, usart_handle_t *handle, status_t status, void *userData)
{
if (kStatus_USART_RxIdle == status || status == kStatus_Success)
{
PRINTF("status is kStatus_USART_RxIdle \r\n");
rxBufferEmpty = false;
rxOnGoing = false;
}
}
In the call back, the control never reached to this condition.
kStatus_USART_RxIdle == status || status == kStatus_Success
Can someone please let me know, what I am missing here?
Regards,
San
Hello,
Can someone please respond my question?
Regards,
San
Hello @sushmasan
Hello @Alice_Yang ,
Thanks for your response.
Before even posting this question, I tried all other possibilities (like trying with SDK examples between two EVK's) those examples working fine. But when it comes to testing with Rpi and I am seeing an issue.
Anyway I will check it from my end.
Regards,
Santhosh
Hello @sushmasan
Please use a logic analyzer to capture waveforms for analysis and figure out where the problems is in the communication process.
BR
Alice
Small correction in my previous message,
USART_TransferReceiveNonBlocking(USART_IF2, &g_uartHandle, &receiveXfer, &receivedBytes);
USART_TransferGetReceiveCount(USART_IF2, &g_uartHandle, &rx_count);
please note that this is the order the functions are invoked.