??? 08/11/09 06:08 Read: times Msg Score: +1 +1 Good Question |
#168303 - Serial Auto Baud Rate Detection |
Hi there,
I want to implement UART auto baud rate detection logic in C. I want to count the time taken to receive a bit using timers. The following is the code excerpt to count the bit time: unsigned int count_bit_time( bit digit) { /* Measure the duration for a bit. */ unsigned int count = 0; RXD = 1; /* configure as an input pin */ TH0 = 0; TL0 = 0; RXD = ~digit; P1_5 = 0; while (RXD != digit); P1_5 = 1; TR0 = 1; /* start timer0 */ P1_4 = 0; while (RXD == digit); TR0 = 0; P1_4 = 1; count |= TH0; count <<= 8; count |= TL0; return count; } Summary: P1_4 and P1_5 are connected to debug LEDs. I am turning ON the LEDs before entering the Loop and turning them OFF on leaving the loop. If digit is 0, the function should check the reception time for '0' on RXD and if digit is '1' the function calculates the reception time for '1'. The count is displayed on a 7-segment display This program is running infinitely! I'd appreciate any comments or suggestions. Thanks in advance, Sarma |
Topic | Author | Date |
Serial Auto Baud Rate Detection | 01/01/70 00:00 | |
what is the purpose of this line | 01/01/70 00:00 | |
Function Calls | 01/01/70 00:00 | |
Waiting for destruction | 01/01/70 00:00 | |
Re:Waiting for destruction - Suicidal Move! | 01/01/70 00:00 | |
Autobauding | 01/01/70 00:00 | |
Why must it be in 'C'?![]() | 01/01/70 00:00 |