本人在项目中用到了BS86D20的串口通讯,现在发出例程给各大网友参考下
void uart_init() //串口初始化
{
_ucr1 = 0x80; /* 1000 0000 */
_ucr2 = 0xc4; /* 1100 0000 */
//_hircs1=0;_hircs0=1;//HIRC 时钟频率选择位 12MHZ选这个
//_hircs1=0;_hircs0=0;//HIRC 时钟频率选择位 8MHZ选这个
_hircs1 = 1; _hircs0 = 0; /* HIRC 时钟频率选择位 16MHZ选这个 */
_brg = 25; /* 9600波特率 */
_uarte = 1; /* 使能UART中断 */
_emi = 1; /* 使能全局中断 */
}
void Send_Uart( unsigned char dat ) //发一个字节的数据
{
while ( _txif == 0 )
{
_clrwdt();
}
_txr_rxr = dat;
}
void Send_String(unsigned char *s)//发送字符串
{
while(*s != '\0')
{
Send_Uart(*s);
s++;
}
}
}
void __attribute( (interrupt( 0x2C ) ) ) Interrupt_Uart( void ) /* 串口接收中断 */
{
if ( RxCount > 25 )
{
RxCount = 0;
}
UartRxBuf[RxCount] = _txr_rxr;
RxCount++;
while ( _txif == 0 )
{
_clrwdt();
}
_uartf = 0;
}
合泰BS86D20 串口通讯源码 - 啊和的博客
中微单片机串口通信程序
合泰BS86D12C PWM初始化函数
HT单片机HT66F017普通咖啡机程序
AD滤波程序
彩屏仿数码管字体
单片机PID算法例子