cancel
Showing results for 
Search instead for 
Did you mean: 

Different baudrate

jones2
Associate II
Posted on May 10, 2004 at 09:13

Different baudrate

4 REPLIES 4
jones2
Associate II
Posted on May 17, 2011 at 12:00

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.

jdaniel
Associate II
Posted on May 17, 2011 at 12:00

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,

Phaze426
jones2
Associate II
Posted on May 17, 2011 at 12:00

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?
jones2
Associate II
Posted on May 17, 2011 at 12:00

I found the problem!

the correct formula for timer 1 is:

TH1 = (256L - ( (FREQ_OSC * 32L) / (12L * 9600L)));

thanks.