2008-09-14 11:29 AM
Problem with SPI1
2011-05-17 03:45 AM
Hi,
I am quite new to STM32 and I have a problem with SPI1. I have 2 boards with stm32 microcontrollers. On one board there is STM32F103RBT6, but on the other board STM32F103R6T6. So the problem. When I try to use SPI1 it doesn't work on both boards but the board with STM32F103RBT6 has 2 SPIs and SPI2 is working fine. That SPI1 stucks in while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE)==RESET);What is the problem? My SPI1 configs: GPIO_InitTypeDef GPIO_InitStructure; SPI_InitTypeDef SPI_InitStructure; /* GPIOA and GPIOC Periph clock enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); /* SPI1 Periph clock enable */ RCC_APB1PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); /* Configure SPI1 pins: SCK, MISO and MOSI */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Configure PA4 pin: CS pin */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); /* SPI1 Config */ SPI_I2S_DeInit(SPI1); 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_8; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI1, &SPI_InitStructure); /* SPI1 enable */ SPI_Cmd(SPI1, ENABLE); Thanks! Erik2011-05-17 03:45 AM
Both of your devices are, ''medium density'' - these do not support I2S flavor of SPI.
I note that you are using full-duplex - suggest that you temporarily use a simpler application - to see if you can first get it to work. um0427/FWLib/examples/SPI/Simplex_Interrupt/main.c Use this code which is simpler and see if this works. Note that you must #define SPI_Mode_Select so that I2S mode is not chosen. Give this a try [ This message was edited by: jj.sprague on 14-09-2008 23:57 ]2011-05-17 03:45 AM
These controllers are from 'Performance line'.
So what is the solution to this problem? I cannot find any other way to check this flag. Erik [ This message was edited by: erikszah on 14-09-2008 23:42 ]2011-05-17 03:45 AM
Please try my suggestion (edited in my earlier post). Good luck.