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

With NRF52840 UARTE0, I need to increase the buffer size from 1 byte to 64 bytes. But with this cannot receive 1 byte packet.

Hi,

I'm using a buffer size of 64 bytes using function

nrf_drv_uart_rx(&app_uart_inst, rx_buffer, 64);

When I receive only one byte packet from the remote, I get EVENT_RXDRDY (which I expect). I then wait for about 10 ms.

1. EVENT_RXDRDY

2. delay_ms(10)

3. trigger FLUSHRX

4. Read UARTE register AMOUNT

I get AMOUNT = 0 all the time

Why I'm not getting AMOUNT = 1?

This code works if the buffer size is set to 1.

Please help. Let me know I need to do some trick.

Parents
  • Hi,

    • Is an EVENT_RXDRDY event generated between the step 1 and step 4
    • Do you stop the peripheral with TASKS_STOPRX before you read the AMOUNT register? 
    • Can you share a minimal project that reproduce the error?

    regards

    Jared 

  • Hi Jared,

    From the source of the UART character, I send one character to NRF52840 and I get EVENT_RXDRDY in step 1. All other steps do not see EVENT_RXDRDY. According to the document of NRF52840, after TASK_FLUSHRX in step 3, I'm supposed to see EVENT_ENDRX (please correct me) but I never do. In my application, I cannot send any stop command and here I've not sent TASK_STOPRX at all. I've attached the whole project herewith. The directory it is

    C:\nordic\nRF5SDK160098a08e2\myprojects\peripheral

    7271.usbd_cdc_acm.zip

  • Hi,

    I'm getting several errors when i'm trying to build your project in IAR. Could you just share your entire SDK that contains the project. That should solve the implicit declaration errors. Error P140 "too many arguments in function call" should be resolved before you upload the SDK.

    regards

    Jared 

  • I've changed the libraries also. That's why there are errors. I removed the errors and tried it myself. The problem is still there. Attached is the same project with errors removed. Please let me know if you still get errors.

    6131.usbd_cdc_acm.zip

  • Hi,

    The implicit declaration errors are removed but you still have errors regarding "too many arguments" in app_usbd_cdc_acm_read(). The function takes in 3 parameters not 4. It seems that you try to pass both a size parameter and a read_len. This should be fixed.

    regards

    Jared 

  • app_usbd_cdc_acm.c

    app_usbd_cdc_acm.h

    Please copy these files to your directory (overwrite the existing ones). I've added the fourth parameter to get the actual number of bytes read.

    myprojects\..\components\libraries\usbd\class\cdc\acm\

  • I see there is a typecast error (the third error above). Could you tell me which line number is it and which function?

Reply Children
  • Please replace the file main.c with the following