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

How to trigger ADC from a timer interrupt, while generating PWM with the same timer and while using BLE on nRF51822?

Hi. I am a newbie in Nordic chips, quite knowledgeable in Atmel AVR, though. I'm working with an nRF51822 on a board like this www.waveshare.com/.../BLE400. I use the Mbed environment.

What I'm trying to do is this:

Generate a PWM signal on a pin, with period approximately equal to 4ms (200 ~ 250Hz) and variable duty cycle (within some limits, without ever reaching 0). Simultaneously, I want to measure voltage in another pin, but I want the ADC to trigger during the positive part of the PWM, in each cycle. That is, I'm controlling a heater with PWM, and want to measure current as a feedback, but I need to sample it during the positive cycle, synchronized to PWM, otherwise I would have random errors in the measure.

I have done this without trouble in AVR, using a hardware timer with interrupts, but I have no idea how to do it in the nRF51822 (maybe PPI? also no idea how to code it in Mbed..). In addition, I need to maintain a BLE connection while doing simultaneously PWM and ADC.

Any advice you can give me, I'm grateful.

Greetings.

Related