AnsweredAssumed Answered

Macro issue KSDK1.2.0 (FRDM-KL25Z)

Question asked by Nelson Lobo on Sep 4, 2015
Latest reply on Sep 4, 2015 by Jorge_Gonzalez

Hi,

 

Ive looked up several sample codes and have finally decided to write a code myself. Also looked up KL25 family reference manual for the same purpose to understand the arrangement/assignment of registers.

 

The code is located in I:/folder1/folder2/folder3/folder4/folder5/1.GPIO_Setup location while the KDS1.2.0 installation is located at C:/Freescale/ location.

For which i have also provided include locations for necessary files being refernced in Tool Settings for Cross ARM C Compiler.

The code is basically toggling LEDs i.e. the RGB available on pins 18,19 on portB and pin 1 on portD, which would be as follows:

 

#include "MKL25Z4.h"

#include "fsl_device_registers.h"

#include "fsl_clock_manager.h"

#include "fsl_smc_hal.h"

#include "fsl_port_hal.h"

#include "fsl_sim_hal.h"

#include "fsl_gpio_driver.h"

 

/*as mentioned in fsl_gpio_driver.h inorder to gain access of GPIOs*/

enum _gpio_pins

{

    kGpioLED1        = GPIO_MAKE_PIN(GPIOB_IDX, 19),   /* FRDM-KL25Z4 Green LED */

    kGpioLED2        = GPIO_MAKE_PIN(GPIOB_IDX, 18),   /* FRDM-KL25Z4 Red LED */

    kGpioLED3        = GPIO_MAKE_PIN(GPIOD_IDX,  1),   /* FRDM-KL25Z4 Blue LED */

    kGpioSW1         = GPIO_MAKE_PIN(GPIOD_IDX,  6),   /* FRDM-KL25Z4 power manager */

};

 

/*initialize GPIOs variables array*/

extern gpio_input_pin_user_config_t switchPins[];

extern gpio_output_pin_user_config_t ledPins[];

 

/* Declare Output GPIO pins */

gpio_output_pin_user_config_t ledPins[] = {

    {

        .pinName = kGpioLED1,

        .config.outputLogic = 1,    

        .config.slewRate = kPortSlowSlewRate,

        .config.driveStrength = kPortLowDriveStrength,

    },

    {

        .pinName = kGpioLED2,

        .config.outputLogic = 1,

        .config.slewRate = kPortSlowSlewRate,

        .config.driveStrength = kPortLowDriveStrength,

    },

    {

        .pinName = kGpioLED3,

        .config.outputLogic = 1,

        .config.slewRate = kPortSlowSlewRate,

        .config.driveStrength = kPortLowDriveStrength,

    },

    {

        .pinName = GPIO_PINS_OUT_OF_RANGE,

    }

};

 

/*Use following Macros to access the PORT pins*/

 

#define LED1_EN (GPIO_DRV_OutputPinInit(&ledPins[0])) /*!< Enable target LED1 */

#define LED2_EN (GPIO_DRV_OutputPinInit(&ledPins[1])) /*!< Enable target LED2 */

#define LED3_EN (GPIO_DRV_OutputPinInit(&ledPins[2])) /*!< Enable target LED3 */

 

 

#define LED1_DIS (PORT_HAL_SetMuxMode(PORTB, 19, kPortMuxAsGpio))    /*!< Enable target LED1 */

#define LED2_DIS (PORT_HAL_SetMuxMode(PORTB, 18, kPortMuxAsGpio))  /*!< Enable target LED2 */

#define LED3_DIS (PORT_HAL_SetMuxMode(PORTD,  1, kPortMuxAsGpio))  /*!< Enable target LED3 */

 

 

#define LED1_OFF (GPIO_DRV_WritePinOutput(ledPins[0].pinName, 1))         /*!< Turn off target LED1 */

#define LED2_OFF (GPIO_DRV_WritePinOutput(ledPins[1].pinName, 1))         /*!< Turn off target LED2 */

