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; }
Thank's a lot guys. You got the right answer. Now it's working Jorge Cases