完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我在PIC18F25K22上写了一个新的项目,使用XC8和Microchip代码配置器。为了开始,我写了一个简单的应用程序,它通过UART发送和接收数据。不成功。我唯一能做的就是EUSATAR2资源,并且我将重定向STDIO勾到USAT复选框。只发送第一个字符。我试图读取生成的代码,但对我来说完全没有意义。(后来我完全改变了EuSARTAR2X写()例程,将它简化为3行代码,并使它在没有问题的情况下工作)。我在接收数据方面也遇到了麻烦,但这也可能是硬件问题(设计中的一些电阻)。有人能告诉我如何为P配置代码吗?RtiMF工作正常,以及如何接收数据从UART(接收数据引起中断)?也许是样本代码?
以上来自于百度翻译 以下为原文 I am writing a new project on PIC18F25K22, using XC8 and the Microchip Code Configurator. For start, I am writing a simple app which sends and receives data via UART. Unsuccessfully. The only thing I enable is the EUSART2 resource, and I tick the redirect STDIO to USART checkbox. With the generated code, only the first character is sent. I tried to read the generated code, but it made absolutely no sense to me. (I later changed the EUSART2_Write() routine completely, reduced it to 3 lines of code, and got it to work without problems). I am also having trouble with receiving data, but this might be a hardware issue as well (some resistors in the design). Could somebody direct me how to configre the code for printf to work properly, and how to receive data from UART (receiving data causes interrupt)? Sample code, perhaps? |
|
相关推荐
1个回答
|
|
这听起来像TX中断没有匹配的中断服务例程启用。最简单的方法不使用中断,它只是轮询TXIF标志。个人而言,我不会为MCC那样简单的事情麻烦。自己写,然后你知道代码在做什么。Et Primtf要工作,你需要做的是创建一个名为PutCh()的函数来发送每个字节,Primff()将使用它(这是在XC8用户指南中记录的)。我得到了Primtf的工作,但是我确信我没有勾选TX中断复选框。无论如何,我知道自己写它更快,B。我希望我能做到这一点。它希望它与和声不同,我希望它能起作用,但我似乎不能依靠这些代码配置器。
以上来自于百度翻译 以下为原文 That sounds like TX interrupts are enabled without a matching interrupt service routine. The simplest way to do this doesn't use interrupts, it just polls the TXIF flag. Personally, I wouldn't bother with MCC for something as simple as this. Write it yourself, then you KNOW what the code is doing. To get printf to work, all you need to do is create a function called putch() to send each byte, and printf() will use it. (This is documented in the XC8 user guide.) I got printf to work, but I am pretty sure I did not tick the TX interrupt checkbox. Anyway, I know it is faster to just write it myself, but I was hoping I could do it 'the intended way'. It wanted it to be different than Harmony, I wanted it to work, but it seems that I just cannot depend on these code configurators. |
|
|
|
只有小组成员才能发言,加入小组>>
5162 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3172 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
731浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
629浏览 0评论
527浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 08:52 , Processed in 1.214787 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号