2020-04-21 08:46 AM
I would like to be able to utilise code like this: https://github.com/ciastkolog/BMP280_STM32 on my Nucleo-L476RG. Is there an easy way to create a project and then import the source code or change the MCU type in the existing project?
Everything I try results in a new project with an MCU type I dont have.
I'm very new so please excuse my muppetry.
2020-04-21 07:52 PM
>Is there an easy way to create a project and then import the source code
Yep. Start with a project that works and just copy files over to it. Looks like the library you linked has only two real library files (bmp280.c/bmp280.h).
> or change the MCU type in the existing project?
This will vary in complexity depending on how different the two targets are. Are you trying to port the example for the STM32F0DISCO board onto your Nucleo-L476RG? If so, the linker script will the different. The CMSIS, HAL libraries, and startup code will differ as well. You'd have to update all of these. Probably some #defines as well
It's probably easier to take an existing project which runs on your board as the skeleton and move the core source/include files into that project.
2020-04-21 07:52 PM
> Everything I try results in a new project with an MCU type I dont have.
Why? Start up STM32CubeMX, chose the MCU you have, configure it, and hit generate code.
2020-04-22 12:17 AM
Thanks for the help.
I must be very stupid. I've copied a working project, then copied the two files into the new project. Compiling fails for a number of reasons but mainly due to the #include "stm32f0xx_hal.h" in the bmp280.h file, which is clearly irrelevant.
I can't find how to re-generate code.
I think I'll go back to Arduino.... :(
2020-04-22 06:16 AM
> Compiling fails for a number of reasons but mainly due to the #include "stm32f0xx_hal.h" in the bmp280.h file, which is clearly irrelevant.
Your chip has a "stm32l4xx.h" file instead that you should include. You're going to run into issues when porting code. Just need to tackle them one at a time.
Arduino definitely has a lower entry bar.
If this is your first project, maybe it'd be easier to look at examples in the STM32CubeL4 repository until you can get those up and running in the environment.