210 likes | 339 Views
ME 4447/6405. Configuring CodeWarrior V5.1 for the HCS12. Connect BDM cable to board (red line of ribbon cable connected to pin 1 of BDM_PORT) Open CodeWarrior IDE on desktop. Click on Create New Project. Choose MC9S12C32 Choose P&E USB BDM Multilink Click “Next”. Check “C”
E N D
ME 4447/6405 Configuring CodeWarrior V5.1 for the HCS12
Connect BDM cable to board (red line of ribbon cable connected to pin 1 of BDM_PORT) Open CodeWarrior IDE on desktop. Click on Create New Project
Choose MC9S12C32 • Choose P&E USB BDM Multilink • Click “Next”
Check “C” • Type in project name and use default location for your project • Click “Next”
Check Create main.c/main.asm file • Click “Next”
Select “None” Click “Next”
Check ANSI startup code • Check Small • Check floating is IEEE32, double is IEEE64 • “Next”
Select “No” Click “Finish”
Change RAM 0x0800 To 0x7FFF Comment “ROM_4000…” line Save the change Change to 0x7FFF Comment out this line
Configuring for External Memory Access • In order to configure the microcontroller for external memory access, you need to put the following three statements at the start of your “main” function before any other statement (but after any variable definitions). MISC = 0x03; PEAR = 0x0C; MODE = 0xE2;
Double click “main.c” under Sources. This is the source code you will be editing to create your program. • Put the three statements in your main function
#include <hidef.h> /* common defines and macros */ #include <mc9s12c32.h> /* derivative information */ #pragma LINK_INFO DERIVATIVE "mc9s12c32" #include <stdio.h> #include <termio.h> voidmain(void) { MISC = 0x03; PEAR = 0x0C; MODE = 0xE2; TERMIO_Init(); //Initializes the SCI subsystem puts("Hello, World!\n"); //Prints the string to the screen for(;;) {} /* wait forever */ /* please make sure that you never leave this function */ } • Enter the “Hello World “ code on this page in your “main.c” file
Add stdio and termio to project • Right-click the “Libs” folder in the project pane and select “Add files…” • Add stdlib.h and termio.h files from “C:\Program Files\Freescale\CWS12v5.1\lib\hc12c\include” • Add termio.c file from “C:\Program Files\Freescale\CWS12v5.1\lib\hc12c\src”
In the Debugger window, select the HC12MultilinkCyclonePro menu • Choose “Debugging Memory Map…” • Select the third listing for the RAM and click “Modify/Details”
Change the End field to 7FFF and click OK • Then close the window
Connect The serial cable to COM1 and start AxIDE • Click the Green Arrow to begin execution of your program • “Hello, World!” should appear on the screen
Output window is shown below. • Don’t open multiple debugger windows, otherwise you’ll see communication error.