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.
No no, if file $HOME/workspace/Test/CMSIS MCUX has added CMSIS subfolder that contains a copy of "MKL25Z4.h" file (includes file). In that file, there are some defined variables that start with "#define TPM1_" and continue with other names as "TPM1_BASE". So I don't understand why solution to my problem could be what you say (changing "-" to "->").-
Why?
Thanks!
Hi PT CAOS,
TPM1_BASE is just the address, you can find this define:
It is still the pointer, so you need to use -> instead of _.
If you want to use the _, eg, TPM1_SC, you must have the definition like the bare metal code for KL25:
You can find, actually, the root still use ->, you can use the _ directly, because in your old CW project, it has the definition file like memMapPrt_kl25z4.h.
Actually, just modify the "_" to "->" is not complicate, you can try it on your side.
Wish it helps you!
Have a great day,
Kerry
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi again,
where can I configure MCUXpresso IDE about "_" to "->"? In others words, if I wrote "_" in Codewarrior, why does not compile my program with that syntax in MCUX? Is there any configuration parameter I could change?
Thanks.
Hi PT CAOS,
It is determined by your project head file, if your header file already define the register" _", then you can use it.
But some header file just define the register point, then you need to use"->".
From my own opinion, you can refer to the official SDK code, then it will help you to understand it.
Have a great day,
Kerry
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi PT CAOS,
Thank you for your interest in NXP kinetis product, I would like to provide service for you.
Change TPM0_SC to TPM0->SC
Change TPM0_MOD to TPM0->MOD.
Others is the same, just use "->" instead of "_".
Please try it on your side.
Wish it helps you!
Have a great day,
Kerry
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------