This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Integrating Uart part from app_ble_uart example into pwm_driver example

i have integrated the uart relevant parts from the app_ble_uart example to the pwm_driver example, i did the modifications to the sdk_config and defines

i get an error while in 'uart_init()' because it has allready been initiated in the 'nrf_log_default_backends_init()' but for some reason many of the defines i added to the sdk_config file are in grey .. specificaly 'NRF_LOG_BACKEND_RTT_ENABLED'  which i think may prevent this error no 8 '..uart.. Initialized..'

may be you know why ? 

2. in the uart event handler i would like to be able to define that at some point the next event will come only after receiving X bytes to the dma and not get a new event for each byte in the message

3. what is the api for sending a buffer message via dma 

4. i would like to understand how to wirte a uarte event handler and define it works via dma not through an existing example so i will have better understanding of the software.. is there a guide to do so ?

5. in the app_ble_uart example it works with s2132, i was not sure if i hade to define it as well in the preproccessor defines, what is the differance if the s132 is flashed on me board but i don't define working with softdevice ?

6. one last thing, it is not clear for me from the app_ble_uart example when it is defined to work with UARTE and not UART, and does the UARTE (dma) has also 6 bytes limitation buffer for fifo or if it works in fifo,

i am a biginer with nordic and maybe some of the questions give indication to that

Parents
  • i no longer have the error,  i found the problem with the   NRF_LOG_BACKEND_RTT_ENABLED   not defined as enable -> 1 

    but now when i get the event after i am sending a message (via docklight application) , i cant send anything back via   NRF_LOG_INFO("");

    how do i send a byte array back, not by the app_uart_put () function which transfer one byte each time?

    also, strange but in the modified app_ble_uart example i was able to read printf() on the docklight as well .. what definition might have enabled it ?

  • Hello,

    ziv123 said:
    i no longer have the error,  i found the problem with the   NRF_LOG_BACKEND_RTT_ENABLED   not defined as enable -> 1 

    Great, I am happy you were able to figure out the cause of your issue!
    I was also going to suggest that you ensure that NRF_LOG_BACKEND_UART_ENABLED was set to 0.

    ziv123 said:
    but now when i get the event after i am sending a message (via docklight application) , i cant send anything back via   NRF_LOG_INFO("");

    I have not used the docklight application you mention, but you will need an RTT compatible reader to see the RTT output. Personally I use and recommend the J-Link RTT Viewer for this.

    ziv123 said:
    how do i send a byte array back, not by the app_uart_put () function which transfer one byte each time?

    A byte array transfer would just be multiple calls to app_uart_put(). Please see the UART API Reference for further detail about its functions.

    ziv123 said:
    also, strange but in the modified app_ble_uart example i was able to read printf() on the docklight as well .. what definition might have enabled it ?

    The UART example uses STDIO retargetting to have the printf function output to UART - if you have copied all your UART components from the UART example, this is probably why you are seeing it in your Docklight application.

    2. in the uart event handler i would like to be able to define that at some point the next event will come only after receiving X bytes to the dma and not get a new event for each byte in the message

    To implement this you could set up a counter for your receptions - but keep in mind that the buffer might overflow if you do not read it often enough. Please see the UART Documentation for further detail on this.

    3. what is the api for sending a buffer message via dma 

    To set up easyDMA transfers over UARTE you would have to set up PPI to trigger the STARTTX task, you can read more about that in the UARTE Documentation regarding Transmission.
    Bear in mind that both the UART and the UARTE peripheral supports easyDMA - but I would recommend using the UARTE peripheral.

    4. i would like to understand how to wirte a uarte event handler and define it works via dma not through an existing example so i will have better understanding of the software.. is there a guide to do so ?

    I am not sure what you are asking for here - you would like to do it yourself rather than seeing an example, in order to build a better understanding? If I have understood you correctly, then I suggest reading the UARTE Documentation I referenced above, in combination with the UARTE API Reference . While you definitely will learn a lot from doing it yourself from scratch, I recommend not excluding the chance to draw inspiration from existing solutions - especially regarding the correct configuration of the sdk_config file.

    5. in the app_ble_uart example it works with s2132, i was not sure if i hade to define it as well in the preproccessor defines, what is the differance if the s132 is flashed on me board but i don't define working with softdevice ?

    The SoftDevices takes up a lot of space and has the highest priority on the device. If you are not using BLE in your application, I suggest leaving it out of it all together.
    If you open an example from the SDK you could choose the "..\pcaXXXXX\blank" option(where available) to have the application without the SoftDevice.

    6. one last thing, it is not clear for me from the app_ble_uart example when it is defined to work with UARTE and not UART, and does the UARTE (dma) has also 6 bytes limitation buffer for fifo or if it works in fifo,

    You are partly correct, please see the UARTE Documentation I referenced earlier - it details how to use the UARTE and its limits.

    Best regards,
    Karl 

  • Hi .. thanks for detailed reply 

    I am a bit confuse though

    1. I read somewhere That The difference between UART and UARTE is that UARTE uses EasyDMA, and UART does not. But, from what I read here I understand that I can configure the UART to work with easyDMA, so what is the difference?

     

    1. Does any work with DMA (UART or UARTE) requires my configuration and setting of PPI to STARTRX and STARTTX tasks?

     

    1. Also read that UART is both faster and draws less current then UARTE, but usually when working with DMA we save energy because the CPU is not involved in the transfer, so how does it work here?

     

    1. I want to use DMA, the transfer to DMA can be a byte each time I don't care but I want to be notify when x number of bytes where received in the DMA and then I will copy them to local buffer in my event handler .. this way if I understand correctly, I am not limited to 6 bytes buffer and I don't risk losing data?

     

    1. Does the nrf52832 specifies somewhere the size given to DMA or address space ?
