Page 1 of 1

SPI on STM32F1x

Posted: Wed Nov 27, 2013 12:20 am
by toxygen
Hello,
by looking at the example board config (olimex p107), I can see that spi miso and mosi are configured as follows:

Code: Select all

 * PC11 - Input with PU     (SPI3 MISO).
 * PC12 - Alternate output  (SPI3 MOSI).


however, when looking in testhal/STM32F1xx/SPI/main.c I see the following commands:

Code: Select all

 palSetPadMode(IOPORT1, 6, PAL_MODE_STM32_ALTERNATE_PUSHPULL);     /* MISO.*/
palSetPadMode(IOPORT1, 7, PAL_MODE_STM32_ALTERNATE_PUSHPULL);     /* MOSI.*/


I'm using the 2.6.1 release. Can you please clarify which config is correct? I suppose the one with digital input, but I would rather have it confirmed.

Re: SPI on STM32F1x

Posted: Wed Nov 27, 2013 9:18 am
by Giovanni
HI,

The one with digital input is correct, it is possible that the one with alternate is working too, I have to verify.

Giovanni

Re: SPI on STM32F1x

Posted: Mon Feb 03, 2014 5:56 pm
by goeck
Hey,

just a short question on this. I want to use PA8 as MCO pin on my STM32F0-Discovery, so I set up everything but had to alter definitions in my board.h. All works.
I now just want to leave bord.h as is from repository and set up in an init funtion in main(). So I use

Code: Select all

palSetPadMode(GPIOA, 8, PAL_MODE_STM32_ALTERNATE_PUSHPULL);   
but the compiler telles me function is not defined.
Can't I chnage pin behaviour this deep after board init?

Cheers
Stefan

Re: SPI on STM32F1x

Posted: Mon Feb 03, 2014 6:33 pm
by Giovanni
Is it an F0 or an F1? that line works for the F1 only which has the old GPIO unit. For all the other STM32s it is:

palSetPadMode(GPIOA, 8, PAL_MODE_ALTERNATE(N));

Where N is the number of the alternate function, see the data sheet.

Giovanni

Re: SPI on STM32F1x

Posted: Tue Feb 04, 2014 8:43 am
by goeck
Awesome, thanks again for the help, Giovanni!