#define LED3_OFF (GPIO_DRV_WritePinOutput(ledPins[2].pinName, 1))         /*!< Turn off target LED3 */

 

 

#define LED1_ON (GPIO_DRV_WritePinOutput(ledPins[0].pinName, 0))          /*!< Turn on target LED1 */

#define LED2_ON (GPIO_DRV_WritePinOutput(ledPins[1].pinName, 0))          /*!< Turn on target LED2 */

#define LED3_ON (GPIO_DRV_WritePinOutput(ledPins[2].pinName, 0))          /*!< Turn on target LED3 */

 

 

#define LED1_TOGGLE (GPIO_DRV_TogglePinOutput(ledPins[0].pinName))          /*!< Toggle on target LED1 */

#define LED2_TOGGLE (GPIO_DRV_TogglePinOutput(ledPins[1].pinName))          /*!< Toggle on target LED2 */

#define LED3_TOGGLE (GPIO_DRV_TogglePinOutput(ledPins[2].pinName))          /*!< Toggle on target LED3 */

 

 

int main(void)

{

  unsigned int count = 0;

  unsigned int check_gpio = 0;

 

 

 

// SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK|SIM_SCGC5_PORTD_MASK;

//

// PORTB_PCR18  |= (PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK);

// GPIOB_PDDR |= (1<<18);

// GPIOB_PSOR |= (1<<18);

//

// PORTD_PCR1  |= (PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK);

// GPIOD_PDDR |= (1<<1);

// GPIOD_PSOR |= (1<<1);

 

 

  LED1_EN;

  LED2_EN;

  LED3_EN;

 

 

    while(1)

    {

//     /*Toggle bits*/

//     GPIOB_PTOR |= (1<<18);

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

//     GPIOD_PTOR |= (1<<1);

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

//

//

//     GPIOB_PCOR |= (1<<18);

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

//     GPIOB_PSOR |= (1<<18);

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

//

//     GPIOD_PCOR |= (1<<1);

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

//     GPIOD_PSOR |= (1<<1);

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

 

 

    LED1_TOGGLE;

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

    LED2_TOGGLE;

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

    LED3_TOGGLE;

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

    }

    return 0;

}

 

I get following errors:

I:\Folder\Evalutation Board Trials\Freescale\Freescale FRDMKL25Z\Trial Codes\1.GPIO_Setup\Debug/../Sources/main.c:109: undefined reference to `GPIO_DRV_OutputPinInit'

I:\Folder\Evalutation Board Trials\Freescale\Freescale FRDMKL25Z\Trial Codes\1.GPIO_Setup\Debug/../Sources/main.c:110: undefined reference to `GPIO_DRV_OutputPinInit'

I:\Folder\Evalutation Board Trials\Freescale\Freescale FRDMKL25Z\Trial Codes\1.GPIO_Setup\Debug/../Sources/main.c:111: undefined reference to `GPIO_DRV_OutputPinInit'

I:\Folder\Evalutation Board Trials\Freescale\Freescale FRDMKL25Z\Trial Codes\1.GPIO_Setup\Debug/../Sources/main.c:115: undefined reference to `GPIO_DRV_TogglePinOutput'

I:\Folder\Evalutation Board Trials\Freescale\Freescale FRDMKL25Z\Trial Codes\1.GPIO_Setup\Debug/../Sources/main.c:118: undefined reference to `GPIO_DRV_TogglePinOutput'

I:\Folder\Evalutation Board Trials\Freescale\Freescale FRDMKL25Z\Trial Codes\1.GPIO_Setup\Debug/../Sources/main.c:121: undefined reference to `GPIO_DRV_TogglePinOutput'

 

I am suspecting that i haven't defined a macro that is preventing the compiler to gain access of this function.

Also attached is the source code and project file of the same.

 

Im stuck please help!!!

Original Attachment has been moved to: 1.GPIO_Setup.rar

Outcomes