This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Processor Type and compile time switches

I am writing FLASH code that will work on both a medium and high density STM32 chip. Is there a simple way of selecting the FLASH and PAGE size in my code with out me having two versions of a header file. In other words are there processor configuration #defines that tell me the processor type or better still the flash and page sizes that I can access at compile time.

I'm using Uvision 3 and the two processors I m targetting are STM32F101VB and ..103VE

Parents
  • Create two targets.

    For each target, select the C/C++ tab.
    In the field Define, you add a suitable preprocessor define.

    In the source code, you use conditional compilation depending on the value of your define.

    #if PROCESSOR_BIG_BAUTA
        // Building for xxx
        #include <xxx>
    #elif PROCESSOR_TINY
        // Building for yyy
        #include <yyy>
    #else
        // Oops, unsupported or missing choice
        #error "No known target specified"
    #endif
    

Reply
  • Create two targets.

    For each target, select the C/C++ tab.
    In the field Define, you add a suitable preprocessor define.

    In the source code, you use conditional compilation depending on the value of your define.

    #if PROCESSOR_BIG_BAUTA
        // Building for xxx
        #include <xxx>
    #elif PROCESSOR_TINY
        // Building for yyy
        #include <yyy>
    #else
        // Oops, unsupported or missing choice
        #error "No known target specified"
    #endif
    

Children