2012-05-23 02:52 AM
Hi,
I am trying to use the OLIMEX STM32-P103 (ARM cortex M3) as SPI master to get some information from an accelerometer but, I dont know how to use SPI. Even after many hours of searching on the internet i did not found any examples or tutorial. Can someone help me by giving me links or explaining me? Thanks PS: I am using IAR workbench for ARM. Please excuse me for my bad english. #spi-stm32f1032012-05-23 04:55 AM
How about the examples in the various firmware libraries?
STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\SPI\*2012-05-23 05:54 AM
Thank for your responce,
I found one in the IAR example but with the STM3210E name (in STM32F10x\stm32f10x_stdperiph_lib\Project\STM32F10x_StdPeriph_Examples\SPI\FullDuplex_SoftNSS) and when I program it on the chip it does not work. Which firmware library are you speaking about? Where can I find it?2012-05-23 06:10 AM
Sure it can't work.
You need to take it as an example, and use it as a template for your project. The I2C interface might not be the same, i.e. might use other pins. There might be other differences between this two boards.2012-05-23 06:34 AM
Yes, the
example
helped me
understand how
todeclare the
SPI
but
not
how to use
itor assign
pins
.2012-05-23 07:54 AM
I guess you can't circumvent comparing the schematics of both boards.
If they use the same SPI interface, i.e. the same pins, you don't need to change the initialization. Otherwise you will need to change your project to match your layout. Locate where the initializations are done, and change accordingly. > Yes, theexample
helped me
understand how
todeclare the
SPI
but
not
how to use
itor assign
pins
. I don't know the code you speak of. A peripheral initialization requires several consecutive steps, which are not necessarily done in one place (one function.). It shouldn't be too difficult to find out.2012-05-23 08:26 AM
I have compared
the two
boards
and
find
thatthe pins are,
in fact,
different
.And I
still do not understand
,even
after
searching
in the code
,how to change
the pins used
. The main.c program in attached. ________________ Attachments : main.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I008&d=%2Fa%2F0X0000000bRy%2FwueX7qNoj9ng0bSvOrGX0bmz6xv5YU0Bk4mJTsIxGQw&asPdf=false2012-05-23 12:43 PM
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
#ifdef USE_STM3210C_EVAL
/* Enable SPI3 Pins Software Remapping */
GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);
#endif
/* Configure SPIy pins: SCK, MISO and MOSI */
GPIO_InitStructure.GPIO_Pin = SPIy_PIN_SCK | SPIy_PIN_MISO | SPIy_PIN_MOSI;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(SPIy_GPIO, &GPIO_InitStructure);
/* Configure SPIz pins: SCK, MISO and MOSI */
GPIO_InitStructure.GPIO_Pin = SPIz_PIN_SCK | SPIz_PIN_MISO | SPIz_PIN_MOSI;
GPIO_Init(SPIz_GPIO, &GPIO_InitStructure);
}
This
SPIy
and
SPIz
definitions are somewhere else, and the pin definitions too :
SPIy_PIN_SCK, SPIy_PIN_MISO, SPIy_PIN_MOSI
#ifdef USE_STM3210C_EVAL
/* Enable SPI3 Pins Software Remapping */
GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);
#endif
Seems all a little bit hidden, but follow this mentioned #defines
.
SPIy
and
SPIz
are somewhere mapped to
SPI1
,
SPI3
or
SPI3.
2012-05-24 12:57 AM
Ok,
I will look for
that and I
'll inform you
of my
progress
. An other question : Do you know where I can found the peripheral libraries for STM32F103 (in PDF), I did not found it yet. Thank you.2012-05-24 04:14 AM
On the STM32F1 page fund there
http://
click on any STM32F10x device in the list (scroll down...). This opens another Tab in your browser (usually), displaying available resurces for the selected part. Select the ''Design support'' tab on this page, and scroll down. The standard peripheral lib is there in the list, and is the same for all F10x parts. Don't ask me why it's missing in the STM32F1 overview page, and you need to select a part first...