nrf52840 UART variable length receive

hi

I have a question about uart receive.

The UART example receives data based on special characters or the length of the received data to determine whether it is a string.but in my code receives not special characters or unknown length.

In the nRF5 SDK v17.1.0 has example of \examples\peripheral\libuarte, It manages the receive buffers and implements the receiver inactivity timeout.I need this way to receive UART string that unknown length and do not contain special character.

My code is based on FREERTOS,I  tryed nrf_libuarte_async.c,nrf_libuarte_drv.c etc all the way to my code,but Compile error.

How do I implement receiving UART data of variable length like example of \examples\peripheral\libuarte?

I looking forward.

gary

Parents
  • Hi, 

    How do I implement receiving UART data of variable length like example of \examples\peripheral\libuarte?

    You should be able to port this example to FreeRTOS but I do not have any templates to show you at this moment. It looks like a very simple example that can be easily ported to FreeRTOS where the callbacks are happening in interrupt context. All you need to do is to create another FreeRTOS task to be able to do a NRF_LOG_FLUSH in a loop in the new task.

  • Hi,

    I have tried porting example of \examples\peripheral\libuarte into FreeRTOS,but the compiled failed after the porting was complete.example of libuarte is bare-metal program, porting Directly to FreeRTOS to compiled failed, I guess it is a timer conflict.I am very frustrated, do not know how to solve.I wonder if you can help me,write an example project based on FreeRTOS.I`m looking forward to your reply.

    sincerely yours.

  • It is not possible for us to provide examples will all possible combinations of features (baremetal or OS). All the examples given are to be used as a template and then you add features there after. This is better than starting from scratch for most of the cases.

    shark said:
    I guess it is a timer conflict.I am very frustrated, do not know how to solve.I wonder if you can help me,write an example project based on FreeRTOS.

    Libuarte and FreeRTOS combo is not supported out of the box. So you need to do this yourself. Ofcourse we can help you solve technical issues, but you need to be more specific on the problem you have. 

    What is the setup you are using (Device and SDK version)?
    What are the changes you made?
    what errors are you getting? 

    Can you give us some code snippets on the changes you made in your porting efforts so that we can try to see if we can review/help ?

  • I have used nRF5_SDK_17.1.0_ddde560version SDK,libuarte is base-metal program,porting a a part of UART function to blinky_freertos to compiled failed.as follows:

    .\_build\nrf52840_xxaa.axf: Error: L6200E: Symbol RTC1_IRQHandler multiply defined (by drv_rtc.o and port_cmsis_systick.o).

    .\_build\nrf52840_xxaa.axf: Error: L6200E: Symbol app_timer_create multiply defined (by app_timer2.o and app_timer_freertos.o).

    .\_build\nrf52840_xxaa.axf: Error: L6200E: Symbol app_timer_init multiply defined (by app_timer2.o and app_timer_freertos.o).

    .\_build\nrf52840_xxaa.axf: Error: L6200E: Symbol app_timer_start multiply defined (by app_timer2.o and app_timer_freertos.o).

    .\_build\nrf52840_xxaa.axf: Error: L6200E: Symbol app_timer_stop multiply defined (by app_timer2.o and app_timer_freertos.o).

    How do I solve it?

    In the meantime,I`m looking at other solutions you recommended.

  • you need to remote app_timer2.c from your project and only include app_timer_freertos.c. 

  • Thanks for your reply, the problem has been solved.
    But I have one more question. My program uses the NRF_LIBARTE_ASYNC_EVT_RX_DATA event to determine if the data has been received.
    When data is received, timeout and RX_buffer is full generate events. If a timeout occurs, an event is generated indicating that the data stream has been received. If rx_Buffer is full, an event is generated indicating that the data may not have been received.

    When an event is generated, how do you know that data is still being received?

  • shark said:
    If a timeout occurs, an event is generated indicating that the data stream has been received. If rx_Buffer is full, an event is generated indicating that the data may not have been received.

    It is a bit unclear to me what you mean here.  

    shark said:
    If a timeout occurs, an event is generated indicating that the data stream has been received.

    A timeout normally means that the complete data has not being received.

    shark said:
    When an event is generated, how do you know that data is still being received?

    Which event exactly are we discussing about here? Is it still NRF_LIBARTE_ASYNC_EVT_RX_DATA ?

Reply
  • shark said:
    If a timeout occurs, an event is generated indicating that the data stream has been received. If rx_Buffer is full, an event is generated indicating that the data may not have been received.

    It is a bit unclear to me what you mean here.  

    shark said:
    If a timeout occurs, an event is generated indicating that the data stream has been received.

    A timeout normally means that the complete data has not being received.

    shark said:
    When an event is generated, how do you know that data is still being received?

    Which event exactly are we discussing about here? Is it still NRF_LIBARTE_ASYNC_EVT_RX_DATA ?

Children
No Data
Related