Skip to main content
Visitor II
March 2, 2009
Question

SPI Slave to Master

  • March 2, 2009
  • 17 replies
  • 2624 views
Posted on March 02, 2009 at 04:45

SPI Slave to Master

    This topic has been closed for replies.

    17 replies

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:32

    hi

    the problem can be solved by using the configuration as given by cofor

    GPIO_DeInit(GPIO2);

    GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;

    GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;

    GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ;

    GPIO_Init (GPIO2, &GPIO_InitStructure);

    GPIO_DeInit(GPIO3);

    GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;

    GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;

    GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;

    GPIO_Init (GPIO3, &GPIO_InitStructure);

    The important thing here is to disable the IPConnected for the outputs - nss, mosi, clk

    GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;

    and enable IPC for Miso

    GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;

    Gilbert try the above code and reply when it works.

    bye,

    vik

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:32

    Hi all,

    I too face the same problem. The transmitted data goes correctly but the received data is the same as transmitted data.

    People hav recommended that nss pin be pulled high. but there is no place to do that now in my board. can anyone help me out.

    thanks in advance,

    vik

    (ST guys should actually include this in their errata) :|

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:32

    Thanks a lot. I did like descibed and now it works very nice:)

    [ This message was edited by: gilbertf on 31-03-2007 10:46 ]

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:32

    Hi

    If anyone is having code for flash M25P64 communication STR910.

    Please let me know.

    Please find my attached code. I am not able to read or write into flash.

    I can read Flash ID succesfully.

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:32

    hi!

    I WAS FACING THE SAME ERROR, THANKS FOR THE HELP IN SOLVING BY WRITING THE SOLUTIONS.

    I HAVE PULLED UP THE NSS PIN AND DISABLED THE IP FOR PINS OTHER THEN MISO.

    THANKS....

    //MISO

    GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;//

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

    GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;

    GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;

    GPIO_Init (GPIO5, &GPIO_InitStructure);

    //MOSI, SCLK & NSS

    GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7;

    GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;

    GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;

    GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2;

    GPIO_Init (GPIO5, &GPIO_InitStructure);

    [ This message was edited by: satnam.singh on 01-05-2008 15:09 ]

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:32

    It is possible to use SSP0 in Master mode without the need for external pull up on NSS and just using the four SSP pins MISO MOSI SCLK and NSS.

    Configure the NSS pin to be a general purpose output and drive it through software to provide the chip select output.

    e.g. For SSP0 on port 2

    /* Gonfigure SSP0_CLK and SSP0_MOSI */

    GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

    GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2;

    GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;

    GPIO_Init(GPIO2, &GPIO_InitStructure);

    /* Gonfigure SSP0_NSS pin as general purpose I/O */

    GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

    GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;

    GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;

    GPIO_Init(GPIO2, &GPIO_InitStructure);

    /* Gonfigure SSP0_MISO pin GPIO2.6 */

    GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

    GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;

    GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ;

    GPIO_Init(GPIO2, &GPIO_InitStructure);

    Simply set P2_6 low before any read/write and set it high when the data transfer is complete.

    I hope this helps

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:32

    Hi Dave, I am having a problem that is the MISO signal is not received and after checking with the oscilloscope I realize that the line is always ''1'', so I guess I have some king of problem with the MISO pin definition. Regarding your tip, what do you mean with your last line:

    ''Simply set P2_6 low before any read/write and set it high when the data transfer is complete.''

    As far as I can see 2.6 is an input, how should I do that?

    Thanks a lot.