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

ADC 16KHz nrf51822

Hi all, I want to make sampling from microphone at 16KHz. So I want to first disable softdevice, do all measurements. An after that enable softdevice to transmit data. Will this procedure be enough to achieve such frequency? Or maybe it is enough to somehow permit BLE transmit receive without disabling softdevice? Thank you.

  • Hi Miroslav

    You probably already read this post which describes ADC sampling frequency limitations when using a softdevice.

    I suspect disconnecting from BLE peer device and not start advetising will make the softdevice be idle and not generate interrupts. That would make the ADC to be uninterrupted by the softdevice.

    If you have other interrupts in your system, it might be necessary to set the ADC interrupt with priority APP_IRQ_PRIORITY_HIGH, so it will not be interrupted or blocked by other application interrupts.

    The sampling time for 8-bit ADC configuration is 20us, so the max sampling frequency is 50kHz when uninterrupted.

    The sampling time for 10-bit ADC configuration is 68ua, so the max sampling frequency is 14,7 kHz when uninterrupted.

    Update 20.4.2016 On second thought, you may not need to disconnect from a BLE to sample ADC with >1kHz frequency. If you use radio notification, you get notified before a BLE connection event takes place, and also when it is finised. You could start your ADC sampling session when getting radio notification event for BLE connection event finised, but you must make sure the ADC stops sampling before the following connection event starts. Generally, a radio event takes 1 millisecond for each packet sent, so if you send a single packet in a connection event, the connection event will take 1 millisecond. If you send 6 packets in a single connection event, then the connection event will take ~6 milliseconds. Additionally the softdevice starts the 16MHz crystal 1.5ms before the start of a connection event.

    So if you set

    D = C - 7.5ms
    
    where:
    D: duration of the ADC sampling sequence
    C: BLE connection interval
    

    Then I don't expect the ADC sampling and the BLE connection event to occur at the same time.

  • Hi Stefan, Yes I read that. So as I see there is no need to disable softdevice. When I sample all data I can start advertising to send data I sampled with ADC. Thank you. Just one more question before closing subject: is 1.2V max limit for ADC?

  • You can measure up to 3.6V with the ADC, when setting 1/3 prescaler. The ADC range is however 0V-1.2V when setting 1/1 prescaler

Related