randy.shaffer
Joined: 21 Mar 2018 Posts: 51
|
PWM shuts off unexpectedly for 16LF1503 |
Posted: Fri Oct 11, 2024 12:21 pm |
|
|
Code: | #include <16LF1503.h> // device file
#fuses NOWDT, NOBROWNOUT
#use delay(internal = 16MHZ)
#use PWM(PWM1, FREQUENCY = 15.625kHz, OUTPUT = PIN_C5, PWM_OFF, STREAM = IN1)
#byte PORTC = 0x00E
#bit IN2 = PORTC.3
void main()
{
set_tris_c(0b00000100); // X: C7,C6. Inputs: C2. Outputs: C5,C4,C3,C1,C0.
IN2 = FALSE;
delay_ms(100); // supply voltage settling time
pwm_set_duty_percent(IN1, 1000);
pwm_on(IN1);
delay_ms(1000); // 100% duty for 1 second
pwm_set_duty_percent(IN1, 500); // after 1 second, reduce duty to 50%
pwm_on(IN1);
while(TRUE);
} |
Compiler is v5.118. Program outputs 100% duty initially. After one second, I wanted to drop the duty ratio to 50%, but it drops to zero instead. Thanks for having a look. |
|