#include "main.h"
#include "config.h"
#include "compiler_defs.h"
#include "C8051F380_defs.h"
// Peripheral specific initialization functions,
// Called from the Init_Device() function
void Timer_Init()
{
TCON = 0x40;
TMOD = 0x20;
CKCON = 0x08;
TH1 = 0x64;
}
void UART_Init()
{
SCON0 = 0x10;
}
void Port_IO_Init()
{
// P0.0 - SCK (SPI0), Open-Drain, Digital
// P0.1 - MISO (SPI0), Open-Drain, Digital
// P0.2 - MOSI (SPI0), Open-Drain, Digital
// P0.3 - NSS (SPI0), Open-Drain, Digital
// P0.4 - TX0 (UART0), Open-Drain, Digital
// P0.5 - RX0 (UART0), Open-Drain, Digital
// P0.6 - SDA (SMBus0), Open-Drain, Digital
// P0.7 - SCL (SMBus0), Open-Drain, Digital
// P1.0 - TX1 (UART1), Open-Drain, Digital
// P1.1 - RX1 (UART1), Open-Drain, Digital
// P1.2 - Unassigned, Open-Drain, Digital
// P1.3 - Unassigned, Open-Drain, Digital
// P1.4 - Unassigned, Open-Drain, Digital
// P1.5 - Unassigned, Open-Drain, Digital
// P1.6 - Unassigned, Open-Drain, Digital
// P1.7 - Unassigned, Push-Pull, Digital
// P2.0 - Unassigned, Push-Pull, Digital
// P2.1 - Unassigned, Push-Pull, Digital
// P2.2 - Unassigned, Push-Pull, Digital
// P2.3 - Unassigned, Open-Drain, Digital
// P2.4 - Unassigned, Open-Drain, Digital
// P2.5 - Unassigned, Open-Drain, Digital
// P2.6 - Unassigned, Open-Drain, Digital
// P2.7 - Unassigned, Open-Drain, Digital
// P3.0 - Unassigned, Open-Drain, Digital
// P3.1 - Unassigned, Open-Drain, Digital
// P3.2 - Unassigned, Open-Drain, Digital
// P3.3 - Unassigned, Open-Drain, Digital
// P3.4 - Unassigned, Open-Drain, Digital
// P3.5 - Unassigned, Open-Drain, Digital
// P3.6 - Unassigned, Open-Drain, Digital
// P3.7 - Unassigned, Open-Drain, Digital
P0MDOUT = 0xFF;
P1MDOUT = 0x83;
P2MDOUT = 0x07;
XBR0 = 0x07;
XBR1 = 0x40;
XBR2 = 0x01;
}
void Oscillator_Init()
{
OSCLCN |= 0x83;
CLKSEL = 0x08;
OSCICN = 0xC3;
}
void Interrupts_Init()
{
IP = 0x10;
EIE1 = 0x01;
EIE2 = 0x02;
IE = 0x18;
}
// Initialization function for device,
// Call Init_Device() from your main program
void Init_Device(void)
{
Timer_Init();
UART_Init();
// SMBus_Init();
// SPI_Init();
Port_IO_Init();
Oscillator_Init();
// Interrupts_Init();
}
这是我的配置程序,
//UART0·¢ËÍÒ»¸ö×Ö·û
void RS232SendChar(unsigned char byte)
{
REN0 = 0;
SBUF0 = byte;
while(TI0 == 0); //·¢ËÍÖжϱêÖ¾
TI0 = 0;
REN0 = 1;
}
这是串口发送程序,程序运行到while(TI0 == 0); 就TI0一直不置一,求高手看一下是不是配置出了问题? |