cancel
Showing results for 
Search instead for 
Did you mean: 

Probleme with UART1 TIMER1

jrichard9
Associate II
Posted on January 24, 2006 at 14:21

Probleme with UART1 TIMER1

1 REPLY 1
jrichard9
Associate II
Posted on May 17, 2011 at 12:10

hi,

i used upsd3333dv

timer0 -->1ms

the uart1 at 9600bps using timer1 / 40MHz clk.

when i activited Timer1 (ET1=1) timer0 is stop

THANKS FOR YOUR HELP

////////////////////////////////////////////////////////////////////

void psd_Timer1 (UWORD baudrate)

{

unsigned char baud_ratio;

UWORD timer_reg_value;

bit ea_value;

ea_value = EA; // save EA state

EA = 0; // Disable Interrupts

SCON1&=0xFD;

t_in1 = 0; // empty transmit buffer

t_out1 = 0;

t_disabled1 = 1; // disable transmitter

PCON |= 0x40; // baudrate X2 pour uart1

if ( (PCON & 0xC0) ) baud_ratio = 0x02 ;

else

baud_ratio = 0x01;

//------------------------------------------------

//Set timer 1 up as a baud rate generator.

//------------------------------------------------

TR1 = 0; // stop timer 1

ET1 = 0; // disable timer 1 interrupt

//IE|=0xF7; //desable timer1 interrupt

//T2CON &= 0xCF;

//T2CON |= 0x30;

PCON &= 0xf3; // use timer 1 for baudrate UART

TH1 = (unsigned char) (256 - (OSC * baud_ratio/ (32L * 12L * baudrate)));

//IE|=0x08; //enable timer1 interrupt

ET1 = 1; //enable timer 1 interrupt

TR1 = 1; // met en marche le timer 1

EA = ea_value; // return EA value

}

void psd_UART1_Init(void)

{

//UART1

SCON1&=0xFC; // clear TI and RI interrupt flag

SCON1 |= 0x70; // mode 1

IEA|=0x10; // enable UART1

}

void init_psd(void)

{

PSD_reg.DIRECTION_A = 0x30; // set port pins PA4(RST_2) and PA5(RST_1) to output

PSD_reg.DATAOUT_A = 0x30; // pas de reset VPC3: PA4(RST_2) and PA5(RST_1)

PSD_reg.DIRECTION_B = 0x30; // set port pins PB4(LED_1) and PB5(LED_2) to output

PSD_reg.DATAOUT_B = 0x30; // turn off LEDs: PB4(LED_1) and PB5(LED_2)

P3SFS = 0x03; // enable alternate port function Tx, Rx UART0

P4SFS0 = 0x0C; // enable alternate port function Tx, Rx UART1

P4SFS1 = 0x0C; // enable alternate port function Tx, Rx UART1

}

void TimerInstall(void) // init du timer 0. 1 IT ttes les 1ms

{

TR0 = 0;

TMOD = (TMOD & 0xf0) | 0x01; // 16-bit timer mode

TH0 = TH0_RELOAD;

TL0 = TL0_RELOAD;

ET0 = 1; // enable timer 0 interrupt

TR0 = 1; // run timer 0

}