AnsweredAssumed Answered

Variables in MKL25Z4.h file (#include)

Question asked by PT CAOS on Mar 18, 2019
Latest reply on May 30, 2019 by Kerry Zhou

Hello,

 

I'm trying to "convert" a CodeWarrior project to a MCUX Project. In my first test, I have created a new project for my board (FRDM-KL25Z, with its SDK already installed in my system for MCUX). After creating the project, I have added a file that I created some days ago in CodeWarrior:

#include <MKL25Z4.h>

#define RED_SHIFT (1 << 18)

 

void clockConfig();
void portBConfig();
void tpm0Config();

 

int main (void) {

    clockConfig();
    portBConfig();
    tpm0Config();
    
    while (1)
    {          
        while((TPM0_SC & TPM_SC_TOF_MASK) == 0) // wait until the TOF is set
        {
            ;
        }

 

        TPM0_SC |= TPM_SC_TOF_MASK; // clear TOF
        GPIOB_PTOR = RED_SHIFT;     // toggle blue LED
    }
}

 

void clockConfig()
{
    // set clock to 2MHz
    MCG_C1 = MCG_C1_IREFS_MASK | MCG_C1_IRCLKEN_MASK; // INTERNAL CLOCK|MCGIRCLK ACTIVE(SET)
    MCG_C2 = MCG_C2_IRCS_MASK;                        // SELECT FAST INTERNAL REFERENCE CLOCK (1)
    SIM_SOPT2 |= SIM_SOPT2_TPMSRC(3);                 // MCGIRCLK IS SELECTED FOR TPM CLOCK
}

 

void portBConfig()
{
    SIM_SCGC5  |= SIM_SCGC5_PORTB_MASK; // enable clock to Port B
    PORTB_PCR18 = PORT_PCR_MUX(1);      // make PTB18 pin as GPIO
    GPIOB_PDDR |= RED_SHIFT;            // make PTB18 as output pin
}

 

void tpm0Config()
{
    SIM_SCGC6 |= SIM_SCGC6_TPM0_MASK; // enable clock to TPM0
    
    TPM0_SC  = 0;                   // disable timer while configuring
    TPM0_SC |= TPM_SC_PS(5);        // prescaler
    TPM0_MOD = TPM_MOD_MOD(62500);  // modulo value
    TPM0_SC |= TPM_SC_TOF_MASK;     // clear TOF
    TPM0_SC |= TPM_SC_CMOD(1);      // enable timer free-running mode
}

 

My first line is an include to file <MKL25Z4.h>, where there are some defined variables. In my original source code, generated and write in CodeWarrior (Windows version), there are a variable called TPM0_SC. However, now, in my new MCUXpressoIDE (Linux version), file MKL25Z4.h (included) not contain that variable...

Same problem occurs with others variables...

 

Is it normal?

 

Thanks.

Outcomes