Help getting started with Codewarrior and MC9S12C32

cancel
Showing results for 
Search instead for 
Did you mean: 

Help getting started with Codewarrior and MC9S12C32

2,695 Views
JonP
Contributor I
Hi,

I recently completed a microcontrollers class at my university. We used the MC9S12C32 and coded exclusively in assembly using AsmIDE. I would like to start coding in C using Code Warrior (I have the special edition that came with my 9S12 installed), but I am completely confused on using the program. I found some tutorials on how to create a new project, but I cannot seem to find any step by step tutorials on the following:

1. How C fits into Code Warrior and can be used with my micro.
For example, I have seen examples using a function EnableInterrupts() which is self explanatory. Where do you find a list of all these functions? Where is a reference list of variables that define the register locations? How do I create multiple C source code files and link them together? What C features are not supported?

2. Mixing C and assembly code.
What problems should I look out for? Is it possible to reserve space for a variable with assembly code and reference that variable in C?

3. Monitoring the registers and memory space on my micro with the debugger. Is this even possible?

4. Compiling project code and transferring to my micro.

If someone can point me to tutorials on those questions, I believe a lot of my frustration will be relieved. Bonus points for a tutorial that starts with a new project and ends with a completed project loaded onto the micro. Thanks in advance!


Jon
Labels (1)
Tags (1)
0 Kudos
3 Replies

21 Views
CompilerGuru
NXP Employee
NXP Employee
>1. How C fits into Code Warrior and can be
>used with my micro.
>For example, I have
>seen examples using a function
>EnableInterrupts() which is self explanatory.

Well, its not a function at all. It is a macro as Lundin already mentioned.
After building the project once, you can jump to the definition of it.

>Where do you find a list of all
>these functions?
All the macros defined in hidef.h are defined in hidef.h :smileyhappy:
Well, I know, not really helpful. Most of the functions defined in the ANSI library are for ANSI-C compliance, so any good book on the language should explain them. The compiler manual also contain a chapter about the ANSI functions (contained as pdf in the help/pdf directory). But knowing C a bit helps.

>Where is a reference list of variables that
>define the register locations?
The IO peripherial registers are described in pdf's you can download from the freescale web site. The header file contained for the C32 is using the same names. When you create a project with the wizard, the right header is already included and you can start using them.

>How do I create multiple C source code files
>and link them together?
Just add all the C files to your project, or is the question how to do this in C?
Anyway, start with one file. Once this works, start splitting it up.

>What C features are not supported?

All the basics are there. The only things not supported are are things like file IO, just as there is no file system. Also printf needs some SCI inteface code, otherwise linking fails.

>2. Mixing C and assembly code.
>What problems should I look out for?
>Is it possible to reserve space for a
>variable with assembly code and reference
>that variable in C?
Sure.
You did read about the wizard and how it creates projects. If you select both C and asm during the wizard, the generated project contains both a C file and an assembly file. So you see the basics in there. In the end it depends on how deeply you want to interact between C and assembly, as starter I would start with C or assembly, and once you control one of the two languages, start interacting with the other.

>3. Monitoring the registers and memory space
>on my micro with the debugger.
>Is this even possible?
Of course! But (there has to be a but), there are different ways to connect from the debugger to the target system, and I'm not sure what you have available.
>4. Compiling project code and transferring
>to my micro.

>If someone can point me to tutorials on
>those questions, I believe a lot of my
>frustration will be relieved.
>Bonus points for a tutorial that
>starts with a new project and ends with
>a completed project loaded onto the micro.
>Thanks in advance!

Jon




Did you check the HCS12X_Quick_Start.pdf on the root of the installation? Well, it ends up running the code on the simulator, but that's a start. And if you do have a board properly configured in front of you connected with one of the supported ways to connect, then all it needs for hardware is to pick another connection in the last step in the wizard. Which connection and how to set it up really depends on what you have in front of you :smileywink:.
0 Kudos

21 Views
Lundin
Senior Contributor IV
All those questions can be answered by looking at either the app notes or the examples that came with Codewarrior. There should be a directory called "Technical Notes" in your CW directory. If not, re-install the compiler and make sure you get it.

hidef.h contains various definitions like EnableInterrupts. I wouldn't recommend using it though, writing "asm CLI" directly in the code makes the code more portable, in case you want to pick another compiler in the future.
0 Kudos

21 Views
CompilerGuru
NXP Employee
NXP Employee

As far as I know, the "Technical Notes" are not installed as part of the normal installation. I think they are contained as separate installer on the normal installation CD, also you can download them them separately out of

http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId=01272694011135

here's is a direct URL:

http://www.freescale.com/files/soft_dev_tools/doc/support_info/CW_816-bit_Technical_Notes_SP.zip

Just wanted to add this note before someone is uninstalling CW :smileywink:

Danie

(Alban link highlight)

Message Edited by Alban on 2006-12-21 11:41 AM

0 Kudos