2004-05-10 12:13 AM
2011-05-17 03:00 AM
I initilize Uart1 and Uart2 to use timer2 and timer1 respectivly as baudrate generators.
Timer2 works ok, how ever uart2 does not work ok with timer1. (Uart2 is used with interrupts and Uart1 by polling) Initializations: T2CON =0x34; // Set UART1 to use timer2 PCON &= ~0x0C; // Set UART2 to use timer1 TMOD |= 0x20; // 8-bit auto-reload Timer. TMOD &= 0xC0 ; // set timer 1 as timer (not counter) WDKEY = 0x55; // Disable Watchdog SCON = 0x50; // enable first serial UART & receiver SCON2 = 0x50; // enable 2nd uart TH1 = (256L - ( (FREQ_OSC) / (12L * 32L * 9600L))); timer_baud = (65536L - ( (FREQ_OSC * 125L) / (4L * 19200L))); RCAP2L = (timer_baud & 0x00FF); RCAP2H = (timer_baud >> ; I hope you can help me. Thanks.2011-05-17 03:00 AM
steadicopter,
I don't see anything in your code that actually starts timer1. You might want to try adding: TR1 = 1; Or if you want to stick with the whole mask motif: TCON |= 0x40; Let me know if that helps. Best Regards, Phaze4262011-05-17 03:00 AM
I forgot to write it in my message, but I have started the timer.
So TCON |= 0x40; does not help. do you have another idea? is my calculation of the timer1 baudrate correct?2011-05-17 03:00 AM
I found the problem!
the correct formula for timer 1 is: TH1 = (256L - ( (FREQ_OSC * 32L) / (12L * 9600L))); thanks.