2023-09-29 11:13 PM
Hi, I have been using PWM with DMA in one project with register-level programming, there i could find the RAM usage was around 28% and the ROM usage was hardly 0.5%. The similar application project when i tried with using HAL API's, I found the RAM usage was 6% and ROM usage was 3%. So i don't understand how there is so much difference when i use HAL over register level programming. At the same time using more of RAM is better or utilization of ROM is better?
Solved! Go to Solution.
2023-10-02 08:01 PM
> Also as you said register level uses less memory compared to HAL, that is true in case of ROM, but just not in case of RAM.
The map file can help you determine what is taking up space. Register-level coding doesn't use more RAM than HAL for the same code functionality. The size of buffers certainly doesn't change between the two.
> So what should be the solution for having larger dynamic buffer sizes in the code as they are going to be a part of RAM only and not ROM.
No magic solution here. You have a fixed amount of RAM, divvy it up however you need. If you need more, consider external SDRAM or similar for storage.
2023-09-30 06:58 AM
Generally, using ROM is preferable since you have more of it, but it doesn't really matter as long as you have sufficient resources.
Using register-level programming should use less RAM and ROM than using HAL. If it's not, you're doing something very differently. Probably you have a large DMA array declared which isn't in or doesn't match the size in the HAL version.
2023-09-30 08:01 AM - edited 2023-09-30 08:01 AM
While we can play the guess game, this is also an opportunity for you to learn how to find out where the memories go: have a look at the mapfile.
I often do projects where it's not clear beforehand how much resources would there be needed. In that case, I usually opt to spend FLASH and spare RAM, because as @TDK said above, RAM is a more scarce thus precious resource in mcus.
JW
2023-10-02 07:47 PM - edited 2023-10-02 07:49 PM
Yep, i am using large DMA buffer size, roughly 226 * 3 (bytes). Also as you said register level uses less memory compared to HAL, that is true in case of ROM, but just not in case of RAM. So what should be the solution for having larger dynamic buffer sizes in the code as they are going to be a part of RAM only and not ROM.
Please do share some insights on this: @waclawek.jan.
2023-10-02 08:01 PM
> Also as you said register level uses less memory compared to HAL, that is true in case of ROM, but just not in case of RAM.
The map file can help you determine what is taking up space. Register-level coding doesn't use more RAM than HAL for the same code functionality. The size of buffers certainly doesn't change between the two.
> So what should be the solution for having larger dynamic buffer sizes in the code as they are going to be a part of RAM only and not ROM.
No magic solution here. You have a fixed amount of RAM, divvy it up however you need. If you need more, consider external SDRAM or similar for storage.
2023-10-02 09:54 PM
Hey, just looking for some heads up, where exactly can i find my memory map file?
2023-10-03 12:26 AM
This is toolchain-dependent; if you use some kind of IDE, surely documentation to that IDE will tell you. You may also need to tick some tickbox for the mapfile to be generated; again, toolchain-dependent.
JW
2023-10-03 07:10 AM - edited 2023-10-03 07:11 AM
In STM32CubeIDE, it's in the same directory as the output ELF file, but with a MAP extension. It is created as part of the compilation process. It is a text file and can be viewed in a text viewer of your choice.