Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Poor Man's PWM

$
0
0

Hello to all,

 

in one of my projects that is reincarnating every few month I needed some PWM. Unfortunately on a pin that does not support it. To keep things simple, I thought I can do some kind of poor man's PWM just in a simple for loop. But it seems to be more some kind of stupid man's PWM. Because it is flickering very strong. I thought I can do in the main routine something like:

           for (int i = 0; i < 10; i++){
                    // poor mans PWM
                    if (i<brightness){
                        P1OUT |= 0x03;
                    }

                    else{
                        P1OUT &= 0xFC;
                    }
                }

The complete code can be found here.

The program is not that complex in my eyes, that it should flickering. What am I doing wrong here? I only need three different brightnesses, because the new LEDs are to bright. Has anybody an idea how I can solve my problem easy?

 

Greetings,

 

Sven

 

edit: Using MSP430-GCC as compiler, if this might be from interest.


Viewing all articles
Browse latest Browse all 2077

Trending Articles