<div class="blockcode"><blockquote>#include "ML51.h" #include "BC26.h" unsigned char uart_receive_data,bufhead; bit receiveFlag,bufOverFlag; unsigned char temp; void Uart0_Init(void); void Uart0_SendChar(unsigned char Udat); void Uart0_SendString(unsigned char *PBuf); typedef struct _UART_BUF //定义数组 { char buf [BUFLEN+1]; unsigned int index ; }UART_BUF; void Clear_Buffer(void) //清空数组 { Delay_ms(30); buf_uart2.index=0; memset(buf_uart2.buf,0,BUFLEN); } void nbiot_receive_process_event(unsigned char ch ) //将SBUF保存进数组 { if(buf_uart2.index >= BUFLEN) { buf_uart2.index = 0 ; } else{ buf_uart2.buf[buf_uart2.index] = ch; buf_uart2.index++; } } void BC26_Init(void) //打印数组 { Uart0_SendString(buf_uart2.buf); } void USART2_IRQHandler() interrupt 4 //串口接收中断 { if (RI) { RI=0; temp=SBUF; nbiot_receive_process_event(temp); BC26_Init(); } if (TI) { TI=0; } } void Uart0_SendChar(unsigned char Udat) { SBUF=Udat; while(!TI); TI=0; } void Uart0_SendString(unsigned char *PBuf) //打印字符串 { while(*PBuf!='\0') { Uart0_SendChar(*PBuf); PBuf++; } } void main (void) { MFP_P46_GPIO; P46_PUSHPULL_MODE; MFP_P31_UART0_TXD; MFP_P30_UART0_RXD; P31_QUASI_MODE; P30_QUASI_MODE; UART_Open(24000000,UART0_Timer1,115200); UART_Interrupt_Enable(UART0,Enable); ENABLE_GLOBAL_INTERRUPT; while(1) { Delay_ms(10000); Clear_Buffer(); } } 我用N76E003做串口通信,将16M改成16.6M才使得串口波特率误差小,现在要把N76E003移植到ML51,结果发现ML51产生的波特率误差较大,有没有人会改ML51时钟
收藏0 举报
ML51uart0BC26.zip
2020-7-30 09:27 上传
点击文件名下载附件
411.12 KB, 下载次数: 3
jasontu 发表于 2020-7-30 10:44 參考76E003改时钟的例程,把CLOCK OUT打出來。 修改-15的數值,觀察頻率輸出,就可以抓到規則。 ...
本版积分规则 发表回复 回帖并转播 回帖后跳转到最后一页
人才类勋章
6
36
0
扫码关注 21ic 官方微信
扫码关注嵌入式微处理器
扫码关注电源系统设计
扫码关注21ic项目外包
扫码浏览21ic手机版
本站介绍 | 申请友情链接 | 欢迎投稿 | 隐私声明 | 广告业务 | 网站地图 | 联系我们 | 诚聘英才
京公网安备 11010802024343号