I use PIC16F628A for driving 3 outputs in PWM and i meet some problems with my C code.
I want to control 3 differents PWM, for the moment i've just connect 2 switchs (up and down) for control PWM hard only.
I don't understand, because when i push up switch i've just 3 differents duty cycles (same when i push down) but only 2 when i up again, and i locked at the 3rd cycle.
My wish was to obtain 10% for each push in "up switch" and same for "down switch" progress.
I've fixed F=500Hz and that is good.
I joined my program (Hitech C).
I hope some assistance, thanks by advance.
People maybe able to help. Unfortunately, your files are unreadable. Try loading them into a text editor and saving them so that the end of line characters are inserted. Or, cut and paste them into a CODE tag.
/****************************************************************
Timmings in ms
****************************************************************/
void DelayMs(uchar cpt)
{
ushort t ;
while (cpt != 0)
{
CLRWDT() ;
-- cpt ;
t = 112 ;
while (t !=0) -- t ;
}
}
// S1 est mis à jour par ValeurPwmS1 --> Timer1
// S2 est mis à jour par ValeurPwmS2 --> Timer1
// S3 est mis à jour par ValeurPwmS3 --> PWM
setDC_PWM((ValeurPwmS3 * 4)-1) ; // on se ramène à l'échelle [0-1023]
while (TestBPs() != AUCUNE) CLRWDT() ; // attent le relâchement
Compteur62us = 0 ;
}
/****************************************************************
main program
****************************************************************/
main()
{
CLRWDT() ;
Maybe but majority is rarely the reference for me.
C is more portable and more readable.
In assembler, if you change µC you learn assembler again, in C not.
Maybe but majority is rarely the reference for me.
C is more portable and more readable.
In assembler, if you change µC you learn assembler again, in C not.
Depends on your programming skills?, and the number of proven routines you have available - and also on your definition of 'efficient' - a competent C programmer, with a good working knowledge of assembler on the target device, could certainly write large programmes far faster than in pure assembly.
In my program, i suspect variables init or wrong calculation, i would like your opinion.
I don't think a mistake for pwm use, i have read more and more your tutorial and Microchip specs, but without result...