I was just wandering if somebody could helpme with these trouble. I´m trying to set:
PWM1_Init
PWM1_Set_Duty
PWM1_Start
PWM1_Stop
but none of these seem to function.
Code: Select all
WM_puente_H
' Declarations section
dim current_duty, current_duty1, old_duty, old_duty1 as byte
sub procedure InitMain()
cmcon1=7
ANSEL = 0 ' Configure AN pins as digital I/O
TRISIO = %00101000 ' configure PORTA pins as input
PWM1_Init(5000) ' Initialize PWM1 module at 5KHz
PWM2_Init(5000) ' Initialize PWM2 module at 5KHz
end sub
main:
InitMain()
current_duty = 16 ' initial value for current_duty
current_duty1 = 16 ' initial value for current_duty1
PWM1_Start() ' start PWM1
PWM2_Start() ' start PWM2
PWM1_Set_Duty(current_duty) ' Set current duty for PWM1
PWM2_Set_Duty(current_duty1) ' Set current duty for PWM2
while (TRUE) ' endless loop
if (RA0_bit <> 0) then ' button on RA0 pressed
Delay_ms(40)
Inc(current_duty) ' increment current_duty
PWM1_Set_Duty(current_duty)
end if
if (RA1_bit <> 0) then ' button on RA1 pressed
Delay_ms(40)
Dec(current_duty) ' decrement current_duty
PWM1_Set_Duty(current_duty)
end if
if (RA2_bit <> 0) then ' button on RA2 pressed
Delay_ms(40)
Inc(current_duty1) ' increment current_duty1
PWM2_Set_Duty(current_duty1)
end if
if (RA3_bit <> 0) then ' button on RA3 pressed
Delay_ms(40)
Dec(current_duty1) ' decrement current_duty1
PWM2_Set_Duty(current_duty1)
end if
Delay_ms(5) ' slow down change pace a little
wend
end.
Well hope you can helpme
Have a good day
PD: also my CONFIG word is set: :$2007 : 0x0355