SPI on STM32F1x

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
User avatar
toxygen
Posts: 24
Joined: Tue Mar 13, 2012 9:54 pm

SPI on STM32F1x

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SPI on STM32F1x

Post 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
goeck
Posts: 92
Joined: Mon Feb 11, 2013 12:00 pm

Re: SPI on STM32F1x

Post 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
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SPI on STM32F1x

Post 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
goeck
Posts: 92
Joined: Mon Feb 11, 2013 12:00 pm

Re: SPI on STM32F1x

Post by goeck »

Awesome, thanks again for the help, Giovanni!
Post Reply