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

nrf52 adc spike problem

Hi,

I'm using nrf52 with s132(v17.0.0).

When I connect nrf52 with my phone, there is error like this picture.

And, the code is

#define SAADC_SAMPLES_IN_BUFFER 240

void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
    if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
    {
        ret_code_t err_code;
        uint16_t bytes_to_send = (uint16_t) SAADC_SAMPLES_IN_BUFFER;
        uint8_t DATA[SAADC_SAMPLES_IN_BUFFER];
        // set buffers
        err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAADC_SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);

        // print samples on hardware UART and parse data for BLE transmission

        for (int i = 0; i < SAADC_SAMPLES_IN_BUFFER; i++)
        {
          DATA[i] = p_event->data.done.p_buffer[i];
        }
       err_code = ble_nus_data_send(&m_nus, DATA, &bytes_to_send, m_conn_handle);
         
        if ((err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_NOT_FOUND))
        {
            APP_ERROR_CHECK(err_code);
        }
        
    }
}

When the buffer is filled, then next buffer is filled by ADC value.

I guess the problem occurs at this time.

Also, when I use printf function to see value in PC, same problem occurs.

How can I solve this?

Thank you.

Parents
  • Hello,

    I'm using nrf52 with s132(v17.0.0).

    Thank you for clarifying. I recommend that you upgrade to SDK v17.0.2 as it is API compatible and contains some bugfixes - all you need to do is download the v.17.0.2 SDK and move your project over to it instead.

    When I connect nrf52 with my phone, there is error like this picture.

    What is the axis labels here? Please include more of the image. Without the axis' labels and magnitudes it is very hard to say anything about what this is depicting.

    And, the code is

    Could you possibly share your entire main.c file, or at least all the SAADC related code from your application?
    For example, how are you triggering sampling - are doing periodic sampling through PPI ( like in the SAADC example ), or are you calling the samples manually?

    I guess the problem occurs at this time.
    Also, when I use printf function to see value in PC, same problem occurs.

    I assume these values are a list of returned SAADC samples? If so, what were you sampling, and what were you expecting?
    It seems you have a 10x value halfway through this list. Is this expected?
    Since I know nothing about what you are sampling, I also do not know if this 10 x spike is as expected. If it is, I have no idea what you would like me to read from this list - please elaborate. 

    How can I solve this?

    I do not yet know enough about the issue to help you resolve it, but I look forward to resolving this issue together!

    Best regards,
    Karl

Reply
  • Hello,

    I'm using nrf52 with s132(v17.0.0).

    Thank you for clarifying. I recommend that you upgrade to SDK v17.0.2 as it is API compatible and contains some bugfixes - all you need to do is download the v.17.0.2 SDK and move your project over to it instead.

    When I connect nrf52 with my phone, there is error like this picture.

    What is the axis labels here? Please include more of the image. Without the axis' labels and magnitudes it is very hard to say anything about what this is depicting.

    And, the code is

    Could you possibly share your entire main.c file, or at least all the SAADC related code from your application?
    For example, how are you triggering sampling - are doing periodic sampling through PPI ( like in the SAADC example ), or are you calling the samples manually?

    I guess the problem occurs at this time.
    Also, when I use printf function to see value in PC, same problem occurs.

    I assume these values are a list of returned SAADC samples? If so, what were you sampling, and what were you expecting?
    It seems you have a 10x value halfway through this list. Is this expected?
    Since I know nothing about what you are sampling, I also do not know if this 10 x spike is as expected. If it is, I have no idea what you would like me to read from this list - please elaborate. 

    How can I solve this?

    I do not yet know enough about the issue to help you resolve it, but I look forward to resolving this issue together!

    Best regards,
    Karl

Children
No Data
Related