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

nrf_pwm signal glitches ("flickering") on nrf_pwm_set_value()

Hi!

I use nrf51-pwm-library ( github.com/.../) to control brightness of LED RGB light source and it works ok till I don't want to adjust brightness slowly (dimming function).

When I use

nrf_pwm_set_value(channel->pwmChannel, channel->currentBrightness);

function - no matter using scheduler or simple in for loop

		int counter = 0;
	int brightnessChangeDelay = 2000;
for (;;)
{
		if(counter++ >= brightnessChangeDelay)
		{
					nrf_pwm_set_value(channel->pwmChannel, channel->currentBrightness);
			counter = 0;
		}
}

Led flickers.

I though that the problem is caused by updating compare register to fast, but looking at nrf_pwm.c I see that it's updated via naxt_pwm_val after timer interrupt.

What else can cause the glitches? I think that reason is not in the communication, because when it's dimming very slowly and device is already disconnected for a long time it also happens.

__

it look's like that:

image description

in the middle is the moment, when I update the value... ;/

Related