7 years, 11 months ago.

STM32L4 Discover Accelerometer SPI access PinMap help needed

I like to access the accelerometer MEMS (LSM303CTR) via SPI and get the “mbed” error “pinmap not found for peripheral”. I use the following code:

    new SPI(PD_4, PD_3, PD_1); // mosi, miso, sck

I looked already into TARGET_DISCO_L476VG/PeripheralPins.c and cannot find the above pins in the SPI PinMap file. I looked up the pins from the Disco schematics.

Are the SPI pins wrong for the LSM303CTR, any ideas?

I investigated into this further, I found an STM mbed sample project (BSP_DISCO_L476VG) for the STM32L4 Discovery board, this supports the accelerometer. My use of the mosi, miso, sck pins is correct, however the sample is using STM low-level HAL drivers instead of the mbed SPI API.

This is very bad because I like to use the “mbed” API. I still believe that the described SPI ports PD_4, PD_3, PD_1 are missing in the mbed configuration.

posted by Helmut Tschemernjak 16 May 2016

Finally I verified that the PINS are missing in the mbed PIN lookup configuration. I still feel that this is a bug because all MCU pins should be available in mbed to allow developing via mbed for own boards. I close this questions.

posted by Helmut Tschemernjak 18 May 2016

1 Answer

7 years, 11 months ago.

Hi Helmut.

1) Which target board are you using for this testing ? Be sure that you have imported the proper target board for your project as this is very important for the labels you will use for the SPI interface.

2) Assuming you have the STM32L4 based board (linked to your username), then this landing page should help:

NUCLEO-L476RG https://developer.mbed.org/platforms/ST-Nucleo-L476RG/

Only the labels written in blue/white or green/white (i.e. PA_4, PB_5, A0, D14, LED1...) must be used in your code.

If the target board is not the same as yours then search for the proper PLATFORM to import the correct matching dev board.

3) Next, is the MEMS (LSM303CTR) onboard this target board or do you have an external PCB with this MEMS sensor ?

Either way, you must review the schematics for the proper target board to confirm if the SPI interface pins are in use with onboard peripherals or can be used by your project.

Hope this helps.

Thank you Sanjiv , I am using the STM STM32L4 Discovery board, the chip is included on the disco board. I investigate into it further.

posted by Helmut Tschemernjak 16 May 2016