完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我试图在两个PICS之间建立一个SPI主/从链路——一个24FJ(主)和一个32 MX(从机)。虽然我已经正确地连接了SS链接,但我在手动(GPIO)模式中使用它,而不是在两个图片中启用SS功能。使用这个主代码:我从24FJ得到正确的传输,带有SPI3CON1= 0xC3E(SDO禁用,16位,SS禁用,主控,2MHz)(见附加的范围跟踪)在从属端,我有这个代码:但是32 MX不确认传输。我的32 MX795F512L有专用的SPI3引脚-没有RPS-这些都是正确连接和TrIS/Digital SuffuldSp3Con=0x1400(SDO禁用,16位,SS禁用,从)请注意,我已经暂时设置这是唯一的操作代码,32 MX只是等待永远接收传输-但等待无效。我误解了PIC从功能-从来没有使用过它-但它击败了我错过了什么!请给我建议。
以上来自于百度翻译 以下为原文 I'm attempting to set up an SPI master/slave link between two PICs - a 24FJ (master) and a 32MX (slave). Although I have the SS link correctly connected I am using it in manual (GPIO) mode instead of enabling the SS feature in both PICs. Using this master code: SS_enable; writeSPI(0xAAAA); SS_disable; I am getting the proper transmission from the 24FJ with SPI3CON1=0xC3E (SDO disable, 16 bit, SS disable, master, 2MHz) (see the attached scope trace) At the slave end I have this code: while(SS_disable);//sensing the GPIO line from the 24FJ if(readSPI3()==0xAAAA) B1;///turns on an LED if true - SPI3 is also used on the 32MX but the 32MX is not confirming the transmission. My 32MX795F512L has dedicated SPI3 pins - no RPs - and these are all correctly connected and TRIS/digital configured SPI3CON=0x1400 (SDO disable, 16 bit, SS disable, slave) Please note that I have set this temporarily to be the only operating code and that the 32MX simply waits forever to receive the transmission - but waits in vain. Obviously I am misunderstanding the PIC slave function - never used it before - but it beats me what I've missed! Your advice please. Attached Image(s) |
|
相关推荐
11个回答
|
|
通常,SS 行是控制硬件中的从属的,你不需要自己做任何事情。(这也有一个优点,当SS线变低时,SPI硬件将复位,从而任何杂散时钟脉冲将被忽略。)我不知道“READSPI3()”函数是什么,但是您使用它的方式意味着它必须阻止,直到SPI外围设备指示它具有COMPL。换句话说,它需要等待SpBBF位的设置,然后它可以从SPIXBUF.SUSAN读取接收到的值。
以上来自于百度翻译 以下为原文 Typically the SS line is what controls the slave in hardware and you don't need to do anything yourself. (This also has the advantage that when the SS line goes low, the SPI hardware will reset so that any spurious clock pulses will be ignored.) I have no idea what the 'readSPI3()' function does but the way you are using it means that it must block until the SPI peripheral indicates that it has completed the exchange. In other words it needs to wait for the SPIRBF bit to be set and then it can read the received value from the SPIxBUF. Susan. |
|
|
|
你为什么在奴隶中残废SS?正如苏珊所暗示的,SS在奴隶中工作是一件很好的事情。我强烈建议你在奴隶中启用SS,并且摆脱你自己的奴隶代码,直到SS变低。让硬件来完成它的工作。
以上来自于百度翻译 以下为原文 Why have you disabled SS in the slave? As Susan implies, SS is a very GOOD thing to have working in the Slave. I would strongly suggest that you enable SS in the Slave, and get rid of your own slave code that is waiting until SS goes low. Let the hardware do its job. |
|
|
|
谢谢你回复澳洲人苏珊。我已经尝试了SS线在主从双方,但奴隶似乎忽略它。我的RealSPi3()只写0xFF,然后等待SpBBF清除-但你是对的,函数需要“等待”,显然SS变低了,而不是由主机完成,缓冲区的填充应该是个办法——我会尝试你的建议。我以前从未建立过奴隶。
以上来自于百度翻译 以下为原文 Thanks for replying Aussie Susan. I have tried enabling the SS line in both master and slave but the slave seems to ignore it. My readSPI3() just writes 0xFF and then waits for SPIRBF to clear - but you're right, the function needs 'something to wait for' and evidently the SS going low isn't doing it - and the filling of the buffer by the master ought to do the trick - I shall try your suggestion. I have never set up a slave before. |
|
|
|
从属者应该等待SpBBF设置,然后从外围设备读取。主机中的WrrestPipe()是否等到传输完成后返回?如果不是,你早就禁用SS了。
以上来自于百度翻译 以下为原文 The Slave should wait for SPIRBF to set, then read from the peripheral. Does WriteSPI() in the Master wait until the transfer is complete before returning? If not, you are disabling SS too early. |
|
|
|
主和从SPI硬件之间如何使用“SS”行有一个轻微的“不平衡”。当SPI外围设备处于“主”模式时,它将不*驱动 行-您需要通过端口引脚(使用LATX寄存器)来完成。然而,外围设备处于“奴隶”模式。如果它是启用的,它将使用SS 行。因此,在主控器中:-将您正在使用的引脚作为SS信号使用到从交换机,但是在这个突发中需要许多值-将您所用的PIN作为在主从中的sSavealin使用:-设置要返回的初始值。主-等待一个值被交换(SS 行将下降并重置时钟计数器为第一个值)-从顶部的过程中读取接收到的值-重复,您可能需要在上述行之间添加其他代码位(错误检查总是一个好主意),但这是T。基本轮廓苏珊
以上来自于百度翻译 以下为原文 There is a slight 'imbalance' between how the master and the slave SPI hardware use the SS line. When the SPI peripheral is in 'master' mode, then it will *not* drive the SS line - you need to do that through a port pin (using the LATx register). However then the peripheral is in 'slave' mode then it *will* use the SS line if it is enabled. So, in the master you: - lower the pin you are using as the SS signal to the slave - exchange however many values you need to in this burst - raise the pin you are using as the SS signal In the slave you: - set an initial value you want to send back to the master - wait until a value is exchanged (the SS line will drop and reset the clock counter for the first value) - read the received value - repeat from the top Of course you probably need to add in other bits of code in between the above lines (error checking is always a good idea) but that is the basic outline. Susan |
|
|
|
感谢你的回应——是的,我已经有了这个报道。澳大利亚人苏珊-我刚刚回来,现在将更新,但您的输入是真的赞赏,我不知道,即使启用了SS,您仍然应该手动操作它从主人。这在家庭手册中并不是很清楚,而且必须在控制器之间配置一个新的主从配置。而且,我一直假设奴隶会自动等待SS线变低,但是你告诉我它需要在寄存器装满之前被告知寄存器是完整的,然后,当然,等待它再次空出。从你说的,它现在都在工作,所以我就去做。不管怎样,再次谢谢你。
以上来自于百度翻译 以下为原文 qɥb Thanks for responding - yes, I already had that covered. Aussie Susan - I am just back at it now and will update but your input is really appreciated and I had NO idea that, even with SS enabled, you should still operate it manually from master. This is NOT made clear in the family manual and must flummox a good few who are new to master slave configurations between controllers. Also, I had been assuming that the slave would automatically be waiting for the SS line to go low but you tell me it needs to be told the register is full before it will load - and then, of course, wait for it to empty again. From what you say it should all be working now so I'll give it a go. Thanks again, regardless. |
|
|
|
不,你把她写的东西错了。奴隶硬件处理SS。你只需要等待外围设备说它已经接收到另一个字节。这正是我在第5页中所说的。
以上来自于百度翻译 以下为原文 No. you have mis-interpeted what she wrote. The slave hardware handles SS. You just have to wait for the peripheral to say it has received another byte. That is precisely what I said in post#5. |
|
|
|
多谢澳大利苏珊-我刚刚回到这里,谢谢你的解释,现在工作得很好。感谢QuiBi以前是一个非常类似的家伙,在我的第八个十年里才出现在数字上。在这里,我被(最不情愿地)呈现为一个“超级”成员,但事实上,我没有做任何值得的事情。再次感谢——如果我能看到的话,我会把这个问题解决掉。
以上来自于百度翻译 以下为原文 Many thanks Aussie Susan - I only just got back to this and, thanks to your explanation, it's now working fine. Thanks also to qɥb I'm a formerly very analog kind of a bloke and have only come to digital in my eighth decade - here I am presented (most unwillingly) as a "super" member but, in truth, I've done nothing to deserve it. Thanks again - I'd mark this 'solved' if I could see how. |
|
|
|
编辑第一篇文章,编辑“主题”,并添加“[解决]”或类似的。:)
以上来自于百度翻译 以下为原文 Edit the first post, edit the "subject", and add "[Solved]" or similar to it. :) |
|
|
|
|
|
|
|
你是最老的成员。你知道很多关于类比,所以你是超级会员。此外,你可以教我们一两件事。
以上来自于百度翻译 以下为原文 You are the oldest member. You know a lot about analogue so yeah you are a super-member. Plus you could teach us a thing or two. |
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2028 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3204 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
777浏览 1评论
666浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
595浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
676浏览 0评论
576浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 04:52 , Processed in 1.520709 second(s), Total 96, Slave 80 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号