Message Edited by J JORDAN on 2006-12-0703:34 PM
/* * File: main.c * Purpose: sample program * */ #include "common.h" #include "mcf5xxx.h" #include __interrupt__ void pit0_irq(void) {//vector 64+55=119, source =55 //take a read from the ADC unsigned int adc_result; //store adc result here PIT0_PMR = 0x6000; ADC_CTRL1 |= (113); //start conversion adc_result = (ADC_ADRSLT0>>3); //read result register printf("%d\n\r", adc_result); fflush(stdout); } int main() { GPIO_DDRTC = 0xff; //init output port GPIO_PORTTC = 0x00; //init port pins mcf5xxx_set_handler(64 + 55, pit0_irq); //init irq //PWM module setup, outputs 1, 3, 5, 7 GPIO_PTDPAR = 0x0f; //pwm outputs on port td PWM_PWMPOL = 0xaa; //pulses high PWM_PWMCTL = 0xf0; //concatenate all 4 channels to 16bit PWM_PWMDTY0 = 0x00; PWM_PWMDTY1 = 0x10; PWM_PWMPER0 = 0xff; PWM_PWMPER1 = 0xff; PWM_PWMSCLA = PWM_PWMSCLB = 8; PWM_PWMCLK = 0xaa; //select scaled clocks PWM_PWME = 0xaa; //enable all channels //PIT module setup PIT0_PCSR = PIT_PCSR_PRE(11)|PIT_PCSR_PIE| PIT_PCSR_RLD|PIT_PCSR_EN; PIT0_PMR = 0x6000; //configure analog to digital converter ADC_CTRL2 = 3; //clock div assuming fast clock ADC_ADSDIS = (11); //stop at AN1, only perform sample0 with AN0 ADC_POWER &= ~(0x0001); //power up adc A GPIO_PANPAR = 1; //setup AN0 to primary pin function INTC_ICR55 = 0 | INTC_ICR_IP(6) | INTC_ICR_IL(6); //set priorities for pit0 irq55 INTC_IMRH &= ~INTC_IMRH_MASK55; //unmask that specific interrupt mcf5xxx_irq_enable(); while(1) { } }