📄 initial.#2
字号:
#include "c8051F330.h"
#include "rs232.h"
void Port_IO_Init(void)
{
P0MDIN = 0xFE;
P1MDIN = 0xF0;
P0MDOUT = 0xBD;
P1MDOUT = 0xFF;
P0SKIP = 0xC9;
P1SKIP = 0xFF;
XBR1 = 0x40;
XBR0 = 0x05;
}
void Oscillator_Init(void)
{
OSCICN = 0xC3; //SYSCLK derived from Internal H-F Oscillator divided by 1.
}
void UART_Init(void)
{
SCON0 = 0x50; //Enable reception @ 8bits UART
ES0 = 1; //Enable UART interrupt
TMOD |= 0x20; //*Baud rate is 9600bps*******
TH1 = 0x96; //****************************
TR1 = 1; //Enable timer1
}
void I2C_Init(void)
{
TMOD |= 0x02;
CKCON |= 0x04; //400k/s
TH0 = 0xEC;
EIE1 = 0x01; //Enable SMBus interrupt
SMB0CF |= 0xD0; //Enable SMBus and disable slave mode
SMB0CN |= 0x80; //SMBus work at master mode
TR0 = 1; //Enable timer1
}
void Timer3_Init(void)
{
TMR3RLL = 0x9F; //Timer3 will overflow at 25ms
TMR3RLH = 0x38;
EIE1 |= 0x80; //Enable timer3 interrupt
TR2 = 1; // Start Timer3
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -