完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我一直在尝试各种各样的事情来完成这项工作,但我什么也没找到。我试过CKE、CKP、SMP、主预分频器和次预分频器的所有可能的组合(字面意思:我编写代码来迭代所有可能的组合,重置编码器,并尝试从中读取一些值并通过USB CDC将它们吐出)。我试过使用循环,我试过使用中断。我已经尝试过3线只读和4线双向。我已经尝试了16位模式和8位模式。我已经尝试过声明SS,我已经尝试让SPI模块来处理它。我尝试使用“框架模式”,我试着把它关闭。在每一种情况下,我从编码器接收空值。不幸的是,我没有访问作用域的权限,但是我已经按照PIC24和编码器的数据表中的说明操作,并且尝试了来自整个网络的代码。这似乎不那么困难,但什么也不能奏效。我想在这里发布一些代码,但是我已经尝试了很多不同的变体,以至于我无法选择在这里发布的代表我努力的东西。谁能告诉我正确的方向吗?我有什么遗漏在这里吗?这看起来应该非常简单。
以上来自于百度翻译 以下为原文 I've been trying various things to get this working and I'm just not getting anywhere. I've tried every possible combination of CKE, CKP, SMP, primary prescaler, and secondary prescalar (literally: I wrote code to iterate through all possible combinations, reset the encoder, and try to read a few values from it and spit them out via USB CDC). I've tried using loops and I've tried using interrupts. I've tried 3-wire read only and 4-wire bidirectional. I've tried 16-bit mode and 8-bit mode. I've tried asserting SS myself and I've tried letting the SPI module take care of it. I've tried using "framed mode" and I've tried leaving it off. In every case, I receive empty values back from the encoder. Unfortunately, I don't have access to a scope but I've followed the instructions in the datasheets for the PIC24 and the encoder as well as trying code from all over the web. This doesn't seem like it should be that difficult but nothing works. I'd post some code here but I've tried so many different variations on it that I couldn't possibly pick something to post here that would be representative of my efforts. Could anyone point me in the right direction? Is there something I'm missing here? This seems like it should be very straightforward. |
|
相关推荐
4个回答
|
|
|
|
|
|
PIC与模拟输入共用的数据输入引脚吗?如果是,你把它转换成数字模式了吗?
以上来自于百度翻译 以下为原文 Is the data input pin on that PIC shared with an analog input? If yes, have you switched it to digital mode? |
|
|
|
其中明显的一种是投入产出和投入产出。一些命名约定在主输出、从输入对和主输入都使用相同的名称,而从输出则使用不同的名称。如果使用有点碰撞的SPI,则应该能够单步使用DVM测量信号。当然,一个范围使事情变得容易很多。/ Ruben
以上来自于百度翻译 以下为原文 The obvious one: Input to output and output to input. Some naming conventions use the same name at both the master output, slave input pair and the master input, slave output while other have different names. If you use a bit banged SPI you should be able to single step and measure the signals with a DVM. Of course, a scope makes things a lot easier. /Ruben |
|
|
|
一些想法:在POST 6中的代码似乎将SS控制到SPI1,因此它确定信号何时被断言。当你说“...我只是编写一个程序,简单地打开和关闭它…”你还在运行你的SPI初始化代码(与PPS设置为SS1OUT)?-send_command()函数似乎想通过LATB2控制它,但是初始化似乎又想将其置于SPI1的控制之下。-我怀疑SPIFE需要设置。-如果我正确地读取它,AMS数据表表明设备的/INT信号被用来调整SPI交换的速度。e s(即,除非/INT被断言,否则不应该发起任何交换)。-我建议基于AMS数据表中记录的交互wi发布一个最小的、完整的程序,尝试做一些非常简单的事情(例如,读取ID寄存器或者会给您提供非零、非FF数据的事情)。这个装置。设置你的逻辑分析仪来捕获/INT,SS,时钟和数据信号。发布一个图片,当你运行程序时会发生什么。(您可能无法直接发布图片,但是其他新用户已经采用了一些解决办法。)使用简单明了、定义良好的内容可能会在这里获得更多的帮助。
以上来自于百度翻译 以下为原文 Some thoughts: - The code in post 6 seems to give control of SS to SPI1, so it determines when the signals will be asserted. When you say "...I just write a program that simply turns it on and off..." are you still running your SPI initialization code (with the PPS set to SS1OUT)? - Your send_command() function seems to want to control it via LATB2 but again the initialization seems to want to put it under control of SPI1. - I suspect SPIFE needs to be set. - If I'm reading it correctly, the AMS data sheet indicates that the device's /INT signal is used to pace the SPI exchanges (i.e., you shouldn't initiate any exchange unless /INT is asserted). - I'd suggest posting a minimal, complete program that attempts to do something very simple (e.g., read the ID register or something that'll give you non-zero, non-FF data) based on the AMS data sheet's documented interaction with the device. Set up your logic analyzer to capture /INT, /SS, the clock, and data signals. Post a picture of what happens when you run the program. (You may not be able to post pictures directly but there are workarounds that other new users have employed.) Working with something straightforward and well-defined will probably get you more help here. |
|
|
|
只有小组成员才能发言,加入小组>>
5234 浏览 9 评论
2026 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3200 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
771浏览 1评论
659浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
588浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
670浏览 0评论
571浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 22:52 , Processed in 1.197480 second(s), Total 84, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号