//Toggling 8 LEDs on PORTA using Freescale Student Project board with HCS12 MCU Module from Axiom //HCS12 MCU Modules come with USB-BDM. This code is for CodeWarrior IDE only //Notice the following facts about the Student Project Board //a) the lower 4 bits of PA3-PA0 are connected to LEDs(LED1-LED4 on J10) permanently //b) they must be enabled by clearing bit P4 of PORTP. //c) ON the Project Board, MAKE SURE jumper for these LEDs is set. LED JUMPER is part of group of jumpers called UFEA right next to the Buzzer //d) We also need to connect 4 wires from LED5-LED8 (J10) to pins PA7-PA4 via J6 connector(pins 25,27,29,31) //On HCS12 MCU Module itself, //a)MAKE SURE ALL the jumpers for PORTB are removed.(SW3-1...SW3-4 and LED1-LED4) //b)The 8 Jumpers (SW3-1...SW3-4 and LED1-LED4) on HCS12 MCU module connect the PORTB to SW and LEDs of the Module itself. //c)The PORTB can be either used by the HCS12 MCU Module itself or the Project Board, but not both of them at the same //WE USE THIS LAB EXTENSIVELY IN FUTURE LABs. SO KEEP THE LEDs CONNECTED TO PORTA7-PORTA4. THIS WAY WE HAVE 8 LEDs //See Chapter 7 of Mazidi & Causey HCS12 textbook //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 */ DDRA = 0xFF; //PORTA as output since LEDs are connected to it DDRP = DDRP | 0b00010000; //on Project Board, the lower 4 bits of PA3-PA0 are connected to LEDs(LED1-LED4) permanently PTP = PTP & 0b11101111; //and must be enabled by clearing bit P4 of PORTP //on Project Board,we need to connect 4 wires from LED5-LED8 (J10) to pins PA4-PA7 via J6 connector (pins 25,27,29,31) for(;;) { PORTA = 0x55; MSDelay(500); //1/2 sec delay PORTA = 0xAA; MSDelay(500); } } //The HCS12 MCU Module works with XTAL=4MHz //Freq. for Instruction Clock Cycle (Bus Freq.) is 2MHz (1/2 of 4MHz). void MSDelay(unsigned int itime) { unsigned int i; unsigned int j; for(i=0;i