/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / ST32L152 - SPI2 - problem with MISO Pins

Username:     
Password:     
             

Forum

# 1   2013-04-29 06:58:59 ST32L152 - SPI2 - problem with MISO Pins

FreedOx
New member
Registered: 2013-04-16
Posts: 7

ST32L152 - SPI2 - problem with MISO Pins

Hello everyone,
I am using a Open4 STM32L152 and i want to use the SPI2 communication to link with a sensor.
I have managed to configure the MOSI & SCK & NSS pins but MISO still don't work.
The problem is when i configure the MISO pins to work in AF mode, the MISO pins is stuck at "1".
So i cant receive any value on my pins. just 0xFFFF.

   

Code:

//CONFIGURATION GPIO
                GPIO_StructInit(&GPIO_SPI_Init);
                GPIO_SPI_Init.GPIO_Pin = GPIO_Pin_MOSI | GPIO_Pin_MISO | GPIO_Pin_SCK;
    GPIO_SPI_Init.GPIO_Mode = GPIO_Mode_IN_AF;
    GPIO_SPI_Init.GPIO_OType = GPIO_OType_PP;
    GPIO_SPI_Init.GPIO_PuPd = GPIO_PuPd_UP;
    GPIO_SPI_Init.GPIO_Speed = GPIO_Speed_40MHz;
    GPIO_Init(GPIOB,&GPIO_SPI_Init);                 


    GPIO_PinAFConfig(GPIOB,GPIO_PinSource_MOSI,GPIO_AF_SPI2);
    GPIO_PinAFConfig(GPIOB,GPIO_PinSource_SCK,GPIO_AF_SPI2);
    GPIO_PinAFConfig(GPIOB,GPIO_PinSource_MISO,GPIO_AF_SPI2);
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);

//CHOIX DU SPI
    IS_SPI_ALL_PERIPH(SPI2);
    

    SPI_SSOutputCmd(SPI2, ENABLE);
    
    //INITIALISATION DE LA STRUCTURE
    SPI_StructInit(&SPI2_Init);
    
    
    //CONFIGURATION SPI :
    
    SPI2_Init.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
    SPI2_Init.SPI_Mode = SPI_Mode_Master;
    SPI2_Init.SPI_DataSize = SPI_DataSize_16b;
    SPI2_Init.SPI_CPOL = SPI_CPOL_High;
    SPI2_Init.SPI_CPHA = SPI_CPHA_2Edge;
    SPI2_Init.SPI_NSS = SPI_NSS_Soft;
    SPI2_Init.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
    SPI2_Init.SPI_FirstBit = SPI_FirstBit_MSB;
    SPI2_Init.SPI_CRCPolynomial = 0;

The problem occur when i enter this command .


   

Code:

GPIO_PinAFConfig(GPIOB,GPIO_PinSource_MISO,GPIO_AF_SPI2);

When i enter in mode AF, the pin pass from 0 to 1 and stay stucked to 1 ...
MOSI and SCK pins work properly. i can see data pass throught it.


For informations :
-I program on Circle APP, maybe there is an option who conflict MISO pins...
-I HAVE ALREADY TRIED TO CHANGE PULL UP/OPEN DRAIN MODE
-I HAVE ALREADY TRIED TO PUT MISO ON INPUT MODE
-I DO NOT HAVE THE GPIO_MODE_IN_FLOATING THAT WE CAN SEE IN ANOTHER CASE. ( i use std stm32lxx library)

Thanks for your comprehension amd for your time if youre reading me...
Frederic TOMAS

Offline

 

# 2   2013-04-29 07:41:39 ST32L152 - SPI2 - problem with MISO Pins

FreedOx
New member
Registered: 2013-04-16
Posts: 7

Re: ST32L152 - SPI2 - problem with MISO Pins

My bad, the command

Code:

  GPIO_SPI_Init.GPIO_Mode = GPIO_Mode_IN_AF;

is actually

Code:

  GPIO_SPI_Init.GPIO_Mode = GPIO_Mode_AF;

Just for your comprehension

Offline

 

# 3   2013-04-29 15:00:28 ST32L152 - SPI2 - problem with MISO Pins

FreedOx
New member
Registered: 2013-04-16
Posts: 7

Re: ST32L152 - SPI2 - problem with MISO Pins

Problem Solved ...
Was the welds ...
I have tested with another CI and it work fine.
So, you can take my Code if you want to program SPI2 on STM32L152VBT6

Offline

 

Board footer