cancel
Showing results for 
Search instead for 
Did you mean: 

STM32VLDISCOVERY SPI problems

roballen321
Associate
Posted on September 10, 2013 at 15:49

I'm using an STM32VL Discovery board and I'm trying to configure the SPI1 port to send data. I couldn't find any examples for this board, only for the F4 Discovery, so I'm a bit stuck. I've run the following code and put an oscilloscope on PA5,6,7 and can't see any data at all. I think the problem might be in re-mapping the port, as I can't find anyway or moving it from GPIO to SPI. Any help would be much appreciated.

#include ''stdio.h'' 
#include <
stm32f10x_spi.h
> 
#include <
stm32f10x_gpio.h
> 
#include <
stm32f10x_rcc.h
> 

int main(void) 
{ 
//Set up clocks 
RCC_APB2PeriphClockCmd(GPIOA, ENABLE); 
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); 
GPIO_InitTypeDef GPIO_InitStructure; 
//Attempt at port re-map, doesn't seem to help 
GPIO_PinRemapConfig(GPIO_Remap_SPI1, ENABLE); 
// Configure SPI_MASTER pins: SCK, MISO and MOSI // 
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; 
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 
GPIO_Init(PORT_SPI_COMMS, &GPIO_InitStructure); 
GPIO_InitTypeDef GPIO_InitStruct; 
GPIO_InitTypeDef gpio; 
//************************************************** 
SPI_InitTypeDef SPI_InitStructure; 
GPIO_InitTypeDef GPIO_InitStructure1; 
GPIO_StructInit (& GPIO_InitStructure1); 
SPI_StructInit (& SPI_InitStructure); 
//**************************************************** 
//Configure SPI1 master mode 
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_High; 
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; 
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; 
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64; 
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; 
SPI_InitStructure.SPI_CRCPolynomial = 7; 
SPI_Init(SPI1, &SPI_InitStructure); 
SPI_Cmd(SPI1, ENABLE); /* Enable the SPI */ 
while(1) 
{ 
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); 
SPI_I2S_SendData(SPI1, 0xFFFF); 
} 
} 

#32
0 REPLIES 0