Skip to main content
pic_micro
Associate III
January 10, 2015
Question

SPI PIN Configuration for STM32F0

  • January 10, 2015
  • 24 replies
  • 4155 views
Posted on January 10, 2015 at 10:14

Dear All,

I would be grate if any one could advice me that in which page the SPI pin configuration is showing in the ''RM0091Reference manual'' STM32F0

I mean,

What are the proper  Configure GPIO for MOSI, MISO and SCK pins.

What is the exact pin configuration 

in which page is showing above configuration

Thanks in advance

    This topic has been closed for replies.

    24 replies

    Tesla DeLorean
    Guru
    January 10, 2015
    Posted on January 10, 2015 at 14:54

    You'd configure them in AF mode, the direction of MOSI/MISO is determined by the Master or Slave configuration of the SPI.

    MOSI - Master Out - Slave In
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    pic_micro
    pic_microAuthor
    Associate III
    January 10, 2015
    Posted on January 10, 2015 at 19:42

    Dear Sir,

    Thanks for the reply After correct configuration of SPI1 Can I connect the MOSI pin to USART Level sifter input ( RX of MAX 232) Then can we see the SendData16 out put letter of SPI As per my program it is ( 0XFF)

    while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
    SPI_I2S_SendData16(SPI1,0XFF);

    Please advice
    Tesla DeLorean
    Guru
    January 10, 2015
    Posted on January 10, 2015 at 20:49

    I'm sure you can do a lot of things, you'll have to experiment and understand the signalling of RS232 vs SPI

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    pic_micro
    pic_microAuthor
    Associate III
    January 11, 2015
    Posted on January 11, 2015 at 05:57

    Dear Sir,

    Actually what I need to confirm that the SPI is working or not and the send data is outing from the MOSI pin of MCU, Event ought  the RS232 and SPI signal formats are  different, I am expecting what ever data will display on the PuTTy serial screen. I tested but nothing in display

    Please advice by word

    Please advice

    pic_micro
    pic_microAuthor
    Associate III
    January 11, 2015
    Posted on January 11, 2015 at 06:39

    Dear Sir,

    I connected MOSI pin to MISO by wire the configure following code then the system is working. My next experiment is connect the SD card to MCU Any advice

    void Send_Data(){
    while(1) { 
    while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
    SPI_I2S_SendData16(SPI1,'B');
    while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
    temp = SPI_I2S_ReceiveData16(SPI1);
    for(i=0;i<2;i++){
    while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
    USART_SendData(USART1, temp);

    }
    delay();
    }
    }

    PLEASE ADVICE
    pic_micro
    pic_microAuthor
    Associate III
    January 11, 2015
    Posted on January 11, 2015 at 13:02

    Dear Sir,

    I connected my SPI program to SD card (4GB Micro SD card inserted to big SD card socket )

    while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
    SPI_I2S_SendData16(SPI1,0x44);
    while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
    temp = SPI_I2S_ReceiveData16(SPI1);

    After sending data as above program ( sent data is 0x44) then I read the sd card using hex editor but hex editor does not show anything Please advice, Am I on correct track???
    Tesla DeLorean
    Guru
    January 11, 2015
    Posted on January 11, 2015 at 15:23

    After sending data as above program ( sent data is 0x44) then I read the sd card using hex editor but hex editor does not show anything. Please advice, Am I on correct track???

    The protocol for writing to blocks of data on the SD Card is significantly more complication than that.

    http://wiki.seabright.co.nz/wiki/SdCardProtocol.html

    http://alumni.cs.ucr.edu/~amitra/sdcard/Additional/sdcard_appnote_foust.pdf

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    pic_micro
    pic_microAuthor
    Associate III
    January 11, 2015
    Posted on January 11, 2015 at 15:36

    0690X00000602zZQAQ.jpg

    pic_micro
    pic_microAuthor
    Associate III
    January 11, 2015
    Posted on January 11, 2015 at 17:20

    Dear Sir.

    I found following youtube link how write to the SD card 

    https://www.youtube.com/watch?v=r9BafZi6Vpc

    I can use above method write to the SD card

    If Writing part such complicate, Can I have the advice for reading part using MCU

    Thanks in advance

    Tesla DeLorean
    Guru
    January 11, 2015
    Posted on January 11, 2015 at 17:56

    Look, it's a block access memory device, not a direct access memory (SRAM, NOR). Think of it like a hard drive.

    You need a driver to read/write to it using the command defined in the SD/MMC card specifications.

    STM32F0xx_StdPeriph_Lib_V1.4.0\Utilities\STM32_EVAL\STM320518_EVAL\stm320518_eval_spi_sd.c

    STM32F0xx_StdPeriph_Lib_V1.4.0\Utilities\STM32_EVAL\STM32072B_EVAL\stm32072b_eval_spi_sd.c

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..