Hi, Here is my little problem: I use a Phillips 87lpc767 controler to generate a code on his TXD pin at 1200 bauds. my cystal frequency is 8MHz; My problem: TXD gives 40.000 bits/s !
//Timer configuration: PCON |= 0x80; //(SMOD1 = 1) TMOD = 0x20; // Timer #1 in autoreload 8 bit mode TH1 = 0xDD; // calculated on keil site with Fcpu = 8.00 MHz (XTAL) and SMOD1 checked TL1=TH1; TR1 = 1; // Turn on Timer 1 //To test the speed: void timer1_ISR (void) interrupt 3 { TXD ^= 0x01; } //in main, for timer1 interrupt: ET1 = 1; EA = 1;
Hi Arnaud, In my programs I calculate the Timer reload value in the following way:- #define TR -((1L << SMOD) * XTAL)/(32L * 12 * BAUD_RATE)) which gives 0xDD ie the value that you have already calculated, so would you not be better off testing the baud rate by outputting the data to SBUF and monitoring it? So remove ET=1; and EA=1; and the timer1_ISR and instead do somthing like the following:- /* REMOVED AS NOT NEEDED */ //ET1 =1; //EA = 1; do { TI = 0; /* clear transmit 'interrupt' */ SBUF = 'A'; /* test serial data */ do { } while (!TI); /* wait for data to finish txmitting */ } while (1); /* loop forever */ Hope this helps, Mark.
Thanks a lot, Mark, for your help. Everything works fine, now :)