2012-09-23 01:17 PM
I am having a strange issue. I am using FatFS and I have setup the SPI1 with
CS - PB14CK - PA5MISO - PA6MOSI - PA7When I just use the SD card interface, everything works well. I am getting the proper SPI signals and protocol. As soon as I add GPIO PE3 and enable it, then my SPI1 MISO signal goes all over. I even removed the SD card interface to see if MISO was staying High. And it does when the PE3 is not enable but as soon as PE3 is enabled, MISO turn to an output and generates all kind of signals on the line.I have attached the signal analysis pictures - One with PE3 on and without.Does anyone know whether this is a Bug inside the ST ?FatFS init-------------------------------------------------------static void
power_on (
void)
{
SPI_InitTypeDef SPI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable SPI & GPIO clocks */
SPI_GPIO_CLK(ENABLE);
SPI_PERIF_CLK(ENABLE);
for
(Timer1 =25
; Timer1; );/* Wait for 250ms */
/* Configure I/O for Flash Chip select */
GPIO_InitStructure.GPIO_Pin = SPIMMC_PIN_CS;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(SPIMMC_PORT_CS, &GPIO_InitStructure);
/* Deselect the Card: Chip Select high */
CS_HIGH();
/* Connect SPI pins to AF */
SPI_AF_SET();
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
/* SPI SCK pin configuration */
GPIO_InitStructure.GPIO_Pin = SPIMMC_PIN_SCK;
GPIO_Init(SPIMMC_PORT_SCK, &GPIO_InitStructure);
/* SPI MOSI pin configuration */
GPIO_InitStructure.GPIO_Pin = SPIMMC_PIN_MOSI;
GPIO_Init(SPIMMC_PORT_MOSI, &GPIO_InitStructure);
/* SPI MISO pin configuration */
GPIO_InitStructure.GPIO_Pin = SPIMMC_PIN_MISO;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(SPIMMC_PORT_MISO, &GPIO_InitStructure);
/* SPI_MMC configuration */
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
/* 84000kHz /256 = 328 < 400kHz */
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial =
7
;SPI_Init(SPIMMC, &SPI_InitStructure);
SPI_CalculateCRC(SPIMMC, DISABLE);
/* Enable SPIx */
SPIMMC->CR1 |= SPI_CR1_SPE;
/* drain SPI */
while
(!(SPIMMC->SR & SPI_I2S_FLAG_TXE)) { ; }SPIMMC->DR;
}
PE3 Init-------------void
init_PE3(void
){
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE , ENABLE);
/*-- GPIO Configuration ------------------------------------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOE, &GPIO_InitStructure);
}
2012-09-23 03:40 PM
The solution is somewhat obfuscated by the lack of defines, but I don't see any AF pin source configuration.
2014-05-19 07:30 AM