Guys,
I'm trying to count a pulse from T0 input on P3.4,
Here's the code : sbit counter_input=P3^4; //input pulse from op-amp void init_timer() { TL0=0x00; //TH0=0x00; counter_input = 1; //set it as input to read a pulse from op-amp counter_input = 0x00; //clear the counter TMOD=0x05; P0=0x00; } main : . . . unsigned int counter=0,d1,d2,d3,dx,dy,dz,x; lcd_ini(); //init LCD init_timer();//init timer0 TR0=1; while (1) { counter=TL0; P0=TL0; x=counter/10; d1=counter%10; d2=x%10; d3=x/10; dx=d1+48; dy=d2+48; dz=d3+48; lcd_data(dx); lcd_data(dy); lcd_data(dz); }
I got the output already, but it's not consistent yet, 781, 881,321, 050...etc, I tested with putting input to the sensor it's responding on the display according to the input, but...it's not yet displaying for example 000, 030, 050,090, etc...
Any ideas on this case ? I'm abit confuse on using timer and counter ....
Thanks for the ideas
I have no idea yet on how to debug it ? How can I see my counter doing what I want ?
I did already on the board and op amp has given me a pulse, but I'm not sure if I'm doing the right code for it... That's why I asked to this forum.