nRF51822 : Timer capture and PWM generation with softdevice

Hello,

I have been developing some products over the nRF51822 BLE. Got my introduction with nRF about 2 months back and despite the steep learning curve I was able to integrate the softdevice with LESC passkey and some GPIO peripheral control for a BLE Lock product. NRF team has been a GREAT HELP.

Now I want to add one more peripheral that is a 125KHz RFID card reader. I have figured out the hardware for the same. It basically fires a 125KHz to the coil and depending on the load from RFID card, a data stream of one and zero is received from a comparator. 

Refer this link https://www.serasidis.gr/circuits/RFID_reader/125kHz_RFID_reader.htm

I basically want to integrate this using the nordic mcu.

I figured out the PWM output using the app__pwm example. I am a bit stuck on capturing the waveform. I get that I have to start the timer in counter mode triggered by one GPIO but I am not able to do this along with the softdevice running in parellel.

Please let me know of any literature available or any example for the same.

What I had done so far : 

1. BLE stack along with peer manager is working perfectly

2. A couple of notify and write characteristics are available to take care of the peripherals.

3. I have used two timers so far, one for the SD and one 100ms to do all my control related tasks.

4. I was able to generate a 125KHz PWM on one GPIO.

What I need to do : 

To capture the pulses on one GPIO (pin P0.07 in my case). How I perceive this is that I can make an array to store the capture values and then process it any time. Let me know if I am looking at this in a wrong way.

Peripherals used so far : 

/*****/control task timmer
APP_TIMER_INIT(0, 4, false);
    err_code = app_timer_create(&m_control_timer_id,
                                APP_TIMER_MODE_REPEATED,
                                control_timeout_handler);
    err_code = app_timer_start(m_control_timer_id, APP_TIMER_TICKS(100, 0), NULL);

/*****/peer manager timer
    uint32_t err_code = app_timer_create(&m_sec_req_timer_id,
                            APP_TIMER_MODE_SINGLE_SHOT,
    err_code = app_timer_start(m_sec_req_timer_id, SECURITY_REQUEST_DELAY, NULL);
                            sec_req_timeout_handler);

/*****/pwm output
    app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(8L, MCU1); // 125KHz on MCU1 pin
    err_code = app_pwm_init(&PWM1,&pwm1_cfg,NULL);
    APP_ERROR_CHECK(err_code);
    app_pwm_enable(&PWM1);
    app_pwm_channel_duty_set(&PWM1, 0, 50); //set initial duty as zero (instanct, channel, !duty)

/*****/general GPIOs on about 6 pins that are handled accross the code.

I also got to know about the PPI+timer+gpiote method but I was not able to get it running.

Also for me power consumption is very critical since it is a battery operated device. Any extra hardware uses a lot of power as I observed so I want to make it very minimal.(< 0.5mA total during idle operation).

Thanks & Regards

Related