完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
我想在SPC560D和SPC56EL发现板之间实现SPI通信。 SPC56EL应作为从机,SPC560D作为主机。对于这两块板,我在SPC5Studio中使用相应的DSPI示例应用程序。 然而,我无法在两个板之间进行通信。 主设备每隔20ms发送7个12位SPI帧到从设备。为SPC560D调整DSPI示例以获得此功能是没有问题的。 问题是从站(SPC56EL)配置。我通过添加线路将设备设置为从机模式 spip-> DSPI - > MCR .B .MSTR = 0 在spi_lld_start函数(spi_lld.c)中并调整CTAR0寄存器中的帧大小。此外,DMA仅设置为RX。之后,当主机将CS设置为低电平时,从机的SOUT引脚设置为高电平。然而,SPC56EL既不接收任何数据(DSPI_RXFR寄存器为空)或将数据发送回主设备 在从机模式下使用SPC56EL的正确配置步骤是什么? 最好的祝福, 帕特里克 以上来自于谷歌翻译 以下为原文 Hello, I would like to implement a SPI communication between an SPC560D and an SPC56EL Discovery Board. The SPC56EL should act as slave, the SPC560D as master. For both boards, I am using the corresponding DSPI example applications in SPC5Studio. Nevertheless, I am not able to get a communication between the two boards. The master sends every 20ms seven 12bit SPI frames to the slave. It was no problem to adapt the DSPI example for SPC560D to get this functionality. The problem is the slave (SPC56EL) configuration. I set the device in slave mode by adding the line spip->dspi ->MCR .B .MSTR = 0 in the spi_lld_start function (spi_lld.c) and adapted the frame size in CTAR0 register. Additionally, DMA is set to RX only. After that, the SOUT pin from slave is set to high when master sets the CS to low. Nevertheless, the SPC56EL neither receives any data (DSPI_RXFR registers are empty) or sends data back to the master device What would be the correct configuration steps to use the SPC56EL in slave mode? Best regards, Patrik |
|
相关推荐
8个回答
|
|
你好Patrik,
如果你想把EL发现板放在Slave中 是的,您可以在spip-> dspi中设置DSPI设置 - > MCR .B .MSTR = 0 并更新spi_config_high_speed(如下所示) 应设置CTAR_0 :(参见手册以下) ================== 现场描述 SLAVE_FMSZ 从属帧大小。每帧传输的位数等于SLAVE_FMSZ字段值加1。 最小有效SLAVE_FMSZ字段值为3。 SLAVE_CPOL 时钟极性。 CPOL位选择串行通信时钟(SCK)的无效状态。 0 SCK的非活动状态值为低 1 SCK的非活动状态值很高 SLAVE_CPHA 时钟相位。 CPHA位选择SCK的哪个边沿导致数据改变以及哪个边沿 导致数据被捕获。 0数据在SCK的前沿捕获,并在随后的边沿更改 1数据在SCK的前沿更改,并在后续边沿捕获 SLAVE_PE 奇偶校验启用。 PE位使能帧的奇偶校验位发送和接收 0未包含/检查奇偶校验位。 1发送奇偶校验位而不是帧中的最后一个数据位,检查接收帧的奇偶校验位。 SLAVE_PP 奇偶极性。 PP位控制发送和检查的奇偶校验位的极性 0偶数奇偶校验:发送帧中“1”位的数量是偶数。如果输入,则DSPI_SR [SPEF]位置1 接收到的帧数为“1”位是奇数。 1奇数奇偶校验:发送帧中“1”位的数量为奇数。如果输入,则DSPI_SR [SPEF]位置1 收到的帧数为“1”位是偶数。 在第17.4章中,他们对EL参考手册有一些有用的信息。 时钟由MASTER提供。 我正在与DSPI专家核实。 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Hello Patrik , if you want to put EL Discovery board in Slave yes , you have well to set your DSPI Settings in spip->dspi ->MCR .B .MSTR = 0 and update spi_config_high_speed (like below) CTAR_0 should be set : (Cf below Reference Manual) ================== Field Descriptions SLAVE_FMSZ Slave frame size. The number of bits transferred per frame is equal SLAVE_FMSZ field value plus 1. Minimum valid SLAVE_FMSZ field value is 3. SLAVE_CPOL Clock Polarity. The CPOL bit selects the inactive state of the Serial Communications Clock (SCK). 0 The inactive state value of SCK is low 1 The inactive state value of SCK is high SLAVE_CPHA Clock Phase. The CPHA bit selects which edge of SCK causes data to change and which edge causes data to be captured. 0 Data is captured on the leading edge of SCK and changed on the following edge 1 Data is changed on the leading edge of SCK and captured on the following edge SLAVE_PE Parity Enable. PE bit enables parity bit transmission and reception for the frame 0 No parity bit included/checked. 1 Parity bit is transmitted instead of last data bit in frame, parity checked for received frame. SLAVE_PP Parity Polarity. PP bit controls polarity of the parity bit transmitted and checked 0 Even Parity: number of “1â€� bits in the transmitted frame is even. The DSPI_SR[SPEF] bit is set if in the received frame number of “1â€� bits is odd. 1 Odd Parity: number of “1â€� bits in the transmitted frame is odd. The DSPI_SR[SPEF] bit is set if in the received frame number of “1â€� bits is even. On chapter 17.4 , they have some useful informations on EL Reference Manual. The clock is given by the MASTER. I am checking with DSPI experts. Best regards Erwan |
|
|
|
你好,
最后,我解决了我的问题。主要问题是,我不知道如何在spi.c中使用SPI驱动程序函数。我认为所有驱动程序功能仅用于主配置。在我了解它们独立于主/从配置之后,我所要做的就是调整spi_config结构并在spiStart()函数中添加一行来设置SPI从模式。 这是我的最终测试代码: 最好的祝福, 帕特里克 以上来自于谷歌翻译 以下为原文 Hello, Finally, I solved my issue. The main problem was, that I didn´t understand how to use the SPI driver functions in spi.c. I thought all driver function are only to use in master configurations. After I understand that they are independent from master/slave config, all I had to do was adapting the spi_config structure and adding one line in the spiStart() function to set SPI slave mode. Here is my final test code:
Best regards, Patrik |
|
|
|
好消息,您正在成为SPI专家;-)
不要忘记原始HAL文件和修补文件之间的所有差异都在文件''patch.xml'中。 不要删除它;-) 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Good news , your are becoming a SPI Expert ;-) Do not forget that all the differences between original HAL Files and your patched file are in the file ''patch.xml''. Do not remove it ;-) Best Regards Erwan |
|
|
|
你好,Erwan,
谢谢,但似乎成为SPI专家并不容易;-) 我调查了另一个主设备的意外行为和更快的SPI传输(请参见附带的示波器图片)。 SPI主设备以大约4MHz的频率向从设备(SPC56EL发现板)发送数据。黄线(MISO)显示从SPI从设备发送回主设备的数据。出于测试目的,从器件忽略接收的数据并返回8x11bits。因此,我使用了SPI驱动程序中的spiStartSend函数,并更改了main.c中的代码,如下所示: 根据我的理解,控制器现在应该忽略接收到的数据,并将数组dummyData的前八个元素发送回主控器。由于所有数组元素都为0,因此从机应发送值为0的88位。但是当您查看附加图像时,从机有时会返回至少一个值为1的位。 当我用有效值填充数据数组时,我看到了相同的效果。然后,从站将完全错误的值发送回主站。 你对这种行为有解释吗?有什么我忘了做的吗? 最好的祝福, 帕特里克 以上来自于谷歌翻译 以下为原文 Hello Erwan, Thanks, but it seems that it is not so easy to become an SPI expert ;-) I investigated an unexpected behavior with another master device and faster SPI transmission (please see attached oscilloscope picture). The SPI master sends data to the slave device (SPC56EL discovery board) with around 4MHz. The yellow line (MISO) shows the data send back from SPI slave to master device. For testing purpose, the slave ignores the received data and just sends back 8x11bits. Therefore, I used the spiStartSend function from SPI driver and changed the code in main.c as followed:
For my understanding, the controller should now ignore the received data and send the first eight elements of array dummyData back to the master. As all array elements are 0, the slave should send 88bits with value 0. But when you look at the attached picture, the slave sometimes returns at least one bit with the value 1. I saw the same effect when I fill the data array with valid values. Then the slave sends completely wrong values back to the master. Do you have an explanation for that behavior? Is there something I forgot to do? Best regards, Patrik |
|
|
|
你好Patrik,
根据奴隶配置,(Leopard) FrameSize是11位(0xA + 1) CPOL / CPHA等于0 您是否将主配置(Bolero)配置为相同的配置 CPOL / CPHA 0和FrameSize 11位 明天,我们将尝试在这个问题上建立一个实际的工作。 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Hello Patrik, According to the slave configuration , (Leopard) FrameSize is 11 Bits (0xA + 1) CPOL/CPHA is equals to 0 Did you configure the Master Configuration (Bolero) to the same configuration CPOL/CPHA 0 and FrameSize 11 Bits Tomorrow , we will try to build a practical work on this subject. Best regards Erwan |
|
|
|
你好,Erwan,
是的,他们使用相同的配置。 框架长度FMSZ的另一个问题是: 例如,如果主机发送5x16bits和1x8bits(一次传输总共88位)。如果从机配置为接收8x11位,传输是否也可以工作? 最好的祝福, 帕特里克 以上来自于谷歌翻译 以下为原文 Hello Erwan, Yes, they use both the same configuration. One additional question to the frame length FMSZ: For example if the master send 5x16bits and 1x8bits (totally 88bits for one transfer). Would the transmission also work if the slave is configured to receive 8x11bits? Best regards, Patrik |
|
|
|
你好Patrik,
硕士与硕士slave应该具有相同的配置。 你有没有尝试8x11bits用于master&奴隶 ? 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Hello Patrik , Master & slave should have the same configuration. did you try 8x11bits for master & Slave ? Best regards Erwan |
|
|
|
你好,Erwan,
主机在一个SPI帧内发送88位(5x16位+ 1x8位)。我将从机配置为接收11x8bits。但这不是问题。 我在SPI通信方面的问题或多或少都是时序问题。最后,我通过使用DMA为RX和TX解决了它们。此外,在我看来,SPC5 Studio SPI驱动程序并未针对高数据速率和通过SPI连续数据流进行优化。最后,我只使用了驱动程序函数进行初始化。对于通信控制,我直接写了寄存器。 最好的祝福, 帕特里克 以上来自于谷歌翻译 以下为原文 Hello Erwan, The master sends 88bits (5x16bit + 1x8bit) within one SPI frame. I configured the slave to receive 11x8bits. But this wasn´t a problem. My problems with SPI communications were more or less timing issues. Finally I solved them by using DMA for RX and TX. Additionally, it seems to me that the SPC5 Studio SPI driver is not optimized for high data rates and continuously data stream over SPI. In the end, I only used the driver function for initialization. For communication control, I directly wrote the registers. Best regards, Patrik |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2730 浏览 1 评论
3239 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1808 浏览 1 评论
3647 浏览 6 评论
6035 浏览 21 评论
1338浏览 4评论
198浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
350浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
442浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
273浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 02:53 , Processed in 1.177110 second(s), Total 63, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号