完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我建立了一个新的项目,配置振荡器、引脚等,并设置UART2为9600波特,所有使用MCC。初级OSC是一个8MHz晶体。fCy=4MHz。两者都在范围上进行了验证。每隔1/2秒发送一个“u”,包括“McCyGealEngDyFrase/MCC.H”,定义timeOUT 500 000 UINT 16t计数;UINT8YT数据;/*主应用程序*/int main(空隙){//初始化设备StReSimulalIZE();计数=0;数据=“u”;(1){Le11Sethh();UART2X写(数据);(计数+++T;TimeOUT);计数=0;Re11StLoWo();而(C+++lt;TimeIOUT);计数=0;}在作用域上查看U2TX。字符位模式是正确的,但位宽度是26 US -4X太快。查看UART2.C并找到MCC集BRG到0x19,但也设置BRGH到1使用MCC下拉来清除BRGH,保持9600波特并重复:它现在给了我416位宽度-4X太慢。如果我手动编辑U2MODE(BRG= 0x19,BRGH 0)I可以得到正确的104US比特周期,但是如果在MCC改变之后重新生成它,它又将它设置为416个-讨厌。看起来MCC不与BRG的设置协调BRG计算。这是MCC和PIC24F16KA102版本的已知问题吗?MCC V3.55.1MPLABX V4.15XC16 V1.33 PIC24F16KA102目标
以上来自于百度翻译 以下为原文 I set up a new project, configured the oscillator, pins, etc. and set up UART2 for 9600 baud, all using MCC. The Primary Osc is an 8MHz crystal. Fcy = 4MHz. Both verified on scope. (RB8 on, off, on, off in successive instructions). Send 'U' about every 1/2 second: #include "mcc_generated_files/mcc.h" #define TIME_OUT 50000 uint16_t count; uint8_t data; /* Main application */ int main(void) { // initialize the device SYSTEM_Initialize(); count = 0; data = 'U'; while (1) { LED1_SetHigh(); UART2_Write(data); while (count++ < TIME_OUT); count = 0; LED1_SetLow(); while (count++ < TIME_OUT); count = 0; } Look at U2TX on scope. Character bit pattern is correct but bit width is 26 us - 4x too fast. Look in uart2.c and find MCC sets BRG to 0x19 but also sets BRGH to 1 Using MCC drop-down to clear BRGH, keep 9600 baud and repeat: it now gives me a 416 us bit width - 4x too slow. If I edit U2MODE manually (BRG = 0x19, BRGH 0) I can get the correct 104us bit period, but if I re-generate after an MCC change it sets it back to 416 us again - annoying. Looks like MCC does not co-ordinate BRG calculation with its setting of BRG. Is this a known problem with this version of MCC and the PIC24F16KA102? MCC v3.55.1 MPLABX v4.15 XC16 v1.33 PIC24F16KA102 target |
|
相关推荐
1个回答
|
|
|
我从我的项目中删除了uART2,然后再次包含它。我使用MCC UART2轻松设置标签设置9600波特,等等,然后寄存器标签显式设置BRGH到1。然后我生成MCC代码。这次我得到正确的波特率。U2BRG被设置为0x00 67和BRGH到1(在UART2.C代码中)。这与FCY=4兆赫的REF手册计算值一致。我做了一个调试构建,下载到目标,并检查了U2BRG和U2MODE在SFR窗口-正确的值。我在范围内捕获了几个字符,计时正确。昨天唯一的区别是在寄存器表中显式地设置BRGH。
以上来自于百度翻译 以下为原文 I deleted UART2 from my project, and then included it again. I used the MCC UART2 Easy Setup tab to set 9600 baud, etc, and then the Registers tab to explicitly set BRGH to 1. I then generated the MCC code. This time I got the correct baud rate. U2BRG was set to 0x0067 and BRGH to 1 (in uart2.c code). This agrees with the ref manual calculated values for Fcy = 4 MHz. I did a debug build, downloaded to the target, and inspected U2BRG and U2MODE in the SFR window - correct values. I captured several characters on the scope and the timings were correct. The only difference from yesterday was explicitly setting BRGH in the Registers tab. Go figure .... |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475 浏览 0 评论
5794 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1125浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1098浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 15:49 , Processed in 0.666678 second(s), Total 75, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
9612