June 9, 2013

Kinetis K GCC startup

I have pushed "lightweight" gcc demo to my github repository. A generated CodeWarrior project for Kinetis K with GCC compiler contains a lot of "bloat" in my opinion therefore I decided to write trivial startup without including any libraries (only stdin included for C99 types). C++ support is not present, neither RAM target.

It contains a GPIO demo for the TWRK60N512 at the moment. The demo instantly toogles LED1 on the tower board and LED2 toogles only when the button SW1 is pressed.

The demo contains following files:
  • common/common.h - including purpose
  • cpu/headers/derivative.h - include cpu specific header
  • cpu/headers/MK60DZ10.h - freescale's header file
  • cpu/startup_k60.c - vectors plus reset handler
  • cpu/system_k60.c - system init function which inicializes CPU (clocks - 96MHz). This needs to be edited to reflect desired cpu clock freq
  • cpu/system_k60.h
  • k60n512_flash.ld - GNU linker for K60
  • main.h
  • main.c
  • Makefile
As could be seen, there are no drivers included. The demo itself only contains necessary files to initialize CPU and jump to the main function.

This example could be used with the tutorial which I wrote previously, openOCD with the kinetis K60. I used it as the test project.

Kinetis Kxx gcc startup on github : GPIO gcc Kinetis K (K60) [www.github.com/0xc0170/]

Update1: I added K20D72M board