在调试207的SPI过程中遇到了一个奇怪的问题,求助于各位大侠了 在调试过程中发现,stm32f207的SPI口中所有的输入口好像都不工作,输出口工作正常,不知道什么原因 SPI口配置代码如下: GPIO_InitTypeDef GPIO_InitStructure; SPI_InitTypeDef SPI_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE); GPIO_PinAFConfig(GPIOA,GPIO_PinSource5,GPIO_AF_SPI1); GPIO_PinAFConfig(GPIOA,GPIO_PinSource6,GPIO_AF_SPI1); GPIO_PinAFConfig(GPIOA,GPIO_PinSource7,GPIO_AF_SPI1); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType =GPIO_OType_PP; GPIO_InitStructure.GPIO_Pin = IO_PIN_BUS_CS; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz; GPIO_Init(IO_PORT_BUS_CS,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType =GPIO_OType_PP; GPIO_InitStructure.GPIO_Pin = IO_PIN_BUS_MISO; GPIO_Init(IO_PORT_BUS_MISO,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Pin = IO_PIN_BUS_SCK; GPIO_Init(IO_PORT_BUS_SCK,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = IO_PIN_BUS_MOSI; GPIO_Init(IO_PORT_BUS_MOSI,&GPIO_InitStructure); SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256; SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; SPI_InitStructure.SPI_CRCPolynomial = 0; SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b; SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_Mode = SPI_Mode_Slave; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; SPI_Init(SPI1, &SPI_InitStructure); SPI_CalculateCRC(SPI1, DISABLE); NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel = SPI1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0 ; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2 ; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); wvSpiItEnable(); SPI_Cmd(SPI1,ENABLE); 期待得到答案,重复问题:spi口的输入性质的口好像都不工作,时钟和输入口都没工作 ,望高手帮我看看,期待。。。。。。 |
STM32F207+LWIP的网络丢包问题! 【悬赏问答】
STM32F207+DP83848+RTL8019可不可以实现双网口设计
深圳市旺宝电子STM32F207开发板例程集
STM32F2 器件 -25° 上电正常 复位就挂了
STM32F229 TIMER CNT问题
哪位工程师有STM32F2xx的寄存器手册?
STM32F2xx RTC启动不了,求助!!!!
STM32F2外部按键触发中断问题
STM32F205 低功耗模式有BUG?
STM32F207 两个ADC同时采样问题
RE:STM32F207的SPI配置问题!!!!!!!!
回复:STM32F207的SPI配置问题!!!!!!!!
SPI的时钟开启了吗?需要你在配置的时候打开。
在代码的第三行就开启了,谢谢你的回答,问题还是没找到。
RE:STM32F207的SPI配置问题!!!!!!!!
回复:STM32F207的SPI配置问题!!!!!!!!
看不到你的IO口的配置,你能把IO_PIN_BUS_CS这些定义写出来吗?
GPIO_InitTypeDef GPIO_InitStructure;
SPI_InitTypeDef SPI_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE);
GPIO_PinAFConfig(GPIOA,GPIO_PinSource5,GPIO_AF_SPI1);
GPIO_PinAFConfig(GPIOA,GPIO_PinSource6,GPIO_AF_SPI1);
GPIO_PinAFConfig(GPIOA,GPIO_PinSource7,GPIO_AF_SPI1);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType =GPIO_OType_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType =GPIO_OType_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_Init(GPIOA,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_Init(GPIOA,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_Init(GPIOA,&GPIO_InitStructure);
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
SPI_InitStructure.SPI_CRCPolynomial = 0;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b;
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_Mode = SPI_Mode_Slave;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_Init(SPI1, &SPI_InitStructure);
SPI_CalculateCRC(SPI1, DISABLE);
NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel = SPI1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0 ;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2 ;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_RXNE, ENABLE);
SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_ERR, ENABLE);
SPI_Cmd(SPI1,ENABLE);
谢谢管理员不辞辛苦的回答,非常感谢!
回复:STM32F207的SPI配置问题!!!!!!!!
看不到你的IO口的配置,你能把IO_PIN_BUS_CS这些定义写出来吗?
忘了说了,这个IO_PIN_BUS_CS,即NSS引脚,我没有复用,只是当做普通IO口使用的。谢谢
RE:STM32F207的SPI配置问题!!!!!!!!
RE:STM32F207的SPI配置问题!!!!!!!!
回复:STM32F207的SPI配置问题!!!!!!!!
请问楼主,哪里没设置对,我也遇见这个问题了,很急