AnsweredAssumed Answered

Including existing libraries from KSDK1.2

Question asked by Nelson Lobo on Jul 10, 2015
Latest reply on Jul 15, 2015 by Iva Dorazinova

Ive created a project in the following manner in KDS3.0

 

File--> New --> ProjectName --> Next -->Processors --> Kinetis L --> MKL2x --> KL25Z(48MHz) --> MKL25Z128xxx4 --> Next -->(Nothing selected here) --> Finish

 

Now i write following piece of code in main:

#include "MKL25Z4.h"

/*!

* @brief Main function

*/

int main (void)

{

       unsigned int count = 0;

       SIM_BASE_PTR->SCGC5 |= SIM_SCGC5_PORTB_MASK; //refer to page 206 to check the SCGC5 register which is the System clock gating control register

 

       //PORTB_BASE_PTR->PCR[18] =  PORT_PCR_MUX(1); //

       PORTB_PCR18 = PORT_PCR_MUX(1);

 

       //PTB_BASE_PTR->PDDR = 1 << 18;

       GPIOB_PDDR = 1<<18;

 

       while(1)

       {

         //PTB_BASE_PTR->PSOR = 1 << 18;

         GPIOB_PSOR |= 1<<18;

         for(count = 0;count <1000000;count++);

 

         //PTB_BASE_PTR->PCOR = 1 << 18;

         GPIOB_PCOR |= 1<<18;

         for(count = 0;count <1000000;count++);

         }

         return 0;

}

 

This code toggles bit 18 of PORTB.

 

I wanted to know if i were to use the libraries as done in KSDK1.2.0 examples into this code how do i do it ?

 

Following is the code example for the same output using KSDK1.2.0 example Hello World:

NOTE: in this code ive removed the LPTMR section since i just want to focus on basic port pins functions

 

// SDK Included Files

#include "board.h"

 

/*!

* @brief Main function

*/

int main (void)

{

     unsigned int count = 0;

 

    // Initialize standard SDK demo application pins

    hardware_init();

 

    // Initialize LED1

    LED1_EN;

    LED2_EN;

    LED3_EN;

 

    LED1_ON;

    LED2_ON;

    LED3_ON;

 

    while(1)

    {

         LED1_TOGGLE;

         for(count = 0;count <10000;count++);

    }

}

 

I want to know a way wherein i could provide a path in the project to these KSDK1.2.0 headers so that i could use these functions.

Outcomes