打印

请教STM32SPI的问题

[复制链接]
2156|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ajunjun|  楼主 | 2009-5-3 12:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1、我用SPI口要只接受数据,作为主机可以吗?
2、我该如何配置呢?请赐教!谢谢
沙发
McuPlayer| | 2009-5-3 14:43 | 只看该作者

SPI是双向的

主机当然可以接受数据

但有一点,CLK信号是主机发出,这是SPI的协议所决定的。

使用特权

评论回复
板凳
grant_jx| | 2009-5-3 15:25 | 只看该作者

在主模式下打开接收

参考例程可以看v2.0.3的固件库。。。STM32F10xFWLibFWLibexamplesSPIFullDuplex_SoftNSS

SPI FullDuplex_SoftNSS Example ,需要注意这个例程的NSS是使用软件,不是硬件方式管理。


Example description
===================
This example provides a description of how to set a communication between the two SPIs in full-duplex mode and performs a transfer from Master to Slave and then Slave to Master in the same application with software NSS management.

Both SPIs are configured with 8bit data frame and a 9Mbit/s communication speed. In the first phase, the master SPI1 starts the SPI1_Buffer_Tx transfer while the slave SPI2 transmit SPI2_Buffer_Tx. Once the transfer is completed a comparison is done and TransferStatus1 and TransferStatus2 gives the data transfer status for each data transfer direction where it is PASSED if transmitted and received data are the same otherwise it is FAILED.

As the NSS pin is managed by software, this permit to SPI1 to become slave and SPI2 to become master whithout hardware modification。

In the second step, the slave SPI1 starts the SPI1_Buffer_Tx transfer while the master SPI2 transmit SPI2_Buffer_Tx. Once the transfer is completed a comparison is done and TransferStatus3 and TransferStatus4 gives the data transfer status for each data transfer direction where it is PASSED if transmitted and received data are the same otherwise it is FAILED.

使用特权

评论回复
地板
香水城| | 2009-5-3 19:45 | 只看该作者

使用STM32 SPI的主机模式,可以只接收数据

但要注意SPI的协议是环回式的,即发送的同时进行接收。

正如2楼所说CLK信号是主机发出的,因为环回式的操作方式,只有发送操作,STM32才会发送出时钟信号。

另外,不管什么样的SPI从设备,总需要接收配置命令才能正确地执行操作吧,至少需要一些配置参数,因此应该没有纯粹的只发送数据的SPI从设备。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

0

粉丝