frdm-kl02z LED example problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

frdm-kl02z LED example problem

Jump to solution
1,747 Views
rado__99
Contributor II

Hello, I use this example for blinking red with the uVision IDE: 

My asking is why when I change BOARD_LED_RED_GPIO with BOARD_LED_GREEN_GPIO and BOARD_LED_RED_GPIO_PIN with BOARD_LED_GREEN_GPIO_PIN it doesn't works:

#include "board.h"
#include "fsl_debug_console.h"
#include "fsl_gpio.h"

#include "clock_config.h"
#include "pin_mux.h"
/*******************************************************************************
* Definitions
******************************************************************************/
#define BOARD_LED_GPIO BOARD_LED_RED_GPIO
#define BOARD_LED_GPIO_PIN BOARD_LED_RED_GPIO_PIN

/*******************************************************************************
* Prototypes
******************************************************************************/
/*!
* @brief delay a while.
*/
void delay(void);

/*******************************************************************************
* Variables
******************************************************************************/

/*******************************************************************************
* Code
******************************************************************************/
void delay(void)
{
volatile uint32_t i = 0;
for (i = 0; i < 800000; ++i)
{
__asm("NOP"); /* delay */
}
}

/*!
* @brief Main function
*/
int main(void)
{
/* Define the init structure for the output LED pin*/
gpio_pin_config_t led_config = {
kGPIO_DigitalOutput, 0,
};

/* Board pin, clock, debug console init */
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();

/* Print a note to terminal. */
PRINTF("\r\n GPIO Driver example\r\n");
PRINTF("\r\n The LED is blinking.\r\n");

/* Init output LED GPIO. */
GPIO_PinInit(BOARD_LED_GPIO, BOARD_LED_GPIO_PIN, &led_config);

while (1)
{
delay();
GPIO_PortToggle(BOARD_LED_GPIO, 1u << BOARD_LED_GPIO_PIN);
}
}

Labels (1)
Tags (2)
0 Kudos
Reply
1 Solution
1,475 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Radoslav,

  Please download the official sample code from this link:

https://mcuxpresso.nxp.com/en/select 

Choose the board as FRDM-KL02, generate the code and download it.

Then you can find the example in folder:

FRDM-KL02Z\boards\frdmkl02z\driver_examples\gpio\led_output


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
5 Replies
1,475 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Radoslav LLiev,

    Please check BOARD_InitPins code, do you configure the according pin mux as 1?

   Any updated information, please kindly let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,475 Views
rado__99
Contributor II

Thank you so much for the help, I found the pinMux.c, I configured it and it's done!

0 Kudos
Reply
1,475 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Radoslav lliev,

   Thank you for your updated information, and it's good to hear you solve the problem.

   If your problem is solved and don't have any other question, please help to mark the correct answer, just to close this post, thank you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
1,475 Views
rado__99
Contributor II

Can you give me an example, please?

I am newbie in working with Embedded-C.

0 Kudos
Reply
1,476 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Radoslav,

  Please download the official sample code from this link:

https://mcuxpresso.nxp.com/en/select 

Choose the board as FRDM-KL02, generate the code and download it.

Then you can find the example in folder:

FRDM-KL02Z\boards\frdmkl02z\driver_examples\gpio\led_output


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply