现在用STM32F429II的SPI3驱动数码管,发现其MOSI输出引脚配置至PD6时无输出(AF功能),配置至PC12或者PB5时均可正常输出,GPIO_D的时钟也是配置了。现在程序中其它功能均已经取消,只有SPI3了,MOSI配置至PD6还是无法输出。由于PC12要用于SD卡,所以才把MOSI配置至PD6上,现确实有点摸不着头了,不知是否有哪位大吓有过类似的问题,请指教,谢谢。
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);//SPI3
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;//CLK
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_Init(GPIOC,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;//MOSI
GPIO_Init(GPIOD,&GPIO_InitStructure);
GPIO_PinAFConfig(GPIOC,GPIO_PinSource10,GPIO_AF_SPI3);//SPI3_CLK PC10
GPIO_PinAFConfig(GPIOD,GPIO_PinSource6,GPIO_AF_SPI3);//SPI3_MOSI PD6
NVIC_InitStructure.NVIC_IRQChannel = SPI3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
SPI_CalculateCRC(SPI3, DISABLE);
SPIConfigReg(SPI3);//,SPI_CPOL_Low);
SPI_ITConfig(SPI3,SPI_I2S_IT_RXNE,ENABLE);
SPI_Cmd(SPI3,ENABLE); |