AnsweredAssumed Answered

ColdFire Global Variables

Question asked by Pablo Suarez on Sep 5, 2012
Latest reply on Sep 6, 2012 by Pablo Suarez

Hi, I'm starting with ColdFire Family C language and I will appreciate if somebody can help me with C structure.
I have some time programming in C for 8 bits microcontrollers using CodeWarrior V10.1 and I found my first difference between 8 bits microcontrollers and ColdFire:

When I define my variables, I use to write a header file like this:


#if Global_Variable//- MY_ZEROPAGE RAM from 0x0080 to 0x00FF --------------------------------------------------------------------- #pragma DATA_SEG __SHORT_SEG MY_ZEROPAGE    unsigned char SCI2_Input_Buffer [30];  unsigned char SCI2_Output_Buffer [30];  unsigned char SCI2_Input_Chr_Cnt = 0;  unsigned char SCI2_Status = 0;  unsigned char SCI2_Output_Chr_Cnt = 0;  unsigned char SCI2_Output_Chr_Limit = 0;  unsigned char *Data_Pointer;       #pragma DATA_SEG DEFAULT//- MY_RAM from 0x0100 to 0x087F --------------------------------------------------------------------- #pragma DATA_SEG MY_RAM    unsigned char Function_Request = 0;  unsigned int Delay_Cnt = 0;   #pragma DATA_SEG DEFAULT  #endif//**************************************************************************************************************#if Extern_Variable//- MY_ZEROPAGE RAM from 0x0080 to 0x00FF --------------------------------------------------------------------- #pragma DATA_SEG __SHORT_SEG MY_ZEROPAGE    extern unsigned char SCI2_Input_Buffer [30];  extern unsigned char SCI2_Output_Buffer [30];  extern unsigned char SCI2_Input_Chr_Cnt;  extern unsigned char SCI2_Status;  extern unsigned char SCI2_Output_Chr_Cnt;  extern unsigned char SCI2_Output_Chr_Limit;  extern unsigned char *Data_Pointer;      #pragma DATA_SEG DEFAULT//- MY_RAM from 0x0100 to 0x087F --------------------------------------------------------------------- #pragma DATA_SEG MY_RAM  extern unsigned char Function_Request;  extern unsigned int Delay_Cnt; #pragma DATA_SEG DEFAULT    #endif


In this way I can use this variables shared with all functions.

I get MY_ZEROPAGE and MY_RAM labels from the Proyect.prm file were it specified a RAM or ROM space.


/* This is a linker parameter file for the mc9s08gt32a */NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */    Z_RAM                    =  READ_WRITE   0x0080 TO 0x00FF;    RAM                      =  READ_WRITE   0x0100 TO 0x087F;    ROM                      =  READ_ONLY    0x8000 TO 0xFFAF;    ROM1                     =  READ_ONLY    0xFFC0 TO 0xFFCB; /* INTVECTS                 =  READ_ONLY    0xFFCC TO 0xFFFF; Reserved for Interrupt Vectors */ENDPLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */    DEFAULT_RAM,                        /* non-zero page variables */                                        INTO  RAM;    _PRESTART,                          /* startup code */    STARTUP,                            /* startup data structures */    ROM_VAR,                            /* constant variables */    STRINGS,                            /* string literals */    VIRTUAL_TABLE_SEGMENT,              /* C++ virtual table segment */    DEFAULT_ROM,    COPY                                /* copy down information: how to initialize variables */                                        INTO  ROM; /* ,ROM1: To use "ROM1" as well, pass the option -OnB=b to the compiler */    _DATA_ZEROPAGE,                     /* zero page variables */    MY_ZEROPAGE                         INTO  Z_RAM;ENDSTACKSIZE 0xF0/* VECTOR 0 _Startup /* Reset vector: this is the default entry point for an application. */



Now, where is the Proyect.prm file in CodeWarrior proyect for a ColdFire device like MCF51CN128?

Please, can you explain me how I can specify Global Variables that I can use in any function?


Theank you for your time.

Best regards, Pablo Suárez from Buenos Aires.