完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在调试STM32F103和STM32F030的SPI时,发现原来的MISO配置不同,
STM32F103: /**SPI1 GPIO Configuration PA5 ------> SPI1_SCK PA6 ------> SPI1_MISO PA7 ------> SPI1_MOSI */ GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_6; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); STM32F030: /**SPI1 GPIO Configuration PA5 ------> SPI1_SCK PA6 ------> SPI1_MISO PA7 ------> SPI1_MOSI */ GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = GPIO_AF0_SPI1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 其中区别在于, F103的MISO要配置成输入(GPIO_MODE_INPUT), 而F030的要配置成复用(GPIO_MODE_AF_PP),的确非常奇怪。后来查询RM得知,F103的配置是: CNFy[1:0]: Port x configuration bits (y= 0 .. 7) These bits are written by software to configure the corresponding I/O port. Refer to Table 20: Port bit configuration table. In input mode (MODE[1:0]=00): 00: Analog mode 01: Floating input (reset state) 10: Input with pull-up / pull-down 11: Reserved In output mode (MODE[1:0] > 00): 00: General purpose output push-pull 01: General purpose output Open-drain 10: Alternate function output Push-pull 11: Alternate function output Open-drain Bits 29:28, 25:24, 21:20, 17:16, 13:12, 9:8, 5:4, 1:0 MODEy[1:0]: Port x mode bits (y= 0 .. 7) These bits are written by software to configure the corresponding I/O port. Refer to Table 20: Port bit configuration table. 00: Input mode (reset state) 01: Output mode, max speed 10 MHz. 10: Output mode, max speed 2 MHz. 11: Output mode, max speed 50 MHz. F030的定义是: Bits 2y+1:2y MODERy[1:0]: Port x configuration bits (y = 0..15) These bits are written by software to configure the I/O mode. 00: Input mode (reset state) 01: General purpose output mode 10: Alternate function mode 11: Analog mode 可以查看,两个片子的识别定义不同所以,配置当然也不同了。 再查询手册的UART RX定义,也有同样的不同。 再用兆易GD32F103替代STM32F103时,发现GD的定义与STM相同,但是MISO必须改为GPIO_MODE_AF_PP才能正常接收,否则 SPI 可以发送,接收错误。 这里表示是 GD 的缺陷,待确认。 |
|
|
|
只有小组成员才能发言,加入小组>>
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
528 浏览 2 评论
550 浏览 2 评论
信号发生器产生的正弦频率信号,用定时器进行捕获,当幅值低于3V后为什么MCU就无法捕获到了?
209 浏览 2 评论
875 浏览 2 评论
编码器模式下,中断内访问其他定时器cnt值,会导致进入中断次数丢失的原因?
859 浏览 2 评论
1331浏览 9评论
STM32出现error downloading following files怎么解决?
28浏览 3评论
stm32f103的RST复位后PWM就停止输出了,为什么?
37浏览 3评论
STM32G0空闲中断异常,且DMA接收不到数据是怎么回事?
24浏览 3评论
STM32F103用Timer3TRGO通道触发ADC,ADC在三路输出PWM高电平中间点采样,如何配置?
15浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-3-28 22:58 , Processed in 0.636277 second(s), Total 73, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 深圳华秋电子有限公司
电子发烧友 (电路图) 粤公网安备 44030402000349 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号