frdm-kl02z LED example problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

frdm-kl02z LED example problem

跳至解决方案
2,634 次查看
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);
}
}

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
2,362 次查看
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 项奖励
回复
5 回复数
2,362 次查看
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!
-----------------------------------------------------------------------------------------------------------------------

2,362 次查看
rado__99
Contributor II

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

0 项奖励
回复
2,362 次查看
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 项奖励
回复
2,362 次查看
rado__99
Contributor II

Can you give me an example, please?

I am newbie in working with Embedded-C.

0 项奖励
回复
2,363 次查看
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 项奖励
回复