??? 07/25/06 17:12 Read: times |
#121034 - other details about code Responding to: ???'s previous message |
Oleg Sergeev said:
hi,
Please show timer 2 initialization code. Please show interrupts setup (enabling,priority) code as well. How this interrupt is long in time:/*timer 1 interrupt used for four 7-segment displays multiplexing*/Have you calculated its time duration? <pre> //timer 2 initialization code T2MOD &=0xFC; T2MOD |=0x00; EXF2=0; TCLK=0;RCLK=0; EXEN2=0; TH2=MSBreload_value; TL2=LSBreload_value; RCAP2H=MSBreload_value; RCAP2L=LSBreload_value; C_T2=0; CP_RL2=0; EA=1; ET2=1; TR2=1; [/pre] I havent included any priority code,interrupts follow thier default priority.how to include it?it may help. How this interrupt is long in time:/*timer 1 interrupt used for four 7-segment displays multiplexing*/ TH1=0xF6; //initialize timer 1 for 2.5 ms delay TL1=0x3B; As multiplexing of four 7-segment displays had to be done thus,consecutive display is lit up every 2.5 ms.So each display is lit up after every 10 ms. By the way,there is possible logic error:/* timer 2 interrupt used to increment count every 1 msec*/ void inter_2(void) interrupt 5 {if(P0_0==1) count1++; TF2=0; if((count1%10)==0) g=3;Look atcount1++; if((count1%10)==0) Assume the variable count1 is uchar (8 bit). What does happen during it rolls over 255? You think that you do set variable g to value 3 at each 10 interrupts of timer 2 (when (P0_0==1)) but in fact it happens at values of count1 equal to: 0,10,20...240,250 and then? Yes, at value 0 (after only 6 interrupts! because there are no uchar values 256..259). Regards, Oleg int count1=0;//a global variable In main's infinite while loop,there is following provision: if(count1>9999) //dis is don in ordr to prevent count1 to go outsid range of integers count1=10000; And the time to be displayed is maximum 9.999sec,so there's no need of taking count1 greater than 9999. |
Topic | Author | Date |
problem in timer with a least count of 1 millisec | 01/01/70 00:00 | |
Code as shown should work methinks | 01/01/70 00:00 | |
clarifications | 01/01/70 00:00 | |
atomicity | 01/01/70 00:00 | |
atomicity problem? | 01/01/70 00:00 | |
about atomicity | 01/01/70 00:00 | |
Back to basic | 01/01/70 00:00 | |
reply to vishal sinha | 01/01/70 00:00 | |
bible time | 01/01/70 00:00 | |
Hm ... | 01/01/70 00:00 | |
reply to Christoph Franck | 01/01/70 00:00 | |
totally imprecse | 01/01/70 00:00 | |
What is the size of the variables? | 01/01/70 00:00 | |
not enough info | 01/01/70 00:00 | |
other details about code | 01/01/70 00:00 | |
here you go again | 01/01/70 00:00 | |
yet questions more![]() | 01/01/70 00:00 |