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

nRF51822 PWM strange behavior

Hi.

I'm using latest version of nrf51-pwm-library to test if PWM works fine, but unfortunately, it's not. I have very simple program which should fade LED from 255 to 0 in infinite loop, but instead fading, I can see LED light on 100% and then turn off (blink instead fade). When I debug, I notice, LED is on (without any fading) when i > 0 and LED is off when i == 0.

Any suggestions? Btw no softdevice is used so far.

This is how my code look like:

#include <stdbool.h>
#include <stdint.h>
#include "nrf.h"
#include "nrf_gpio.h"
#include "nrf_delay.h"
#include "nrf_pwm.h"
#include "boards.h"

int main(void)
{
    nrf_pwm_config_t pwm_config = PWM_DEFAULT_CONFIG;
    
    pwm_config.mode             = PWM_MODE_LED_255;
    pwm_config.num_channels     = 1;
    pwm_config.gpio_num[0]      = 9;   
    
    // Initialize the PWM library
    nrf_pwm_init(&pwm_config);

		for(uint8_t i = 255; i >= 0; i--){
			nrf_pwm_set_value(0, i);
			nrf_delay_ms(100);
		}
}
Parents Reply
  • You are correct. The compatibility matrix states that S110 8.0.0 has been tested with nRF51 second revision, but SDK 7+ has not been tested with nRF51 second revision and is not implemented for the second revision. SDK 7+ might not implement workaround for anomalies stated in the PAN document for second revision nRF51. To realize what changes has been made from second to third revision nRF51, look at the PCN document that describes that. You can see what PAN and PCN documents to look at in table 3 in the compatibility matrix.

    My advise, it is easier to get a third revision nRF51, unless you mean to update existing product in the field that contains nRF51 second revision devices. Is that your situation?

Children
No Data
Related