cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Problem in STM32F215

thirukannan
Associate II
Posted on June 28, 2014 at 17:42

Hi,

I have written code for configuration and Data_send for SPI in stm32f215 like below mentioned code. I have monitor the  clk,data,CS while running using CRO, i am getting CLK,Data but not getting CS. What is the problem please clear me.

Below is code.

int main()

{

SPI_Config();

while()

{

SPI_I2S_SendData( SPI1, 0x55);

}

}

static void SPI_Config(void)

{

    GPIO_InitTypeDef GPIO_InitStructure;

    NVIC_InitTypeDef NVIC_InitStructure;

    /* Peripheral Clock Enable -------------------------------------------------*/

    /* Enable the SPI clock */

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);

    /* Enable GPIO clocks */

    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

    /* SPI GPIO Configuration --------------------------------------------------*/

    /* Connect SPI pins to AF5 */  

    GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_SPI1);

    GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_SPI1);

    GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_SPI1);

    GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_SPI1);

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

    GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_DOWN;

    /* SPI SCK pin configuration */

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;

    GPIO_Init(GPIOA, &GPIO_InitStructure);

    /* SPI  MOSI pin configuration */

    GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_5;

    GPIO_Init(GPIOA, &GPIO_InitStructure);

    /* SPI SCK pin configuration */

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

    GPIO_Init(GPIOA, &GPIO_InitStructure);

    /* SPI  MOSI pin configuration */

    GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_7;

    GPIO_Init(GPIOA, &GPIO_InitStructure);

    /* SPI configuration -------------------------------------------------------*/

    SPI_I2S_DeInit(SPI1);

    SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;

    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_2;

    SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;

    SPI_InitStructure.SPI_CRCPolynomial = 7;

    /* Configure the Priority Group to 1 bit */                

    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);

    /* Configure the SPI interrupt priority */

    NVIC_InitStructure.NVIC_IRQChannel = SPI1_IRQn;

    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;

    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    NVIC_Init(&NVIC_InitStructure);

    SPI_InitStructure.SPI_Mode = SPI_Mode_Master;

    SPI_Init(SPI1, &SPI_InitStructure);

    /* The Data transfer is performed in the SPI interrupt routine */

    /* Enable the SPI peripheral */

    SPI_Cmd(SPI1, ENABLE);

}

Regards,

Thirukkannan.P

1 REPLY 1
Posted on June 28, 2014 at 18:31

Probably not a SOFT control of CS then? Doesn't that imply it's a GPIO?

The loop should also wait on TXE before jamming data out.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..