OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3408|回复: 4

求助!!!新手研究生spi单线发送模式,驱动一款芯片。采用逻辑分析仪采集到的数据正确,却出现连续传输三次的现象,写入芯片...

[复制链接]

23

主题

48

帖子

0

精华

初级会员

Rank: 2

积分
121
金钱
121
注册时间
2019-3-27
在线时间
50 小时
发表于 2019-3-27 18:22:20 | 显示全部楼层 |阅读模式
5金钱
本帖最后由 Wenmin 于 2019-3-27 20:26 编辑

这是时序图片,以下是程序(写入芯片)
void ADN8810write(u16 num)
{
                RESET=1;
          delay_us(20);//¾àÕyêy¾Y′íλ

          CS=0;
          SPI1_ReadWriteByte(11);
          SPI1_ReadWriteByte(num);
//  SPI1_ReadWriteByte((u8)(num));
//           delay_us(1);
           while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY)==SET){}//μè′yspi¿ÕÏD
//         delay_us(2);
//         delay_us(20);
                 delay_us(1);
           CS=1;        

           RESET=0;
                 

//         RESET=1;

        
        
}

u8 SPI1_ReadWriteByte(u8 TxData)
{                 
        
                SPI_I2S_SendData(SPI1, TxData); //í¨1yíaéèSPIx·¢Ëíò»¸öbyte  êy¾Y
                         delay_us(3);
  while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE)== RESET){}//μè′yspi¿ÕÏD

                     
}

主函数功能是写入两个8位数据,逻辑分析仪的数据值正确,但为什么重复发了三次,而且CS片选线自己跳变。??????

F2IEJJ(5]TYE3T[(U3{7AKN.png

最佳答案

查看完整内容[请看2#楼]

Data applied to the SDI pin is clocked into the input shift register on the rising edge of CLK. After all 16 bits of the data-word have been clocked into the input shift register, a logic high on CS loads the shift register byte into the chip. If more than 16 bits of data are clocked into the shift register before CS goes high, bits are pushed out of the register in first-in first-out (FIFO) fashi ...
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

23

主题

48

帖子

0

精华

初级会员

Rank: 2

积分
121
金钱
121
注册时间
2019-3-27
在线时间
50 小时
 楼主| 发表于 2019-3-27 18:22:21 | 显示全部楼层
Data applied to the SDI pin is clocked into the input shift register on the rising edge of CLK. After all 16 bits of the data-word have been clocked into the input shift register, a logic high on CS loads the shift register byte into the chip. If more than 16 bits of data are clocked into the shift register before CS goes high, bits are pushed out of the register in first-in first-out (FIFO) fashion。手册里这么一段话怎么理解
回复

使用道具 举报

23

主题

48

帖子

0

精华

初级会员

Rank: 2

积分
121
金钱
121
注册时间
2019-3-27
在线时间
50 小时
 楼主| 发表于 2019-3-27 18:26:59 | 显示全部楼层
板子用的是探索者F4
回复

使用道具 举报

23

主题

48

帖子

0

精华

初级会员

Rank: 2

积分
121
金钱
121
注册时间
2019-3-27
在线时间
50 小时
 楼主| 发表于 2019-3-27 18:28:59 | 显示全部楼层
Wenmin 发表于 2019-3-27 18:26
板子用的是探索者F4

控制的一款产生电流的芯片。采用单线spi,只有时钟线,SDI和CS片选三根线。目的是通过改变写入的数据,改变电流输出值
回复

使用道具 举报

23

主题

48

帖子

0

精华

初级会员

Rank: 2

积分
121
金钱
121
注册时间
2019-3-27
在线时间
50 小时
 楼主| 发表于 2019-3-28 15:31:12 | 显示全部楼层
@原子哥 求助!!!!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-10 14:35

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表