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

SAADC example's saadc_callback has a buffer "p_event->data.done.p_buffer" in a for loop, is not printing full buffer size data.

Hi.

I am using nRF52840 dongle and running saadc example on it.

To print the ADC data buffer "p_event->data.done.p_buffer" in PC, I am using USB_CDC. The size of SAMPLES_IN_BUFFER is 5.

In the "saadc_sampling_event_init()", 400 is the parameter value passed in the nrf_drv_timer_ms_to_ticks() function.

However, I am only getting one data in the for loop from the saadc_callback. Actually I should get 5 data.

Any reason why this happens?

Thank you.

Parents
  • Hi,

    How are you printing the buffer? You will either need to print each element in p_event->data.done.p_buffer:

    printf("%d", p_event->data.done.p_buffer[0]);
    printf("%d", p_event->data.done.p_buffer[1]);
    printf("%d", p_event->data.done.p_buffer[2]);
    etc,
    

    Or you can take in the size of the pointer as an argument to know how much you need to print, for example using NRF_LOG_HEXDUMP_INFO.

    Best regards,

    Marjeris

  • Hi Marjeris.

    Sorry for so much late.

    I am filling up two buffers of 5 capacity each. I am printing as below pic, inside the call back. And I get the output as in the next pic.

    The USBPrint function internally fills up a buffer containing the parameter information and does a "app_usbd_cdc_acm_write".

    So, the for loop is not running correctly I guess. Or may be I am wrong and something else is there. Only two indexes are printing out of 5.

    I did the way you have shared. Printed each values of the buffer individually. Still its the same output is coming on teraterm.

    But I tried printing the buffer outside the call back. And all data are printed.

    I have not changed the value 400 in "nrf_drv_timer_ms_to_ticks".

    This number(400) is the sampling rate of the ADC. Right?

    Thank you.

Reply Children
Related