Pushpkant
Member level 1
![Member level 1](/styles/images/ranks/dlevel1.gif)
Hello,
I am using timer 0 and timer 1 for pwm waveform generation. Until the pwm is running all is well and good. But when I stop the pwm, the ports associated with pwm are land on some random position either low or high. I have given the code to low the ports but still the ports are at random position each time I stop the pwm.
I have tried to give delay ranging from 1 ms to 1000 ms. Used different types of techniques for lowering the ports. But at each time the code executes the ports are at random positions. The ports are PD5, PD6, PB1 and PB2.
Thanks in advance for your help.
I am using timer 0 and timer 1 for pwm waveform generation. Until the pwm is running all is well and good. But when I stop the pwm, the ports associated with pwm are land on some random position either low or high. I have given the code to low the ports but still the ports are at random position each time I stop the pwm.
Code C++ - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 prints("Down called:");phline(); pwm_0.stop(); pwm_1.stop(); _delay_ms(1); prints("Pwm stopped:");phline(); prints("Before reset");phline(); prints("PORTD ="); USARTWriteNumBinary(PIND); phline(); prints("PORTB ="); USARTWriteNumBinary(PINB); phline(); //_delay_ms(1000); CLR_BIT(PORTD,PD5); CLR_BIT(PORTD,PD6); CLR_BIT(PORTB,PB1); CLR_BIT(PORTB,PB2); /*PORTD &= 0x9F; PORTB &= 0xF9;*/ prints("The ports has been reset:");phline(); prints("PORTD ="); USARTWriteNumBinary(PIND); phline(); prints("PORTB ="); USARTWriteNumBinary(PINB); phline();
I have tried to give delay ranging from 1 ms to 1000 ms. Used different types of techniques for lowering the ports. But at each time the code executes the ports are at random positions. The ports are PD5, PD6, PB1 and PB2.
Thanks in advance for your help.