Hi all,
Using UART is confusing for me because I see various implementations in the documentation. There is a Serial library, then there is the UART driver and HAL. The HAL is further divided to UART and UARTE. I read that the difference between UART and UARTE is that the UARTE uses EasyDMA.
I like to try a few things:
1. Use PPI to setup a timer event to trigger a UART TX task. Eg. Send out "Hello" every 1 second.
2. Use PPI to setup a timer event to trigger a UART RX task. Eg. Read from UART every 1 second.
For (1), I have setup the ppi channel as follows:
err_code = nrf_drv_ppi_channel_assign(m_ppi_channel1, nrf_drv_timer_event_address_get(&m_timer1, NRF_TIMER_EVENT_COMPARE0), nrf_drv_uart_task_address_get(&uart_driver_instance, NRF_UART_TASK_STARTTX));
In this case, should I be using nrf_uart_task_address_get or nrf_uarte_task_address_get or nrf_drv_uart_task_address_get?
I also noticed that there is a NRF_UART_TASK_STOPTX. Does it mean that I also need to have an event to trigger a stop task? Otherwise, it will never stop transmitting?
How does the UART tx happen? Should I be placing the string in some register or ram address so that when the task is triggered, the string is automatically send from the tx pin? If I am using UARTE, I presume i should initalise the tx buffer with this function nrf_uarte_tx_buffer_set.?
For(2), the ppi channel is setup as follows:
err_code = nrf_drv_ppi_channel_assign(m_ppi_channel1, nrf_drv_timer_event_address_get(&m_timer1, NRF_TIMER_EVENT_COMPARE0), nrf_drv_uart_task_address_get(&uart_driver_instance, NRF_UART_TASK_STARTRX));
Similarly, how does the RX happen? What do I need to configure for the RX data to be stored to memory? How can I access it later when I wake up the CPU? Do I also need another event to stop the RX task?
This is the code that I have now.
Thanks in advance!