AnsweredAssumed Answered

STM32f10x - SPI not sending data

Question asked by mahi on Feb 24, 2012
Latest reply on Feb 25, 2012 by Clive One
please correct my code.
what is missing in that.....clarify...

#include "stm32f10x_lib.h"
void RCC_Configuration(void);
void GPIO_Configuration(void);
void SPI_Configuration(void);
ErrorStatus HSEStartUpStatus;
int main(void)
{
     
    RCC_Configuration();
    GPIO_Configuration();
    SPI_Configuration();
    SPI_Cmd(SPI1, ENABLE);
    while(1)
    {
        SPI_I2S_SendData(SPI1, 0x01);
        SPI_I2S_SendData(SPI1, 0x03);
    }
 }
void RCC_Configuration(void)
{
       
        RCC_DeInit();
        RCC_HSEConfig(RCC_HSE_ON);
        HSEStartUpStatus=RCC_WaitForHSEStartUp();
        if(HSEStartUpStatus == SUCCESS)
        {
                 RCC_HCLKConfig(RCC_SYSCLK_Div1);
                 RCC_PCLK2Config(RCC_HCLK_Div2);
                 RCC_PCLK1Config(RCC_HCLK_Div2);
                 RCC_PLLConfig(0x00010000, RCC_PLLMul_9);
                 RCC_PLLCmd(ENABLE);
                 while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {}
                 RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
                 while (RCC_GetSYSCLKSource() != 0x08) {}
        }
         
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA |  RCC_APB2Periph_SPI1, ENABLE);
 
 
}
void GPIO_Configuration(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF_PP;
    GPIO_Init(GPIOA, &GPIO_InitStructure);
     
 
 
}
void SPI_Configuration(void)
{
     SPI_InitTypeDef SPI_InitStructure;
     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_1Edge;
     SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
     SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
     SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_LSB;
     SPI_Init(SPI1, &SPI_InitStructure);
 
 
}

Outcomes