??? 01/13/06 18:40 Read: times |
#107333 - Split mode 3 timer c SDCC program Responding to: ???'s previous message |
Hello Kevin
Here is a skeleton c program which uses timer 0 in split mode and timer 1 as a baud rate generator. Regards, Charles Bannister // Skeleton c program using split Timer zero (mode 3) // Compile SDCC Mode3Timer.c // Packihx Mode3Timer.ihx > Mode3Timer.hex #include<8052.h> unsigned char cMeasureDone; unsigned char cTimer1, cTimer2; unsigned char cCounter1, cCounter2; void measure_start( void ); char measure_poll( void ); void main (void){ PCON |= SMOD; SCON = 0x52; TMOD = 0x27; TH1 = 0xF3; TL1 = -1; for(;;){ RI=0; measure_start(); while( measure_poll() == 0 ); // YOUR CODE GOES HERE } } char measure_poll( void ) { return cMeasureDone; } void int_tl0 (void) interrupt 1 { if( ++cCounter1 == 0 ) cCounter2++; } void int_th0 (void) interrupt 3 { if( --cTimer1 == 0 ){ if( --cTimer2 == 0 ) cMeasureDone = 1;} } void measure_start( void ) { TR0 = 0; TF0 = 0; TL0 = 0; cCounter1 = 0; cCounter2 = 0; cTimer1 = 0; cTimer2 = 30; TR1 = 1; IT0 = 1; IE0 = 0; ET0 = 1; ET1 = 1; EA = 1; cMeasureDone = 0; TH0 = 0; TR0 = 1; } :040000000200CD32FB :03000B000200549C :0100130032BA :03001B000200766A :0100230032AA :01002B0032A2 :1000CD0075810C1200C9E582600302002C7900E9EC :1000DD004400601B7A00900115780075A000E49330 :1000ED00F2A308B8000205A0D9F4DAF275A0FF78E2 :1000FD0000E84400600C7900900000E4F0A3D8FC07 :08010D00D9FAF6D8FD02002C1E :10002C0012003180FE438780759852758927758D33 :10003C00F3758BFFC2981200A1120050AA82BA006D :10004C00F380F62285088222C0E0C0F0C082C08313 :10005C00C0D075D000050BE50B60028002050CD0FA :10006C00D0D083D082D0F0D0E032C0E0C0F0C082DB :10007C00C083C0D075D0001509E5096002800B154E :10008C000AE50A60028003750801D0D0D083D082C3 :10009C00D0F0D0E032C28CC28D758A00750B007521 :1000AC000C00750900750A1ED28ED288C289D2A99D :1000BC00D2ABD2AF750800758C00D28C2275820041 :0100CC002211 :00000001FF |
Topic | Author | Date |
two timers and uart | 01/01/70 00:00 | |
Where to find it | 01/01/70 00:00 | |
thanks | 01/01/70 00:00 | |
bible | 01/01/70 00:00 | |
step 1, step 2, step 3 | 01/01/70 00:00 | |
Count? | 01/01/70 00:00 | |
Yes | 01/01/70 00:00 | |
Split mode 3 timer c SDCC program | 01/01/70 00:00 | |
continuation | 01/01/70 00:00 | |
use 8052 instead | 01/01/70 00:00 | |
clarification | 01/01/70 00:00 | |
OK | 01/01/70 00:00 | |
any that has your chip in the devicelist | 01/01/70 00:00 | |
too slow | 01/01/70 00:00 | |
11059200 to big ! | 01/01/70 00:00 | |
Tutorial shows | 01/01/70 00:00 | |
Macros![]() | 01/01/70 00:00 |