xTimer V1.0
[05-23 02:47:29] 来源:http://www.88dzw.com 单片机电路图 阅读:8450次
文章摘要:Software Main program is simple forever loop with 10ms tick cycle. All tasks will run every tick in round robin manner. The tick was prepared in startup file, as shown below, it was declared as cputick and the modifier extern indicates this variable was declared in external file. extern unsigned reg
xTimer V1.0,标签:电路图讲解,电路图练习,http://www.88dzw.comSoftware
Main program is simple forever loop with 10ms tick cycle. All tasks will run every tick in round robin manner. The tick was prepared in startup file, as shown below, it was declared as cputick and the modifier extern indicates this variable was declared in external file.
extern unsigned register char cputick;
Here is the main program, we will see detail for each task below.
while(1) { while(!cputick) // run following tasks every 10ms ; cputick = 0; set_timer(); // check key pressed run_timer(); // run four timers key_release(); // check if key has been released updatedisplay(); // send data to MAX7219 ring1(); // optional buzzer alarm1 ring2(); // optional buzzer alarm2 } |
set_timer( ) function will check a given input bit. These input bit are P3.2, P3.3, P3.4 and P3.7. Checking is done by logical AND a specified bit with MASK byte, e.g. for P3.2 we will check bit 2 of P3 with MASK byte 0x04. The statement will be (P3&0x04), if the result is 0 then set flag1 bit 0 to one to indicates that key1 was pressed. Then check index1 greater or equal 9, if true, reset index1 to 0. Timer1 will reload with a preset_timer1[index1++].
The preset_timer1[] array is preset value for timer1. The sample is below.
char preset_timer1[] = {-1,0,3,5,10,15,20,25,30};
// reload preset time value from preset array for each key pressed set_timer() if((P3&0x10) == 0) } } |
- 上一篇:XC4003的最小系统电路
《xTimer V1.0》相关文章
- › xTimer V1.0
- 在百度中搜索相关文章:xTimer V1.0
- 在谷歌中搜索相关文章:xTimer V1.0
- 在soso中搜索相关文章:xTimer V1.0
- 在搜狗中搜索相关文章:xTimer V1.0