Inital commit
This commit is contained in:
parent
5c00e1633a
commit
726a76eeff
29
uart_init.c
Normal file
29
uart_init.c
Normal file
@ -0,0 +1,29 @@
|
||||
#include "mc8051fun.h"
|
||||
|
||||
//#include <stc12.h>
|
||||
#include <at89c51ed2.h>
|
||||
|
||||
void uart_init(long fosc, long baud)
|
||||
{
|
||||
TMOD = 0; /* Timer 1, 8-bit auto reload mode */
|
||||
// P_SW1 |= (1 << 6); // move UART1 pins -> P3_6:rxd, P3_7:txd
|
||||
|
||||
// UART1 use Timer2
|
||||
// T2L = (65536 - (fosc / 4 / baud)) & 0xFF;
|
||||
// T2H = (65536 - (fosc / 4 / baud)) >> 8;
|
||||
|
||||
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;
|
||||
|
||||
/* ES = 1; // enable uart1 interrupt
|
||||
EA = 1; // enable interrupts
|
||||
REN = 1;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user