DOC PREVIEW
USC EE 459Lx - CodeWarrior-C

This preview shows page 1-2-19-20 out of 20 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Ming Hsieh Department of Electrical EngineeringEE 459Lx - Embedded Systems Design LaboratoryProgramming the Freescale MC908JL16 in C(for CodeWarrior V6.x)byAllan G. Weber and Mark Redekopp1 IntroductionThis document discusses the use of the CodeWarrior for Microcontrollers, Special Edition software for pro-gramming the Freescale HC08 microcontrollers in C. Much if this document is generic and applies to anyprocessor in the HC08 family. However parts that discuss things like memory layout are specific to theprocessor currently being used in the class. The class is currently using the MC908JL16 (sometimes listed asMC68HC908JL16.) If the CodeWarrior compiler is used for other HC08 processors the information in theseareas will have to be adjusted to match the other processor.2 Installation InstructionsThe CodeWarrior installation software can be obtained from the instructor if you wish to install the softwareon your own system. It should run on any Windows XP or Windows 7 system. To install the software:• Copy the installation file to your hard drive. Depending on the version it will have a name like“CW_MCUs_V6_3.exe”.• Double-click on the file you just copied. There may also be some patch or updates file with it.• Proceed through the series of questions and agreements posed to you. The program will try to installitself under the Program Files folder of your C drive. Feel free to change that if you desire. When youare asked what type of installation you desire, choose “Complete”.• If there are any update files these can also be installed.• After the installation is complete, reboot your system.The CodeWarrior application can be found in the Start menu under “All Programs”, “Freescale Code-Warrior”, “CW for Microcontrollers V6.x”, “CodeWarrior IDE”. You should now be ready to run the Code-Warrior development system to create software for your microcontroller.3 Starting a New ProjectIn order to create a program for your microcontroller, you must first have CodeWarrior create a project. ACodeWarrior project is a folder that contains all the necessary files and configuration information to buildthe project. Start CodeWarrior from the desktop icon or the Start menu and follow these steps.• File. . . New Project. . . . This will bring up the new project wizard to gather information about yourproject.EE 459Lx, Rev. 5/29/13 1• On the Device and Connection screen select the microcontroller you will be using. For most of theclass projects it should be the MC68HC908JL16. Open up the “HC08” list and then open the “JK/JLFamily” list. Click on the microcontroller being used.In the “Connections” box, select “P&E Multilink/Cyclone Pro” if you will be using the USB program-ming hardware, or “Mon08 Interface” to use the Freescale development boards. See Sec. 9 for moreinformation on the programming hardware. Click “Next”.• On the Project Parameters screen, select the programming language. C is recommended since it allowsfor larger projects. Selecting C++ limits the program size to only 1KB. Type a project a name in thetext box. CodeWarrior will create a folder of this name under your “My Documents” folder or you canchange the location. Click “Next”.• On the Add Additional Files screen you can add source files to the project (this can also be done later.)Select the files to add and then click on “Add”. If the “Copy files to project” button is selected thefiles will be copied into the “Sources” folder in the project folder the new project wizard is creating.Use this option if you are going to create your project by modifying one of the demo or template files.If this option is not selected, the source files are left in their original location.One file in the project must contain the “main()” routine. If the “Create main.c/main.asm file” boxis checked, CodeWarrior will add a main.c file to your project containing this routine. You can lateredit this file to add your own code. Alternatively you can uncheck the main.c box and add your ownfile that contains a main routine. This method is easier if you are copying a main program from someother project. However it is done there must be one, and only one, file that contains a main routine.Click “Next”.• On the Processor Expert screen, select “None” when it asks about Rapid Application DevelopmentOptions. Click “Next”.• On the C/C++ Options screen:– Select “ANSI startup code”.– For the memory model select “Small”. The small memory model allows access to all of the 512bytes of RAM in the JL16 processor. If you know you only need a few bytes of RAM you can selectthe “Tiny” memory model which restricts access to only 160 bytes. It’s highly recommended thatyou use the “Small” model.– For floating point, select “None” if your project has no need to do calculations in floating pointarithmetic. If your project requires doing floating point calculations, select one of the choices forthe size of “double” variables, either 32 bits or 64 bits. In either case “float” variables will be32 bits. For more on using floating point see Sec. 5.11.– Click “Next”;• On the PC-Lint screen select “No”. Click on “Finish”.At this point CodeWarrior will create the project folder and bring up the project window.4 Navigating Through Your ProjectAfter CodeWarrior creates your project you will see the project window as shown in Figure 1. In the left-handwindow pane you will see a folder structure for the files that are part of your project.• The “Sources” folder contains your source files. In that folder you should see the files you asked to beadded to your project. If you didn’t add any and selected the option to have CodeWarrior create amain.c it will show up here and you can either edit main.c or replace it with another file. If you chooseto replace it, use the “Remove” command under the Edit menu to delete main.c from the project, thenuse the “Add Files” command under the Project menu to add a different main program file. Other Cfiles can also be added to the project. Double-clicking the file will open it in the CodeWarrior editor.EE 459Lx, Rev. 5/29/13 2Figure 1: New C Language Project Structure• The “Includes” folder contains files specific to model of microcontroller you are using. Your programshould reference the “derivative.h” file which then references the correct include file for your


View Full Document

USC EE 459Lx - CodeWarrior-C

Download CodeWarrior-C
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CodeWarrior-C and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CodeWarrior-C 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?