The miniDragon+ Board and CodeWarrior Lecture L2.1
miniDragon+ Serial cable Reset button Power plug 2 pushbutton switches A/D Pot Run/Load switch 7-segment display I/O headers
Table 1.1 Parallel Ports in the MC9SDP256 Port Port NameDDR NameAvailable Pins miniDragon use Port TPTTDDRT7:0 Port SPTSDDRS7:0SCI(1:0) Port MPTMDDRM7:0LCD Port PPTPDDRP7:0 Port HPTHDDRH7:07-Seg Display Port JPTJDDRJ7,6,1,0 Port AD0PORTAD0Input only7:0Switches, pot Port AD1PORTAD1Input only7:0 Port APORTADDRA7:0Keypad Port BPORTBDDRB7:0 Port EPORTEDDRE7:0Mode, XIRQ Port KPORTKDDRK7, 5:0
Port Data Register Px7Px6Px5Px4Px3Px2Px1Px0PORTx Port Data Direction Register DDx7DDx6DDx5DDx4DDx3DDx2DDx1DDx0DDRx DDx[7:0]:Data Direction for Port x 0 – Input 1 – Output Registers associated with parallel I/O ports
Turning on an LED
A 7-segment display contains seven light emitting diodes (LEDs)
The miniDragon+ board has a common-cathode 7- segment display. This means that all the cathodes are tied together and connected to ground. The output pins 6:0 of Port H are connected through a 1 kW current-limiting resistor to each of the anodes, g – a. In the common-cathode case, an output 1 will turn on a segment and an output 0 will turn it off. g f e d c b a Port H: bit
Programming in C using CodeWarrior
LBE_DP256 is a stationery project that we have created that contains the file main.asm which includes over 80 assembly language routines to perform many I/O functions for the MC9S12DP256 microcontroller on the miniDragon+ board.
Example 1a is the default main.c program for a LBE_DP256 project.
// Example 1a: Turn on every other segment on 7-seg display #include /* common defines and macros */ #include /* derivative information */ #include "main_asm.h" /* interface to the assembly module */ #pragma LINK_INFO DERIVATIVE "mc9s12dp256b" void main(void) { PLL_init(); // set system clock frequency to 24 MHz DDRH = 0xff; // Port H is output PTH = 0x55; // switch on every other segment for(;;) {} /* wait forever */ } Example 1a
Lab 1 Go through the CodeWarrior tutorial in Appendix A. In this tutorial you will compile and run the C programs for Examples 1 – 4.