I have downloaded Keil and STM32 CUBEMX (Together with firmware library for my microcontroller).
I don't understand how do I put my c code to see what is really going on?
I tried connecting Keil with STM32 Cubemx when creatning new project, but when I go to device there is no STM32 Cube, what should I do?
You can't just drop a preexisting project into CubeMX and expect it to sort out what you're trying to do - CubeMX is a code generator for initialization of the hardware, and that's it.
To do what you're trying to do, you need to configure the peripherals as you'd like for your project in CubeMX, have CubeMX generate the project from that (CubeMX can generate projects for a variety of IDEs, including Keil), and then open that project in your IDE and edit in the specifics of your project as you'd like, starting from the generated main function.
Remember to only modify the parts of the generated files between the "USER CODE" comment lines, and not modify those comments if you think you'll ever want to change the project settings you set up in CubeMX - the generator uses those comments to ensure that it doesn't overwrite user code while regenerating the project.
I just want to add that now there is a STM32 Cube IDE which combines the MX with an IDE, so you can generate the code and go to the editor without any problem. No need to use Keil, or any other IDE
Related
I am currently working on a library that abstracts the use of a stm board (specifically the NUCLEO-H723ZG) and we are on the profiling phase. I did get to make the profiling with the SWV after a big headache with the SB26 bridge that comes with the aforementioned board, using the auto generated code from stm32cubeIDE.
Now i need to do the same but abstracting the auto generated code from the stm32cubeIDE into a method that does all the configuration for you, but i cannot pin point what is really missing. I already have copied the SystemClock config, the PeriphCommonClock config, both SCB_Enable Cache and the MPU_Config (and yes both are using the same copy of the ioc configuration). Any ideas of what i could be missing?
I tried to profile an autogenerated main.c and after some configuration it worked perfectly.
Then i tried to do the same with a main.cpp and copying the methods form the autogenerated main one by one (just to see whose were needed) and after copying them all it didn t work. The code executes and the live expressions work. The configurations are the same on the .ioc and the debugging.
I m now looking for the minimum necessary for an SWV configuration method, preferably non dependant from HAL.
This question already has answers here:
CMSIS & STM32, How to begin? [closed]
(2 answers)
Closed 1 year ago.
As I want to write an efficient program to use minimal RAM & Flash, I want to remove HAL library completely from my project & program only in registers.
I want to use cubeIDE for compiling & Debugging but I do not know how to remove HAL library from my project(It seems that HAL library created and attached to project by default when generating project).
Is there any practical way?
Best!
There is an option in STM32CubeIDE project generation which allows you to create empty projects.
The empty project comes with the following:
main.c : Mostly empty
syscalls.c : I don't know what it is for but probably useless.
sysmem.c : Implements _sbrk() function, which is used by malloc() & new()
startup_stm32[xxxxxxxx].s : Startup file in assembly. You can leave it as it is
[xxxxxx]_FLASH.ld : Linker script file. Most of the time, this can be left unchanged.
But you need some additional libraries & files.
CMSIS Library : This includes some core functions common to all Cortex M devices. The core library is header only, and it's the only one you need to get started. There are some additional CMSIS libraries, like the DSP library which you may need depending on your project requirements. I suggest downloading it from its official repository.
Official STM32 headers from ST : This is actually called STM32Cube[xx] (STM32CubeF4 for example) and includes the Cube & HAL framework you want to get rid off. But we're interested in CMSIS compliant device headers. You can delete the rest. It also includes a version of CMSIS which lags behind the official one. Since you can download the latest CMSIS from its official repository, you don't need the one included in Cube package. You can download the relevant package from ST. For example, this one is for F4 series.
Once you have the needed packages, you need to configure STM32CubeIDE such that your project uses the newly obtained libraries. Basically, you need to add some additional include directories and symbol definitions. And there is an additional system_stm32[xxxxx].c file, which can be found in STM32Cube package and needs to be included in your project.
Here you can find a somewhat related answer.
Here is an example STM32CubeIDE blinky project I've created for the Blue Pill board (STM32F103C8). It may be somewhat outdated but it's probably still useful.
The method I've described probably isn't very practical. Some people suggest creating a normal Cube & HAL project and than pruning the unused parts.
I have a project which is include STM32f4 HAL library and lots of code. And I have makefile for the this project.(Include gcc, g++)
I want to import my project into IAR Compiler. How can I do this without change my project. How can I convert it just by adding something on the project?
The STM32CubeMX code generation utility can generate IAR project files that work out of the box for your device. Manually adding your source file structure and custom settings (linker script, FPU etc) should be rather easy once you have that working minimal setup.
You will need to create a new project in IAR and add all the settings yourself. This is fairly straight forward and if you are not familiar with IAR it will help you learn. It is much simpler than makefiles. Of course IAR can work with makefiles as well but it is probably not the best place to start.
There will be a few compiler specific HAL files you will need to change (startup code). These are already in the STM32 HAL downloads.
I am working with STM32 B-L072Z-LRWAN1 discovery kit. How can I add I-CUBE-LRWAN libraries externally, after i have created a project on CubeMX for B-L072Z-LRWAN1 discovery kit. Because project which i have created have not radio libraries. I am coding with System Workbench.
Before this project, i used Ping-Pong example. It was divergent for create a fresh project. So i am trying to make a new project for Lora.
Thanks for answers.
I'm going to answer it from te point of view of a Keil project because that is the program wherein I've done it but these steps should be interchangeable with the IDE. It mostly involves copying the code and adding the right linker and source paths.
The I-CUBE-LRWAN project has been setup such as that the parts of the project have been separated. The root directory of the project consists of three folders: Middlewares, Projects and Drivers. These folders contain both .h and .c files inside their tree structure.
Drivers
The Drivers folder contains all the files related to the specific board you are using, the HAL (Hardware Abstraction Layer), CMSIS and the BSP (Board Support Package). The HAL and CMSIS provide a generalized interface towards the device and when using these creates code that can be ported to other STM32 platforms by changing out the CMSIS board specific definitions. I would recommend that when you create a project you tick the box to include all library files in your project. This will make compilation take longer and your project bigger but will also prevent you from fussing about with missing libraries. The BSP contains Board Specific interfaces for interfaces present on your platform. This includes LEDs and buttons on the L072Z-LRWAN1 and in case of the STM32l4 nucleo the joystick/LCD.
I would recommend that you copy your board specific BSP (.h and .c) into your project and use them as a standardized interface to board specific features. You should create a new BSP .h/.c pair when you are using a custom board.
Projects
The Projects contains your project specific code and contains the business end of your application. A bit of a bump in the road comes up here as ST has chosen to implement all their LoRaWAN code inside the main.c file. I would recommend that you take out all the LoRaWAN related initialization and transmission code (generally anything related to LoRaMainCallback_t) and put it inside a separate file with a defined interface. This is a bit of work but will pay dividend in the fact that your normal code has been separated from your LoRaWAN handling. I've stored my LoRaWAN code inside the file lorawan.<h|c>. With regard to the rest of the files: move the contents to a separate folders in your project called LoRaWAN/App/inc/ and LoRaWAN/App/src/. This pertains to the files: debug.c, hw_gpio.c, hw_rtc.c, hw_rtc.c, vcom.c, debug.h, hw.h, hw_conf.h, hw_gpio.h, hw_msp.h, hw_rtc.h, hw_spi.h, utilities_conf.h and vcom.h. Add the inc folder to your include path (the -I option) and the source files to your project.
Middlewares
The Middlewares folder needs to be copied from the source project to your target project and every inc folder or folder with .h files needs to be added to your include path and every source file needs to be added to your project. I would recommend that the folder structure is kept inside your IDE as to make your navigation between project and folder structure easier.
Another postive effect of keeping the folder structures similar is that upgrading your code with a newer stack should be easier as the files can be found in a somewhat same place in both projects.
Preprocessor defines
And a most important step. You need to take the DEFINE parameters defined inside the project and copy the into your own project. This can be found inside the Keil project (and the other projects also but in other places) under: options for target x->C/C++->define. It contains something akin to these values: STM32L072xx,USE_B_<board name>,USE_HAL_DRIVER,REGION_EU868,DEBUG,TRACE. As you can see I'm using: a Murata radio with integrated STM32, the EU 868 region and debugging and tracing options.
It should be possible to include "hw.h" and compile your program when you've done everything right.
I want to use Eclipse to develop code I will be uploading to my Atmega 2560 microcontroller. I could easily use the Arduino IDE to do this, but in my opinion, developing on Eclipse is a whole lot easier.
So, I followed this guide.
I get to the step where I have to add a programmer, but when I click on the Add button, nothing happens.
Does anyone have an idea as to what might be the problem?
The issue here is that 6.0.x series of avrdude uses a different configuration file which the avr-eclipse plugin is not able to parse. There is a ticket filed for this in the bug tracker in SourceForge.
A temporary solution would be to downgrade to avrdude 5.11.x.
Cheers.
I tried to use Eclipse for Arduino development and I followed this tutorial too but it didn't work for me. Also I couldn't find normal description of how I have to use it. From the other side so called Arduino IDE in my opinion isn't IDE it's very primitive buggy editor(looks like amateur product).
To upload my program to Atmega controller I decided to use avrdude direct from the console, where I specify programmer type and hex file that I want to upload. In this case I write program in c and use avrgcc toolchain for compiling and linking. However the question about IDE is still opened for me(the main problem for me that I don't know how to debug my code without IDE).
Also exist Atmel IDE AVrStudio. I didn'y try to use it, my I will mention it like a variant that you can try if you want.
Getting AVRDude (used by the AVR-ecplipse plugin) running on Windows with USB connected AVR programmers can be a real pain, often involving very specific driver uninstall/install sequences, such as those described at the bottom of this forum topic. I used to use Eclipse for my AVR programming, but have since moved to the new iteration of Atmel Studio. Version 6 is now available, and its relatively straight forward to get everything working well. There are a few things odd about it, but it has improved a lot since AS4.