ICA01 Program Flow
Procedure to Create a New Code Warrior Project
When you open CodeWarrior a Startup dialog box should appear, if not go to File/Start Dialog…
From the Startup Dialog box click Create New Project.
Then under Select the derivative to use choose HCS12XD Family/MC9S12XDP512
Also choose USBDM in the Connections box. Then click next.
Then choose Single Core, and click next.
Then make sure the C box is checked and all others not.
Change the name of the project to something that makes sense for example ICA01.
Change the place to store the project to the ICAs folder in your workbook repo. Click next.
Remember This - The only way to tell where the project is to be stored is when creating the project. You cannot save as the project as a whole via the IDE anywhere else after it has been created.
No need to add existing files so click next.
We want None for Rapid Dev Options. Click next.
Choose ANSI Startup Code, Small Memory Model, and IEEE32 for both float and double. Click next.
Finally check NO to PC-lint. Click Finish.
Procedure to download a project to Code Warrior
Now that the project has been created and stored in your local workbook repo, open it in VSCode as we will want to change the main.c file in VSCode to reflect the problem we are solving.
After you have changed main.c in VSCode make sure to save your changes, so we can then download the project to our micro board and run the program in main.c.
From the project root folder that is in the ICAs folder, right click and via the context sensitive menu choose Open in File Explorer.
- Then double click on the file called PROJECTNAME.mcp. This will load the whole project into the Code Warrior IDE. You may have to search for where the IDE is on your machine. By default that location will be C:Files (x86)12v5.1.exe. You may have located the Code Warrior software somewhere else when you installed the software.
Procedure to run a program in Code Warrior
Now that the project is loaded into Code Warrior we can compile and run it in our micro board.
In CodeWarrior double click on the main.c file so you can see the program that you are about to run on the micro board.
In CodeWarrior, start the Real-Time Debugger by clicking the slanted green arrow. This will compile and load the program into the micro board.
A USBDM Settings dialog box may come up, if so click on Open BDM to connect to the micro board via the USBDM module. You have the option to not show the dialog box in the future, but often this does not work.
Click on OK, once or twice until the program is downloaded to the micro board.
Run the program by clicking the horizontal green Start arrow.
Click the red T symbol to halt the program. After you do this you can single step thru the code, and/or continue by clicking the green start arrow again.
Click the red Reset Target arrow to reset the board. Only do this when you are ready to close the debugger, which you would do by clicking the exit symbol at the top right of the window.
At this point you would go back to VSCode and edit main.c as needed, save your work, and then go back to CodeWarrior. When you do this, CodeWarrior should realize that the main.c file has been changed and ask to update, upon which you would. Then you could run the program in the debugger again. There is another document in the future of this course that will show you how to set breakpoints etc. to properly debug your program.
You would do this cycle of editing in VSCode, saving in VSCode, switching to CodeWarrior, and debugging the program, until you are satisfied that your program solves the problem at hand.
VERY IMPORTANT - You must close out of CodeWarriors debug window and the main CodeWarrior window before committing and pushing your solution to github.
- Finally you would commit your changes on the local machine and push to github.