ECE372 LAB 4

H io definitions and init routines include lcdh

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: them. They are very useful and are going to most likely a big part of most micro ­controlling systems. /* ALWAYS INCLUDE THESE LINES OF CODE */ #include <hidef.h> /* common defines and macros */ #include <mc9s12dt256.h> /* derivative information */ #include "pbs12dslk.h" /* I/O definitions and init routines */ #include "lcd.h" /* LCD definitions and init routines */ #pragma LINK_INFO DERIVATIVE "mc9s12dt256" /* END ALWAYS INCLUDE THESE LINES OF CODE */ #define _P(ADDRESS)*(unsigned char volatile *)(ADDRESS) #pragma CODE_SEG DEFAULT /*Global Variables*/ int counter=0,i,j; void main(void) { DDRB=0xF0; /*LEDS*/ PPSP=0x03; DDRP=0x00; PERP=0x03; PIEP=0x03; EnableInterrupts; LCDInit(); LCDClearDisplay(); while(1) { /*infinite loop*/ LCDPutInt('A'); /*displays “A” to screen*/ for(i=0;i<500;i++){ /*delay loop*/ for(j=0;j<500;j++){ } } LCDClearDisplay(); /*clear display, then run delay loop again*/ for(i=0;i<500;i++){ for(j=0;j<500;j++){ } } } } #pragma CODE_SEG __SHORT_SEG NON_BANKED void interrupt 56 PORT_P_ISR (void){ if(PIFP_PIFP0==1) { /*check to see if interrupt is on or off*/ PORTB=0xE0; /*if on, turn on LED4*/ PIFP=PIFP_PIFP0_MASK; } else { if(PIFP_PIFP1==1) { /*check to see if interrupt is on or off*/ PORTB=0xC0; /*if off, turn on LED3*/ PIFP=PIFP_PIFP1_MASK; } } LCDClearDisplay(); LCDPutString("intrupt "); for(i=0;i<500;i++){ for(j=0;j<500;j++){ } } LCDClearDisplay(); } #pragma CODE_SEG DEFAULT Port P 0 Port P 1 ; 8.2k ohm 8.2k ohm Vcc Vcc Start Code Start Infinite Loop INTERRUPT!!! Clear Display Write “A” to LCD Display. Write “intrupt” to LCD Display After delay loop is finished, clear display After delay loop, clear display...
View Full Document

Ask a homework question - tutors are online