AnsweredAssumed Answered

Flashing LEDs with K22F - debugged and tested

Question asked by Jeff Verive on Oct 6, 2014
Latest reply on Oct 10, 2014 by Adrian Cano

#include "fsl_device_registers.h"

#include "board.h"

 

 

static int i = 0;

 

 

// LEDs are common-anode, with cathodes connected to port pins.

// Therefore, logic high (1) turns them off, and logic low

// (0) turns them on.

 

 

short OFF = 1;

short ON = 0;

 

 

int main(void)

{

     hardware_init();

 

 

     GPIO_DRV_SetPinDir(kGpioLED1, kGpioDigitalOutput); //Green LED

     GPIO_DRV_SetPinDir(kGpioLED2, kGpioDigitalOutput); //Red LED

     GPIO_DRV_SetPinDir(kGpioLED3, kGpioDigitalOutput); //Blue LED

 

 

     GPIO_DRV_WritePinOutput(kGpioLED1, OFF); //Green LED initially off

     GPIO_DRV_WritePinOutput(kGpioLED2, OFF); //Red LED initially off

     GPIO_DRV_WritePinOutput(kGpioLED3, OFF); //Blue LED initially off

 

 

 

 

     while (1)

          {

          for (i = 0; i<0xFFFFFF; i++)

          {

          }

          GPIO_DRV_WritePinOutput(kGpioLED1, ON); //Green LED on

          for (i = 0; i<0xFFFFFF; i++)

          {

          }

          GPIO_DRV_WritePinOutput(kGpioLED1, OFF); //Green LED off

          for (i = 0; i<0xFFFFFF; i++)

          {

          }

          GPIO_DRV_WritePinOutput(kGpioLED2, ON); //Red LED on

          for (i = 0; i<0xFFFFFF; i++)

          {

          }

          GPIO_DRV_WritePinOutput(kGpioLED2, OFF); //Red LED off

          for (i = 0; i<0xFFFFFF; i++)

          {

          };

          GPIO_DRV_WritePinOutput(kGpioLED3, ON); //Blue LED on

          for (i = 0; i<0xFFFFFF; i++)

          {

          }

          GPIO_DRV_WritePinOutput(kGpioLED3, OFF); //Blue LED off

          }

     return 0;

}

Outcomes