[FRDM-KW41Z] Demo gpio_led_output.c working well. Clean copy of it doesn't.

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

[FRDM-KW41Z] Demo gpio_led_output.c working well. Clean copy of it doesn't.

1,045 Views
gillesclerc
Contributor I

Hi there,

I just want to try to blink a single led (gosh) and can't get this to work even with the demo within the connectivity software (with the SDK 2.0 inside i guess).

Ok, so if i build the project gpio_led_outpute_frdmkw41z the led is blinking as expected. But if i do the same things in my own project it didn't. I maybe miss something here.

I did create a new project with the Kinetis SDK 2.x Project wizard (link to the sdk2.0 inside the folder of the connectivity software), and simply did exactly the same things with the GPIO:

// Define the init structure for the output LED pin

gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0,};

// Init the output

GPIO_PinInit(BOARD_LED_GPIO, BOARD_LED_GPIO_PIN, &led_config);

while1{

//toggle it with some delay

delay();

GPIO_TogglePinsOutput(BOARD_LED_GPIO, 1u << BOARD_LED_GPIO_PIN);
  };

I tried everything. Even to change with the define on board.h (LED_RED_INIT(), LED_RED_TOGGLE().

The thing is: It's working very well with the demo but not with my project despite it's exactly the same include define  etc.. (copy pasted!!)

Any one of you have an idea? Maybe i miss a configuration somewhere?

Sorry for my english.

0 Kudos
2 Replies

651 Views
gillesclerc
Contributor I

By not working i mean the led didn't blink. The build and debug is without any error. Here is the code:

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

#include "clock_config.h"
#include "pin_mux.h"
/*******************************************************************************
 * Prototypes
 ******************************************************************************/
/*!
 * @brief delay a while.
 */
void delay(void);

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

/*!
 * @brief Application entry point.
 */
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 taking turns to shine.\r\n");

    /* Init output LED GPIO. */
    GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, &led_config);

    while (1)
    {
        delay();
        GPIO_TogglePinsOutput(BOARD_LED_RED_GPIO, 1u << BOARD_LED_RED_GPIO_PIN);
    }

0 Kudos

651 Views
gillesclerc
Contributor I

Ok i found a way to resolve this problem. Sounds like the wizard 2.0 dont generate the same .h and .c as the demo.

I copied the pin_mux.c and pin_mux.h inside the /board folder from the demo into the generated one from the wizard. And everything about GPIO work well now.

Hope it will help some and save your time..

0 Kudos