Pull data from memory map into program
Is there a preprocessor definition or a way to grab data from the memory map file, such as Target Processor and Flash/RAM memory size, and use within your C program? Parsing the XML would be no big deal if I can access it, but it seems there ought to be an easier way. Currently working with a STM32F4.
I have the strings manually defined in the program, but would like something smarter.
MAJ
-
See https://rowley.zendesk.com/entries/46184--access-memory-segments-from-within-a-program
Regarding finding out the selected target processor, you can use the __TARGET_PROCESSOR pre-processor definition.
Regards,
Jon
-
Thanks, Jon! I appreciate it. You guys are great!
The memory segment symbols work great. Perfecto.
However, I'm having trouble understanding how to correctly use the __TARGET_PROCESSOR definition. I can see that is "contains" the processor name/type during compile time, but it is undeclared. Message is: ...'STM32F407VE' undeclared (first use in this function)
So, I declare it as unsigned const char *__TARGET_PROCESSOR;
But, that appears to null it. It compiles, but doesn't produce anything of value. It doesn't appear to be a string. It appears to behave much differently than the other definitions I'm using, like __DATE__ (which doesn't need to be declared), __FLASH_segment_start__, etc.
I've looked at through the CrossWorks for ARM library and read through the Standard Predefined Macros, and reviewed the pre-defined compiler macros for CPU architectures, but can't find any additional information on using this definition.
Sorry, I thought I was smart enough to figure this one out on my own. :-/
Additionally, is there a list of all the pre-processor definitions one can use in Crossworks, beyond the standard symbols?
Best of wishes,
MAJ
-
Hi Michael,
Sorry, it appears I sold you a dud - it looks like the __TARGET_PROCESSOR definition is no longer really supported in the STM32 support package. There should be a header file that defines a unique number for each target, but it seems that is no longer maintained or shipped. You can make it work by defining a unique number for each target you are going to use yourself, for example:
#define STM32F407VE 1
#define STM32F407VG 2
#if __TARGET_PROCESSOR==STM32F407VE
...
#elif __TARGET_PROCESSOR==STM32F407VG
...
#endifAlternatively, you can use the series name instead, for example:
#ifdef STM32F10X_MD_VL
...
#endifFor a list of definitions, see the STM32 Project Specifics section of the STM32 CPU support package documentation ( http://www.rowleydownload.co.uk/arm/packages/STM32.htm ).
You can also see the definitions passed to the compiler by setting the "Building > Echo Build Command Lines" environment setting to "Yes".
Regards,
Jon
Please sign in to leave a comment.
Comments
3 comments