#2 Blinky Red LED onboard
Lets try out blinking the RED onboard LED. We are going to use Codewarrior and processorexpert with FRDM-K20D50M board
Take a look at the [Freescale K20D50M MCU Programming] #1 Helloworld on the Console using Processor Expert for quickstart
Lets get started.
First we need to see the schematic to identify the onboard LED. There is a good youtube video which gives an example on K25Z board.
LED Schematic :
Red LED connected to D6.
Green LED connected to D3
Blue LED connected to D9
Identify the Ports and Pins for the LED's :
Red, look for D6
Green, Look for D3
Blue, Look for D9
The FRDM-K20D50 CPU uses the Blue LED. So, this has to be disabled to get this on-board LED to work.
Then Lets add BITIO_LDD component, 1 for each LED to control them.
Now lets setup the Bit_IO pins for the 3 LED's. LED Cathode is connected to the microcontroller pin. i.e., Low Level (0) turns it on, and (1) turns it off. By default we need to set all the 3 LED's to (1) to turn it off.
WE add 3 BitIO_LDD Components, for RED, Green and Blue.
Green LED -> Switch off by Default. Cathode connected. So 1 is Off
Red LED -> Switch ON by Default. Cathode connected. So 0 is On.
Now build and Run the Main.c you will see the RED LED glowing by the code is flashed.
Now lets make a blinky. :-)
We need to enable the NegVal() method of the BitIO_LDD
And add this code in the main.c or processorexpert.c
/*lint -restore Enable MISRA rule (6.3) checking. */
/* Write your local variable definition here */
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
/*** End of Processor Expert internal initialization. ***/
int i =0;
RED_LED_NegVal(NULL); // Blink the RED Led
Here is the blinky.
CodeWarrior, PEX Project : Download onboard_blinky.zip