完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我正在尝试为dsPIC33F(找不到现成的驱动程序)实现MCP23S17的接口,我从数据表中无法理解spi所需的定时。如果它希望写8位数据或16位数据。我看到一些驱动程序在网上,有些只使用8位数据,而有些只使用8位数据。e其他16位数据,所以spi传输4个字节:tx[0]=0x40tx[1]=commandtx[2]=value tx[3]=value>8我不明白最后2个字节来自哪里,在数据表中没有对此的引用。我还看到其他驱动程序只使用一个字节作为数据(没有tx[3])。戴维
以上来自于百度翻译 以下为原文 Hello, I am trying to implement interface for MCP23S17 for dsPIC33F (could not find ready implemented driver), I could not understand from datasheet what's the required timing with spi. Should it expect to write 8 bits data or 16 bits data. I saw some drivers in net, some are using only 8-bit data, while other 16 bit data, so that the spi transfer 4 bytes: tx[0] = 0x40 tx[1] = command tx[2] = value tx[3] = value >> 8 I can't understand where these 2 last bytes come from, there is no reference for this in datasheet. I also see that other driver use only one bytes for data (there is no tx[3]). Best Regards, David |
|
相关推荐
6个回答
|
|
嗨,因为SPI总是有它自己的位时钟信号在单独的线/迹上,所以SCK引脚、精确定时并不重要,只要它不太快。MCP23S17的数据表规定了10MHz的最大值。dsPIC33中的SPI硬件通常有一个控制位以8位或16位模式操作。此外,MCP23S17具有内部控制以8位数据或16位序列操作。这对SPI信号线并不重要:当SPI数据传送时。r开始,通过设置/CS低,SPI传输是连续的比特序列,在字节或单词之间没有标点。如果从数组传输数据,则数据的排序可能根据8位或16位模式而受到影响。代码片段显示以8位字节数组构建缓冲区,这是在DSSPIC33中使用8位模式传输到MCP23 S17。“值”是软件中的16位或更长的整数变量。它应该包含要传送到端口扩展器的数据、控制寄存器设置或输出管脚数据。每次传送到MCP23S17时,可以传送1个或更多个数据字节,即一起传送3个或更多个字节。字节4和后续将如何解释,将取决于ICOON寄存器中的设置。
以上来自于百度翻译 以下为原文 Hi, Since SPI always have it's own bit clock signal on a separate wire/trace, the SCK pin, precice timing do not matter, as long as it is not too fast. The datasheet for MCP23S17 specify 10 MHz maximum. SPI hardware in dsPIC33 usually have a control bit to operate in 8 bit or 16 bit mode. Also, the MCP23S17 have internal controls to operate either with 8 bit data or 16 bit sequences. This do not matter to the SPI signal lines: when a SPI data transfer is started, by setting /CS low, a SPI transfer is a contigous sequence of bits, with no punctuation between bytes or words. If transferring data from an array, the ordering of data may be affected depending upon 8-bit or 16-bit mode. The code snippet show building a buffer in a array of 8-bit bytes, this is for transfer to the MCP23S17 using 8-bit mode in the dsPIC33. 'value' is a 16 bit or longer integer variable in your software. It should contain the data you want to transfer to the port expander, control register settings or output pin data. It is possible to transfer 1 or more data bytes in each transfer to the MCP23S17, that is 3 or more bytes together. How byte 4 and following will be interpreted, will depend upon settings in the IOCON register. Regards, Mysil |
|
|
|
嗯,“值”可以是一个或多个字节,这取决于命令,所以上述是有意义的…
以上来自于百度翻译 以下为原文 Hmmm, the "value" can be one or more byte, depending upon the command, so the above makes sense... |
|
|
|
但是根据寄存器汇总(MCP23S17数据表),所有的寄存器都是8位的。那么,在8位大小的寄存器中写入16位的内容意味着什么?问候,戴维
以上来自于百度翻译 以下为原文 But according to register summary (in MCP23S17 datasheet) all register are 8-bits only. So, what does it means to write content of 16-bits in registers of 8-bit size ? Regards, David |
|
|
|
当IOCON.BANT位是明确的,寄存器成对分组,可以被视为16位。
以上来自于百度翻译 以下为原文 When the IOCON.BANK bit is clear, the registers are grouped in pairs which can be regarded as 16 bit. |
|
|
|
|
|
|
|
并且许多SPI(和I2C)从设备具有自动寄存器地址增量,使得如果24位、32、40、48或……在MCP23S17中,SEQOP和IOCON寄存器中的BANK位控制在SPI传输序列中传输多个字节时发生的情况。总计。迈西尔
以上来自于百度翻译 以下为原文 And many SPI (and I2C) slave devices have automatic register address incrementation, such that if 24 bits, 32, 40, 48, or ... bits are transferred, it is possible to update a number of registers in sequince In MCP23S17, SEQOP and BANK bits in IOCON register control what happen when multiple bytes are transferred in a SPI transfer sequence. It is possible to write or read all of MCP23S17 registers in one transfer, 23 bytes in total. Mysil |
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3174 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
734浏览 1评论
615浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
506浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
631浏览 0评论
528浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 22:21 , Processed in 1.259270 second(s), Total 87, Slave 71 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号