#include /* common macros and defines */ #include /* derivative information */ #pragma LINK_INFO DERIVATIVE "mc9s12c128" #include #include "lcd_lib.h" #include "modclock.h" //globals unsigned char ad0_in; //store AD0 value unsigned char ad1_in; //store AD1 value unsigned char chase_counter; //keep track of lit LED //defines #define PAUSE_BUTTON_MASK 0x04 #define ATD_INTERRUPT_INDICATOR 0x80 #define TIMER_INTERRUPT_INDICATOR 0x40 void main(void) { //TODO declare main-loop local variables clockSetup(); lcdSetup(); /************************************ * PWM CONGIFURATION * ************************************/ /* Configure Port P as follows: PTP0 as PWM0 output PTT1-7 as regular digital outputs Configure PWM0 as follows: Clock rate is 500 kHz EDIT: kHz not MHz No concatenation Left aligned PWM Period = 0xFF Default duty cycle = 0x80 */ //TODO Setup PWM and Port T /************************************ * A/D CONGIFURATION * ************************************/ /* Configure Port AD as follows: AD0, AD1 as analog inputs AD2-7 as digital inputs Configure A/D converter as follows: Enable interrupt on conversion completion Conversion sequence covers channels 0 and 1 Freeze mode behavior: freeze after current conversion ATDclock frequency = 666,666 Hz ATD conversion is 8 bits ATD phase 2 sample time is 2 ATD clock periods Multichannel, continuous conversion, non-FIFO Store result in unsigned, left justified format */ //TODO Setup ATD /************************************ * TIMER CONGIFURATION * ************************************/ /* configure the timer for: clock rate = 0.5 MHz reset timer on successful timer 7 output compare stop in freeze and wait modes configure Timer 7 for the following: output compare with a default compare value of 0xF000 enable interrupt on successful compare */ //TODO Setup Timer //TODO One-time initilization of locals and globals EnableInterrupts; /* Main Loop Task: Display the current value of ad0_in and ad1_in on the LCD and then wait 100 ms. Format of display shall be (numbers displayed in Hexadecimal notation): -------- 0: 0x## 1: 0x## -------- */ for(;;) { //TODO Implement main loop task } /* wait forever */ /* please make sure that you never leave this function */ } /* ATDInterrupt: */ void interrupt ?? ATDInterrupt( void ) { PTT |= ATD_INTERRUPT_INDICATOR; //TODO Implement ATD ISR PTT &= ~ATD_INTERRUPT_INDICATOR; } /* timer7Interrupt */ void interrupt ?? timer7Interrupt(void) { PTT |= TIMER_INTERRUPT_INDICATOR; //TODO Implement Timer ISR PTT &= ~TIMER_INTERRUPT_INDICATOR; }