Hi, I am using MSP430G2553 in my design. I want Watchdog timer to trigger ADC10 Conversion in an interval of 1 msec. I am operating ADC10 in single sequence mode and total number of ADC channels are 4. After taking 10 samples (each channel) of all the ADC channel. i.e. total conversion 4*10 = 40, i want to take the average of each channel separately. I have written the code but stuck at the WDT_ISR function. According to my understanding it should be: void WDT_init (void) { WDTCTL = WDT_MDLY_16; // WDT 16ms, for SMCLK = 1Mhz,here SMCLK = 16Mhz so timer interval = 1ms IE1 |= WDTIE; // Enable WDT interrupt __bis_SR_register(GIE); // Enable global interrupt } #pragma vector = WDT_VECTOR __interrupt void WDT_ISR(void) { /* Watchdog Timer interrupt service routine * Here for each interrupt, it triggers ADC to take readings * Also use DTC for transferring adc reading to an array */ ADC10CTL0 |= ADC10ENC + ADC10SC; // Sampling and conversion start while (ADC10CTL1 & ADC10BUSY); // Wait for conversion ADC10SA = (unsigned int)ADC_Readings; // Transfer adc readings to an array using DTC ADC10CTL0 &= ~ENC; //CLEAR ENC bit /*code for calculating average value of 10 samples by accessing array*/ } NOW, MY QUESTION IS: 1. Can i write these many steps in ISR function itself. //Normally ISR should be as small as possible. 2. if NO , how can i optimize the code in msp430g2553 to find out the average value of 10 samples. //Since msp430g2553 does NOT have full fledged DMA 3. How to find out the time taken by WDT_ISR to execute all the steps including ADC conversion //As all the step should execute within 1 msec because WDT_ISR will be called in an interval of 1 msec PLEASE HELP!!
↧