完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
设置一个简单的输出例程,将MSSP设置为SPI主控器。从18F2620规范表中获取代码片段非常正确。顺序:将输出管脚LOW设置为目标SS*信号。用字节数据加载SSPBUF reg。(这应该启动一个SPI输出周期)在SSPSTAT中观察BF位直到它到达1。(即发送周期已经完成。)旋转BF位,直到它变高。读取SSPBUF reg,以便为下一个周期清除BF位,丢弃数据。将SS*的输出引脚设置回HIGH。稍等(测试代码等待40mSec)并重复循环。问题:MPLAB SIM从不设置比特。代码一直在旋转,等待SSPSTAT中的BF位变高。有趣的部分是:将代码片段放入芯片中,观察SPI管脚SDO和SCAD的输出,SS*信号显示端口正按照预期运行。SS*宽度和SCK时钟正是我设置MSSP来生成的。SDO匹配填充到SSPBUF的字节i。(一切都好)我还试着看SSPIF位(PrIl& lt;3 & gt;)。没有欢乐,也没有显示周期的完成。
以上来自于百度翻译 以下为原文 Set up a simple output routine with the MSSP set up as an SPI master. Took the code snippet pretty much right from the 18F2620 spec sheet. Sequence: Set an output pin LOW to be the target SS* signal. Load the SSPBUF reg with a byte of data. (This should initiate a single SPI output cycle) Watch the BF bit in SSPSTAT until it goes to 1. (This sez that the send cycle has completed.) Spin on the BF bit until it goes HIGH. Read the SSPBUF reg just to clear the BF bit for the next cycle, discard the data. Set the output pin for SS* back to HIGH. Wait a bit (test code waits 40 mSec) and repeat the loop. The problem: MPLAB SIM never sets the bit. The code spins forever waiting for the BF bit in SSPSTAT to go HIGH. The interesting part: Putting the code snippet into the chip and observing the output from the SPI pins SDO and SCK and the SS* signal shows that the port is behaving exactly as expected. SS* width and SCK clocks are exactly what I set the MSSP to generate. SDO matches the byte I stuffed into SSPBUF. (All is good) I have also tried looking at the SSPIF bit (PIR1<3>). No joy, it doesn't show the completion of the cycle either. |
|
相关推荐
4个回答
|
|
模拟器不模拟设备上的每一个外设。(我们根本没有足够的人力来做到这一点!)在任何设备上都不模拟MSSP。(有趣的是,我将在下周在MASTERS讨论如何使用模拟器插件来模拟MSSP外围设备。)通过单击MPLAB X中的仪表板窗格中的“单击模拟外围设备”,您可以看到为任何给定设备实现了哪些外围设备。
以上来自于百度翻译 以下为原文 The simulator does not simulate every peripheral on a device. (We simply don't have enough man-power to do this!) MSSP is not simulated on any device. (Interestingly, I will be discussing how to emulate the MSSP peripheral using simulator plug-ins at MASTERS next week.) You can see which peripherals are implemented for any given device by clicking on the "Click for Simulated Peripherals" in the Dashboard pane in MPLAB X. Attached Image(s) |
|
|
|
|
|
|
|
是的。我想可能是这样。谢谢你的迅速澄清。对于sim,我已经用一个虚拟机代替了对执行SPI输出的子机的调用,这个虚拟机只是消磨时间,直到它等于实际的H/W定时。在构建真正可加载的H/W代码时,必须注意注释的输入/输出到哪里,但我可以应付过去,谢谢您的时间。(希望你能解决如何做一个处理MSSP的SIM)
以上来自于百度翻译 以下为原文 Yep. thought it might be something like that. Thanks for the speedy clarification. For the sim I have replaced the call to the sub that does the SPI output with a dummy that just kills time until it equals the actual H/W timing. Have to pay attention to where the commenting in/out goes when building the real loadable H/W code, but I can get by with that, Thank you for your time. (Hope you can work out how to do a sim that will handle the MSSP) |
|
|
|
通过SCL很容易模仿外围设备(以有限的方式)。SCL是模拟器的注册表脚本语言。SCL上的文档可以在MPLAB X安装目录的DOCS子文件夹中找到。
以上来自于百度翻译 以下为原文 It's pretty easy to emulate peripherals (in a limited fashion) via SCL. SCL is an injection scripting language for the simulator. Documentation on SCL can be found in the docs sub-folder of your MPLAB X installation directory. |
|
|
|
只有小组成员才能发言,加入小组>>
5150 浏览 9 评论
1994 浏览 8 评论
1923 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3164 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2221 浏览 5 评论
716浏览 1评论
602浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
488浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
616浏览 0评论
515浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-14 17:30 , Processed in 1.463632 second(s), Total 106, Slave 89 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号