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

ADC + PPI + Timer on the nRF51822 polling too fast

I have the following ADC code: bitbucket.org/.../eakpq

I have been trying for the past few days to get this code to just perform a single ADC scan, on five channels, once every 100ms.

It seems like this should be simple to do and I think the code should work, I have been referencing the example here: github.com/.../main.c

However, it does not work as expected. Instead of polling for an ADC sample once every 100ms it seems to poll as fast as possible and the ADC readings happen back to back. Polling so quickly seems to be stealing CPU from the Bluetooth module which subsequently disconnects.

If anybody could have a quick read over that code and let me know what I am doing wrong that would be much appreciated. I have poured over the documentation and cannot seem to work it out.

Parents
  • Update 2: A working example

    Thanks to the excellent help from these forums I have been able to put a working example together of the nRF51 working as a bluetooth keyboard with the ADC running: bitbucket.org/.../overview

    Update 1: Thread continuation

    This thread is continued by this question which has a working version of UART + ADC + PPI code for the 12.2.0 SDK. Use that as your starting point.

    Original Question

    Alright, here is what I did:

    • I downloaded the 11.0.0 SDK
    • Hooked it up to the github ADC example that I posted in the question: github.com/.../main.c
    • Attempted to get it running on my BLE400

    It worked but there were some gotchas.

    For starters, if I connected to a device that read the Bluetooth UART and I sent messages too quickly (because the ADC was reading too quickly) then I would get disconnections. Throttling the rate at which I sent the UART messages was a must. I suppose there must be documentation somewhere about the maximum rate in which you can send messages down the Bluetooth UART but I have not found it yet.

    Also, this seems to work for version 11.0.0 of the SDK. This is the good news.

    The bad news is that this is with version 11.0.0 of the SDK. I am going to attempt to update this code example to work with version 12.2.0 of the SDK and see if everything still works. Now that I know that this version does work on my device. Wish me luck; I'll post my results back here.

    Note: The annoying part is that ever the nRF52 version of these code samples uses SDK 11.0.0: github.com/.../ble_app_uart__saadc_timer_driven__scan_mode

    I wonder if the excellent Nordic support team will update these Github repositories. I've raised an issue to try and make that happen: github.com/.../4

Reply
  • Update 2: A working example

    Thanks to the excellent help from these forums I have been able to put a working example together of the nRF51 working as a bluetooth keyboard with the ADC running: bitbucket.org/.../overview

    Update 1: Thread continuation

    This thread is continued by this question which has a working version of UART + ADC + PPI code for the 12.2.0 SDK. Use that as your starting point.

    Original Question

    Alright, here is what I did:

    • I downloaded the 11.0.0 SDK
    • Hooked it up to the github ADC example that I posted in the question: github.com/.../main.c
    • Attempted to get it running on my BLE400

    It worked but there were some gotchas.

    For starters, if I connected to a device that read the Bluetooth UART and I sent messages too quickly (because the ADC was reading too quickly) then I would get disconnections. Throttling the rate at which I sent the UART messages was a must. I suppose there must be documentation somewhere about the maximum rate in which you can send messages down the Bluetooth UART but I have not found it yet.

    Also, this seems to work for version 11.0.0 of the SDK. This is the good news.

    The bad news is that this is with version 11.0.0 of the SDK. I am going to attempt to update this code example to work with version 12.2.0 of the SDK and see if everything still works. Now that I know that this version does work on my device. Wish me luck; I'll post my results back here.

    Note: The annoying part is that ever the nRF52 version of these code samples uses SDK 11.0.0: github.com/.../ble_app_uart__saadc_timer_driven__scan_mode

    I wonder if the excellent Nordic support team will update these Github repositories. I've raised an issue to try and make that happen: github.com/.../4

Children
Related