We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm trying trying to program a square signal frequency to simulate the signal obtained in the sensor of the rpm of an engine (in the flywheel). This frequency is generated in a timer interruption. If I don't take into consideration the two missing teeth (forget about the bold lines in the source code) of the flywheel (60 teeth - 2teeth) the code is working, but when I try to get rid of the two first teeth my software is doing nothing. What could be wrong? Thanks a lot. #pragma RB(1) timer0() interrupt 1 using 1 { //takes into account the two missing teeth of the flywheel TR0=0; //stop the timer EAL=0; //disable all interrupts counter=counter++; // if (counter!=121) //60 teeth + 60 holes { if (counter>6) { // frequen_1=~frequen_1; //invert the signal } } else { TR0=0; // two extra microseconds TR0=0; counter=1; frequen_1=~frequen_1; } //in case on the two first teeth I don't invert my signal TL0 = new_timer_reload; //load the new values TH0 = new_timer_reload_high; TR0=1; //start the timer EAL=1; }
"counter=counter++;" Under Keil C51 5.50 this statement don't work but under Keil C51 V7.0 seems it works OK.
counter++; is a better 'C' notation then counter=counter++; It looks unnatural.