Saturday, 4 April 2015

[Freescale K20D50M MCU Programming] #1 Helloworld on the Console using Processor Expert.

Just starting exploring the world of MCU programming.  I was referred a freescale board K20D50M




Being a hardcore java/j2ee developer, Looking at this was little scary.   Followed the steps in QuickStart package in a OpenSDA Mode.  Now comes the time to write some code. I was told that Processor Expert in Codewarrior can do wonders. You do not need to be a hardcore Embedded developer who knows Bits/Registers/MUXing. ;-)

As a beginner. Codewarrior is the best place to start with. Code, test the device from one place. Later you can jump into the Processor Expert Driver suite to write code, while to test you need to use IAR workbench for Kinetics or a Kinetics Design Studio.


Tools you need 

1. FRDM-K20D50M board
2. Codewarrior or other similar tools
3. Realterm - Terminal viewer tool


Assuming, you got your openSDA configuration done on the bootloader mode.  
Lets get into action. 


Create a Bareboard Project -



Name the project


Select the device - K20D50 - MK20DX128:





Select Connections :




Build and Debug Selection:



RAD :



FINISH


CodeWarrior Perspective :


This is what you will see in your codewarrior. You can read more about the perspectivies, look for videos in Youtube if you are not  used to the eclipse environment.




Now comes the real usecase to print Helloworld  by writing code, run it on the freescale board, and see it on the terminal.

Add the ConsoleIO component to the project:



Component (Advanced) Properties:




Serial_LDD  Changes :

You need to change the Serial to UART0.  Lets check the schematic pdf for their pins




Now lets fix the errors in the properties by setting the in and out appropriately, and the baud rate error will be gone.


Locate the main.c:




Add your Printf :




Lets build :




Run it : 




If device/board is not connected to your USB.



Connect, Refresh and Retry:



Console Output: 



Realterm Configuration:



Realterm Output Configuration:




Realterm Output when you run the program. Press the reset button, you will see the program restarting.


You can add the printf in a for loop.
there you go! The 1st MCU Hello world is done.

2 comments: