STM32F103CB调试W25Q128时遇到的几个奇怪的问题

记录STM32调试W25Q128时遇到的问题

方便后续回顾及其他人有遇到相同问题时的一个参考

当前硬件配置

使用的是SPI1,PB5,PB4,PB3做SPI引脚,这里有做了REMAP操作

问题一、PB5,SPI_MOSI没检到波形

之前在别的线路板上面成功调试过W25Q128的读写操作,换上新的线路板之后,去读取0地址的固定长度地址,读回来的数据是0xFF,刚开始还以为是对的。
在做了写操作再回读时发现数据完全不对。用示波器检测各个管脚的波形,SPI_SCK波形正常,但SPI_MOSI没有检测到波形
反复检测配置确认没有问题,搜索找到原因
因为配置了硬件I2C1,而I2C1与SPI1 REMAP有冲突,导致SPI1工作不正常,触发BUG,官方给出的建议是两者不要一起用。
在禁用I2C1之后,SPI1波形恢复正常

问题二、PB3,SPI_CK没有检测到波形

因为需要重新适配STM32CUBEPROGRAMER的算法,需要在官方的参考程序上面进行修改,之前在目标板子上可以正常读写的操作
换了一个方式,操作结果又不对了,这次是SPI_SCK(PB3)没有产生波形,而之前不对PB5,SPI_MOSI竟然有波形产生
查了下数据表发现PB3默认是作为JTAG使用,需要将JTAG功能禁用掉
因为参考程序是标准库写的,起始时没有将JTAG功能禁用

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);

问题三、W25Q128第一次读取时值不对

调试期间,在操作时还发生了这样一个错误,就是W25Q128第一次读取时不对,后来数就正常了
第一次读出来是 0xff,再读一次数据就正常了
这是因为驱动写得有问题,SPI_CS管脚配置好之后要配高(即CS空闲时要为高),第一次配置管脚后,默认状态设为0,并没有拉高,导致第一次操作指令失效。

W25Q128FLASH的初始数值

读取前512字节,只针对两个IC作为的结论,这里只作为参考
这个数据格式表示的是FAT分区的格式头,说明W25Q128出厂前是有做过FAT文件读写的测试的

eb fe 90 4d 53 44 4f 53 35 2e 30 00 10 02 01 00 
01 00 02 00 10 f8 01 00 3f 00 ff 00 00 00 00 00 
00 00 00 00 80 00 29 00 00 00 00 4e 4f 20 4e 41 
4d 45 20 20 20 20 46 41 54 20 20 20 20 20 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa 

总结

STM32F103CB使用时占用较多的硬件管脚,导致触发硬件BUG。
同时针对W25Q128的时序,还存在使用的细节没注意

posted @ 2024-11-29 14:40  cau_par  阅读(58)  评论(0编辑  收藏  举报