Reply
  • Hi .. thanks for detailed reply 

    I am a bit confuse though

    1. I read somewhere That The difference between UART and UARTE is that UARTE uses EasyDMA, and UART does not. But, from what I read here I understand that I can configure the UART to work with easyDMA, so what is the difference?

     

    1. Does any work with DMA (UART or UARTE) requires my configuration and setting of PPI to STARTRX and STARTTX tasks?

     

    1. Also read that UART is both faster and draws less current then UARTE, but usually when working with DMA we save energy because the CPU is not involved in the transfer, so how does it work here?

     

    1. I want to use DMA, the transfer to DMA can be a byte each time I don't care but I want to be notify when x number of bytes where received in the DMA and then I will copy them to local buffer in my event handler .. this way if I understand correctly, I am not limited to 6 bytes buffer and I don't risk losing data?

     

    1. Does the nrf52832 specifies somewhere the size given to DMA or address space ?
Children
  • Hello again, 

    ziv123 said:
    Hi .. thanks for detailed reply 

    No problem at all, I am happy to help!

    ziv123 said:
    I read somewhere That The difference between UART and UARTE is that UARTE uses EasyDMA, and UART does not. But, from what I read here I understand that I can configure the UART to work with easyDMA, so what is the difference?

    Yes, this is a bit confusing - since easyDMA support at first was introduced as a feature in the UART module, but since then we have created the UARTE for the purpose of solely using easyDMA.
    So, if you are looking to use UART with easyDMA, please use the UARTE module. Sorry about any confusion on this topic.

    ziv123 said:
    Does any work with DMA (UART or UARTE) requires my configuration and setting of PPI to STARTRX and STARTTX tasks?

     Yes, easyDMA in itself is not enough to make transactions happen. If you are going to use easyDMA to initiate a transaction without direct CPU interference, then you need some other signal to trigger the transfer. This is where PPI comes in. The SAADC peripheral example illustrates how to set up a PPI trigger.

    ziv123 said:
    Also read that UART is both faster and draws less current then UARTE, but usually when working with DMA we save energy because the CPU is not involved in the transfer, so how does it work here?

    Where have you read this? If you could refer me the resource that would be great.
    The CPU is indeed not involved in easyDMA transfers, and is thus more energy efficient in general, yes.
    There is not a whole lot of difference between the UART and UARTE module, except that the easyDMA is default in the UARTE module.
    There is not difference in transfer speed between the UART and the UARTE modules.

    ziv123 said:
    I want to use DMA, the transfer to DMA can be a byte each time I don't care but I want to be notify when x number of bytes where received in the DMA and then I will copy them to local buffer in my event handler .. this way if I understand correctly, I am not limited to 6 bytes buffer and I don't risk losing data?

    No, you may create a larger RX buffer by setting your RXD.MAXCNT.
    You will also receive an RXDRDY event per byte received in the RX buffer.
    The RX buffer can also be double buffered, to avoid loosing data once a buffer is filled.
    Please see the "reception" section of the nRF52832 UARTE documentation for more detail about this.

    ziv123 said:
    Does the nrf52832 specifies somewhere the size given to DMA or address space ?

     Yes, please have a look at the easyDMA documentation for the nRF52832.

    Best regards,
    Karl

Related