17
The miniDragon+ Board and CodeWarrior Lecture L2.1

The miniDragon+ Board and CodeWarrior

  • Upload
    zhen

  • View
    64

  • Download
    0

Embed Size (px)

DESCRIPTION

The miniDragon+ Board and CodeWarrior. Lecture L2.1. 2 pushbutton switches. Serial cable. A/D Pot. Run/Load switch. Reset button. 7-segment display. Power plug. I/O headers. miniDragon+. Table 1.1 Parallel Ports in the MC9SDP256. Registers associated with parallel I/O ports. - PowerPoint PPT Presentation

Citation preview

Page 1: The miniDragon+ Board and CodeWarrior

The miniDragon+ Boardand CodeWarrior

Lecture L2.1

Page 2: The miniDragon+ Board and CodeWarrior

miniDragon+

Serial cable

Reset button

Power plug

2 pushbutton switches

A/D Pot

Run/Load switch

7-segment display

I/O headers

Page 3: The miniDragon+ Board and CodeWarrior

Table 1.1 Parallel Ports in the MC9SDP256

PortPort Name DDR Name Available

PinsminiDragon

usePort T PTT DDRT 7:0

Port S PTS DDRS 7:0 SCI(1:0)

Port M PTM DDRM 7:0 LCD

Port P PTP DDRP 7:0

Port H PTH DDRH 7:0 7-Seg Display

Port J PTJ DDRJ 7,6,1,0

Port AD0 PORTAD0 Input only 7:0 Switches, pot

Port AD1 PORTAD1 Input only 7:0

Port A PORTA DDRA 7:0 Keypad

Port B PORTB DDRB 7:0

Port E PORTE DDRE 7:0 Mode, XIRQ

Port K PORTK DDRK 7, 5:0

Page 4: The miniDragon+ Board and CodeWarrior

Port Data Register

7 6 5 4 3 2 1 0

Px7 Px6 Px5 Px4 Px3 Px2 Px1 Px0 PORTx

Port Data Direction Register 7 6 5 4 3 2 1 0

DDx7 DDx6 DDx5 DDx4 DDx3 DDx2 DDx1 DDx0 DDRx

DDx[7:0]: Data Direction for Port x0 – Input

1 – Output

Registers associated with parallel I/O ports

Page 5: The miniDragon+ Board and CodeWarrior

V2R LED

V2R LED

V1 > V2No current

Currentlight

no light

V1 < V2

Turning on an LED

Page 6: The miniDragon+ Board and CodeWarrior

A 7-segment display contains seven light emitting diodes (LEDs)

a b c d e f g

a b c d e f g

+5V

CommonAnode

CommonCathode

a

b

c

d

e

fg

Page 7: The miniDragon+ Board and CodeWarrior

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 aPort H: bit 6 5 4 3 2 1 0

a b c d e f g

a b c d e f g

+5V

CommonAnode

CommonCathode

a

b

c

d

e

fg

Page 8: The miniDragon+ Board and CodeWarrior

Programming in Cusing CodeWarrior

Page 9: The miniDragon+ Board and 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.

Page 10: The miniDragon+ Board and CodeWarrior

Example 1a is the default main.c program for a LBE_DP256 project.

Page 11: The miniDragon+ Board and CodeWarrior

// Example 1a: Turn on every other segment on 7-seg display#include <hidef.h> /* common defines and macros */#include <mc9s12dp256.h> /* 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

Page 12: The miniDragon+ Board and CodeWarrior
Page 13: The miniDragon+ Board and CodeWarrior
Page 14: The miniDragon+ Board and CodeWarrior
Page 15: The miniDragon+ Board and CodeWarrior
Page 16: The miniDragon+ Board and CodeWarrior
Page 17: The miniDragon+ Board and CodeWarrior

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.