2010-09-12 10:03 PM
STM32F103RCT6 SPI and TI ADS8325 ADC
#spi #spi #stm32-spi #stm32 #spi-problems-stm32 #spi-problems-stm32 #stm32-spi #stm-322011-05-17 05:06 AM
If you see the data on MISO, then it shouldn't really be related to ADC.
Wire MISO to MOSI. Do you get anything back then? Are CPOL, CPHA settings correct? SPI initialization code?2011-05-17 05:06 AM
Domen:
I have tried all 4 CPOL/CPHA combinations without luck. As for the SPI initialization code. Check the attached file if you would prefer to see it in context. Below is a brief explanation of what I believe are the relevant components. I started by setting up the clocks: RCC_PCLK2Config(RCC_HCLK_Div2); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_SPI1, ENABLE); Then I setup the GPIO pins: GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); Then I configure the peripheral: SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Rx; SPI_InitStructure.SPI_Mode = SPI_Mode_Master; SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b; SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Hard; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI1, &SPI_InitStructure); Then I enable hardware slave select (NSS): SPI_SSOutputCmd(SPI1, ENABLE); Finally, in a loop I enable the peripheral for just long enough to incite the ADC to send data and then I disable it. It's at this point that I expect data to appear in SPI1-DR but no luck. Dustin2011-05-17 05:06 AM
Does anyone know where to find a simple example of initializing the SPI?