Page 2 of 2
Re: Problem with SPI1 read on STM32F4
Posted: Sun Apr 20, 2014 5:44 pm
by xlh1460
I had a peek at board.h and changing that seems a bit daunting.
Shouldn't the pin configuration applied in my code be sufficient to override what is defined in board.h?
Re: Problem with SPI1 read on STM32F4
Posted: Sun Apr 20, 2014 7:45 pm
by xlh1460
On, second thought, it sounds like the problem might be with the pins that I am not using and noth with the ones that i am using.
I'll play with this some more.
Re: Problem with SPI1 read on STM32F4
Posted: Sun Apr 20, 2014 8:04 pm
by Giovanni
Hi,
You should not change board.h and board.c manually, in the ./cfg subdirectory there is a .chcfg file (XML), you can change it and then generate the board files using the generator tool included in ChibiStudio (select the .chcfg file and look in the toolbar, a button should appear there).
The .chcfg file has a schema guiding you if you use the Eclipse XML editor.
Giovanni
Re: Problem with SPI1 read on STM32F4
Posted: Sun Apr 20, 2014 8:44 pm
by xlh1460
You and mculover definitely nailed down the problem and pointed me in the right direction.
I didn't touch the board definition files but I changed my code slightly and now it works fine.
Code: Select all
palSetPadMode(GPIOA, 4, 0 );
palSetPadMode(GPIOA, 5, 0 );
palSetPadMode(GPIOA, 6, 0 );
palSetPadMode(GPIOA, 7, 0 );
palSetPadMode(GPIOB, 3, PAL_MODE_ALTERNATE(5) |
PAL_STM32_OSPEED_HIGHEST); /* New SCK. */
palSetPadMode(GPIOB, 4, PAL_MODE_ALTERNATE(5) |
PAL_STM32_OSPEED_HIGHEST); /* New MISO. */
palSetPadMode(GPIOB, 5, PAL_MODE_ALTERNATE(5) |
PAL_STM32_OSPEED_HIGHEST); /* New MOSI. */
palSetPadMode(GPIOA, 15, PAL_MODE_OUTPUT_PUSHPULL |
PAL_STM32_OSPEED_HIGHEST); /* New CS. */
palSetPad(GPIOA, 15);
spiStart(&SPID1, &spicfg);
I needed to "disconnect" the "standard" pins from the SPI peripheral.
This now loops back correctly, regardless of which set of pins I use on SPI1.
Thank you!
Re: Problem with SPI1 read on STM32F4
Posted: Sun Apr 20, 2014 9:22 pm
by Giovanni
I suggest to put the unused pins as "input with pull up", this will prevent noise and extra consumption.
Giovanni