PDA

View Full Version : turning gpio.0 high after pwm command



sirvo
- 21st February 2007, 17:20
i've just developed a dimmer for the internal light of the car using pic12f629 but i've a problem:

when gpio.1 goes low, gpio.0 goes high (turning the lamp on) (gpio.0 = 1)
just after that, when gpio.1 goes high, gpio.0 goes low with PWM. (pwm gpio.0,duty,cycle)

at the first execution, it works fine. But if gpio.1 goes low again, gpio.0 DOESNT go high and when gpio.1 goes high, the PWM works...

the code is attached.

thanks, Sylvio

mister_e
- 21st February 2007, 17:29
I remember of few strange behaviour with this specific PWM. As far as i remind, it trick the TRIS setting and sometimes it set the i/o to input at the end.

Try to use LOW and HIGH after PWM instead of using Io=1 or Io=0

peterdeco1
- 21st February 2007, 17:30
Hi Sylvio. I had a similar problem with the 16F819. It turns out that before I could reuse that port as an output, I had to disable the PWM with
CCP1CON = 0 'TURN OFF PWM
Maybe this will help.

mister_e
- 21st February 2007, 17:33
:eek: i wasn't aware that a 12F629 had a CCP module ;)

sirvo
- 21st February 2007, 17:44
he.. peterdeco.. mister e is correct, pic12f629 has no CCP module..

thanks for the suggestion.

i'm using soft pwm ..

mister e, i have changed everything to HIGH and LOW and it worked really fine!

thanks a lot...!

Sylvio

mister_e
- 21st February 2007, 18:06
Bah don't blame Peterdeco, it's usual to everyone to mix PWM, HPWM and miss something in a post.

Glad to know it's working. At least my memory was good this time :D

Enjoy!

peterdeco1
- 21st February 2007, 18:17
Thanks Steve. I don't have these devices memorized. I saw PWM and it reminded me of my 16F819 problem a year or 2 ago.

mister_e
- 21st February 2007, 18:22
Bah, no problem Peterdeco1, even a superhero may fail... even me :D

You where right, with a CCP module your solution will work. The only thing i would add for safety sake is a LOW pin after.

But i'm an old guy using old method... LMAO!