i made my first experiment with pwm on PSOC4 S Series Pioneer Kit and i want to create a breathing led.
It works, but sometimes there is a flashing on the red led. Can somebody give me a hint, why the flashing occurs?
I use a pwm with a period of 1000 and a clock frequency of 100kHz. The result is a pwm of 100Hz - this is ok!
The red led is connected on port 3.
This is my code:
CyGlobalIntEnable; /* Enable global interrupts. */
for(i=0; i<999; i++)
for(i=999; i>1; i--)
Welcome in the forum.
When you set the compare value to something that is actually larger than the current count, the counter will count down to zero and a new cycle is started. This will introduce flicker.
Your loops are executing a lot faster than the PWM clock runs. I would suggest you to try making a breathe on or off in a fixed time given as 0.5 seconds using a 1ms timer with an interrupt. This would allow the CPU working on some other jobs in parallel.
Now i increased the pwm-frequency and it works fine 🙂
Please can you explain exactly, how it should work with the timer interrupt? Do you have an example?