We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
For the STM32F4xxx line of CPUs
I use a single assembly module for startup, but this module may be used for different CPUs of the family.Since some micros have more memory than others, I need to set the Heap_Size differently depending on the CPU defined in the project "Target Device".I tried this:
IF :DEF: STM32F427_437xxHeap_Size EQU value1ELSEHeap_Size EQU value2ENDIF
However the first option is never taken even though I selected the target device correctly.I have a similar construction in the C code and it works, but seems the macro name "STM32F427_437xx" (or any) is no defined for assembly.
The idea is to make this as transparent as possible, I know I can add my own built compile option to define a name and use it but others would need to remember to change it every time and why would this be needed when Keil already knows the target device?
Any idea how to solve this? I guess if keil defines a macro automatically for C then it should do it also for assembler.
Thank
Hello
I have asked this question of Keil engineering and they say currently the device specific information is not provided to the assembler by uVision - only the compiler as you are aware.
However, they will examine and consider this as a potential addition to a future version of uVision.
Until then, you will have to manually add such a selection to your assembler selections.
Thanks
Bob Boys
I find this a very good and constructive question.
I have a few suggestions:
1: If you can, try using the assembler with the C Pre-Processor. This is possible if using a GNU toolchain, I do not know if it's possible with Keil.
2: In your C-code, write a small function / subroutine, which contains inline-assembly. The inline-assembly could use an #if defined(...) wrapper, in order to select the correct microcontroller.
3: If you allow it to become a run-time-check, you could try setting up a temporary exception vector that will catch any hardware errors (this would probably be HardFault), then do the following:
A: Set previously tested address = NULL.
B: Save previously tested address in a register temporarily.
C: Read the memory address to test, save value in a register temporarily.
D: Write the inverted value you just read.
E: Read the value and check that it matches the inverted value you just wrote.
F: Write back the original value.
G: Find next address to check. Go back to B.
H: When you get a HardFault, you will have a pointer to the last address that did not fail, that's the highest usable memory address.
I: When all is done, restore the HardFault exception vector to what it was before you started the test.
Addresses to test could be SRAM base address + n KB - 4, where n could be 8, 16, 32, 64, 128 (and so forth, depending on your microcontroller's specifications).