I have been trying to compile a GPIO example for the FRDM-KL25Z Arm Cortex-M0+. At the beginning I run into the problem of not finding the path for "MKL25Z4.h". After a quick search online, I found that I had to add the directory path to the project's "Include Paths" (C:/Keil_v5/ARM/PACK/Keil/Kinetis_KLxx_DFP/1.15.0/Device/Include). While this solved the error, another one came out. This time is regarding the "system_MKL25Z4.h" header file. I do not understand why this error surfaced even though I already provided the full path to the directory containing this file.
I would highly appreciate any leads on how to address this situation. Plus, more kudos, if someone could explain to me why adding the full path to the directory does not solve the problem. Furthermore, I did think of writing the full path to the preprocessor definition inside "MKL25Z4.h". However, I think that there must be a better way to address this error.
Your title says "Linker path".
Header files are used by the compiler - not the Linker - so if you have added it in the Linker options, that's the wrong place!
Take a look at the diagrams here to see how the tools in the tool chain relate, and which files are associated with which tools.
Manuel Chavez said:While this solved the error, another one came out. This time is regarding the "system_MKL25Z4.h" header file
You do actually have that file present on your system?
If that's in a different folder, then you also need to add that to your Includes Path.
Manuel Chavez said:a GPIO example for the FRDM-KL25Z
Where did you obtain the example?
Have you contacted the author/supplier for support with it?
Hi Andy,Thank you for your time and prompt reply.First, you are right. A mistake on my end to say it was a Linker error while it is a Compiler error. What I am getting is a Compiler error.
Andy Neil said:Take a look at the diagrams here to see how the tools in the tool chain relate, and which files are associated with which tools.
The link provided to the diagrams that shows the association between files and tools has been very helpful visualizing and clarifying the tool chain. Many thanks for that as well.
Andy Neil said:You do actually have that file present on your system? If that's in a different folder, then you also need to add that to your Includes Path.
Yes, I do have that file present in my system, Windows OS. I got the files of interest after downloading the latest software-pack for the Kinetis KLxx series. The file is located within the same directory in the Path I provided when I initially started this thread. Further, the same Path has been added into the C/C++ Includes Path section. Attached is picture displaying what I assume is correct "include path" source file addition.
Andy Neil said:Where did you obtain the example? Have you contacted the author/supplier for support with it?
I've got the code example from the Embedded Systems Fundamentals with Arm Cortex-M based Microcontrollers textbook. This book is produced by ARM Education Media. Plus, I have not contacted the author. I will do that If help from this forum does not lead to a solution in the next few days.
Manuel Chavez said:While this solved the error, another one came out. This time is regarding the "system_MKL25Z4.h" header file.
What, exactly, is the message?
Copy & paste it here. Post as for source code, but omit step 3.
Also post the source code to which the error relates.
Manuel Chavez said: I got the files of interest after downloading the latest software-pack
Manuel Chavez said:I've got the code example from the Embedded Systems Fundamentals with Arm Cortex-M based Microcontrollers textbook
What is the date of the textbook?
It's quite possible that the "latest" software pack is not compatible ... ?
Andy Neil said:What is the date of the textbook?
The book was printed in 2017. The same year of the latest Software Pack. Furthermore, it also crossed my mind that the latest software pack might have been incompatible source code example I am using. I did download previous versions. However, since we last communicated, after further online searching and walking through the Pack's file system I found that the "system_MLK25Z4.h" header file at the following path: C:/Keil_v5/ARM/PACK/Keil/Kinetis_KLxx_DFP/1.15.0/Device/Source rather than $SAMEPATH/Device/IncludeA clear picture of what errors I am facing will be posted as a reply to your "What, exactly, is the message?" thread
Manuel Chavez said: I found that the "system_MLK25Z4.h" header file at the following path: C:/Keil_v5/ARM/PACK/Keil/Kinetis_KLxx_DFP/1.15.0/Device/Source rather than $SAMEPATH/Device/Include
So has that resolved the issue ?
Thank you Andy for the instructions on how to properly post source code. I learned how to display source code in a clear and neat manner that facilitates collaboration with other members of this forum.Build Output Message:
Build started: Project: MKL25Z_GPIO_Book_Example *** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' Build target 'Target 1' compiling GPIO_Example1.c... C:\Keil_v5\ARM\PACK\Keil\Kinetis_KLxx_DFP\1.15.0\Device\Include\MKL25Z4.h(199): error: #5: cannot open source input file "system_MKL25Z4.h": No such file or directory #include "system_MKL25Z4.h" /* Device specific configuration file */ GPIO_Example1.c: 0 warnings, 1 error ".\Objects\MKL25Z_GPIO_Book_Example.axf" - 1 Error(s), 0 Warning(s). Target not created. Build Time Elapsed: 00:00:00
Textbook C source code GPIO example:
/* * GPIO: LED & Switch Example * Embedded Systems Fundamentals ARM Cortex-M based TextBook */ #include <MKL25Z4.h> // CMSIS HAL #define LED1_SHIFT (1) // on port A #define LED2_SHIFT (2) // on port A #define SW1_SHIFT (5) // on port A #define MASK(x) (1UL << (x)) // MASK macro void Basic_Light_Switching_Example(void){ // Enable Clock to Port A; SET PortA specific bit field location to 1 SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK; // Make 3 GPIO Pins PORTA->PCR[LED1_SHIFT] &= ~PORT_PCR_MUX_MASK; //read, copy, and reset the bit fields of interest PORTA->PCR[LED1_SHIFT] |= PORT_PCR_MUX(1); // modify and write back the desired value of the bit-field of interest PORTA->PCR[LED2_SHIFT] &= ~PORT_PCR_MUX_MASK; PORTA->PCR[LED2_SHIFT] |= PORT_PCR_MUX(1); PORTD->PCR[SW1_SHIFT] &= ~PORT_PCR_MUX_MASK; PORTD->PCR[SW1_SHIFT] |= PORT_PCR_MUX(1); // SET LED bits to Output PTA->PDDR |= MASK(LED1_SHIFT) | MASK(LED2_SHIFT); // CLEAR Switch bit to Input PTD->PDDR &=~MASK(SW1_SHIFT); // turn on LED1, turn off LED2 PTA->PSOR = MASK(LED1_SHIFT); PTA->PCOR = MASK(LED2_SHIFT); while(1) { // IF PortDataInputRegister[1 = Pull-Up] && the Register of Interest bit-field location [ALWAYS 1] if (PTA->PDIR & MASK(SW1_SHIFT)) { //switch is not pressed, so light only LED 2 PTA->PSOR = MASK(LED2_SHIFT); PTA->PCOR = MASK(LED1_SHIFT); } else { // switch is pressed, so light only LED 1 PTA->PSOR = MASK(LED1_SHIFT); PTA->PCOR = MASK(LED2_SHIFT); } } }
Andy Neil said:So has that resolved the issue ?
Yes, adding that other path solved the main issue for this post. Thank you Andy for your time, guidance, and help.