//Testing HCS12 MCU Module (from Freescale or Axiom) by Toggling PORTB in C Language //HCS12 MCU Modules can be used with Freescale Student Project Board and they are made by Axiom. //They can also be used as stand-alone without the project Board. This C code tests the MCU Module without the Project Board //The HCs12 MCU Modules are either C128 (HCSxxx128), DT256 (HCSxxx256), or XDT512 (HCSxxx512). See the designation on your Module. //These HCS12 MCU Module comes with BDM and ready to work with CodeWarrior(only). Connect the module to the x86 PC USB port via a USB cable. //The MCU module has 4-bit green LEDs and are located between Brown POT and Blue DIP SW. //The LEDs are connected to PORTB7-PORTB4 via row of jumpers right in front of LEDs. //Make sure the Jumpers are set for LEDs. They are designateed as LED1-LED4 //Make sure the VB jumper for Power_SEL (next to power jack) is ALSO set. VB is the middle Jumper and allows the power come from USB cable (500 mA Maximum) //WHEN USB CABLE IS THE EXCLEUSIVE PROVIDER OF POWER TO CPU MODULE, NEVER USE IT TO DRIVE POWER HUNGRY DEVICES SUCH AS DC OR STEPPER MOTORS //Modified from an example from Chapter 7 of HCS12 textbook by Mazidi & Causey //Written and tested by Mazidi //In CodeWarrior, make sure you are in TBDML Mode before downloading //Press F7 (to Make), then F5(Debug) to downLOAD,and F5 once more to start the program execution #include /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ void MSDelay(unsigned int); void main(void) { /* put your own code here */ DDRB = 0xF0; //PORTB7-POTB4 as output since LEDs are connected to it, Make sure to set the jumpers for it for(;;) { PORTB = 0x50; //Toggle upper 4-bit of PORTB MSDelay(500); //1/2 sec delay PORTB = 0xA0; MSDelay(500); } } //millisecond delay for XTAL=4MHz //Axiom HCS12 MCU module uses 4 MHz XTAL for HCS12 . void MSDelay(unsigned int itime) { unsigned int i; unsigned int j; for(i=0;i