For 110569
This commit is contained in:
parent
6ca5f28555
commit
28a6ccc3ee
30
uart_init.c
30
uart_init.c
@ -5,6 +5,14 @@
|
||||
|
||||
void uart_init(long fosc, long baud)
|
||||
{
|
||||
TMOD = 0x20; // Timer 1 in Mode 2
|
||||
TH1 = 0xFD; // 9600 baud rate
|
||||
TL1 = 0xFD; // Initial value (not necessary)
|
||||
TR1 = 1; // Start Timer 1
|
||||
SCON = 0x50; // 8-bit data, 1 stop bit, REN enabled
|
||||
return;
|
||||
|
||||
|
||||
TMOD = 0; /* Timer 1, 8-bit auto reload mode */
|
||||
// P_SW1 |= (1 << 6); // move UART1 pins -> P3_6:rxd, P3_7:txd
|
||||
|
||||
@ -14,14 +22,26 @@ void uart_init(long fosc, long baud)
|
||||
|
||||
SM0 = 0;
|
||||
SM1 = 1; // serial mode 1: 8-bit async
|
||||
AUXR |= 0x14; // T2R: run T2, T2x12: T2 clk src sysclk/1
|
||||
AUXR |= 0x01; // S1ST2: T2 is baudrate generator
|
||||
SCON = 0x50;
|
||||
// AUXR |= 0x14; // T2R: run T2, T2x12: T2 clk src sysclk/1
|
||||
// AUXR |= 0x01; // S1ST2: T2 is baudrate generator
|
||||
SCON = 0x50;
|
||||
|
||||
/* ES = 1; // enable uart1 interrupt
|
||||
TMOD |= T1_M1;
|
||||
TI=1;
|
||||
TCLK=0;
|
||||
RCLK=0;
|
||||
// TBCK=0;
|
||||
// RBCK=0;
|
||||
//
|
||||
TH1=0xFD;
|
||||
|
||||
|
||||
//SMOD0=0;
|
||||
|
||||
ES = 1; // enable uart1 interrupt
|
||||
EA = 1; // enable interrupts
|
||||
REN = 1;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user