Other Parts Discussed in Thread: MSP430G2253
Hello
I'm developing a test software in a msp430g2253.
The application uses the ADC10 to sample 1 channels repeat in period of 10 ms (in this case I know that the valor of TA0CCR0 isn´t the corret, only a random number).
To accomplish this I'm using TimerA0.0 to trigger the start conversion on ADC10
#include "msp430g2253.h"
//int contador;
//int contadorADC;
unsigned int ADC_valor=0;
void ConfigureAdc(void);
void ConfigureTimer(void);
void adc_Sam10(void);
void main(void)
{
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_16MHZ; // Set range DCOCTL = CALDCO_16MHZ;
DCOCTL=CALDCO_16MHZ;
BCSCTL3 |= LFXT1S_2; // VLOCLK
//BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO = 1MHz
P1SEL |= BIT4; // ADC input pin P1.4
// contador=0;
//contadorADC=0;
ConfigureTimer();
ConfigureAdc(); // ADC set-up function call
__enable_interrupt(); // Enable interrupts.
while(1)
{
adc_Sam10();
}
}
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
//contadorADC=contadorADC+1;
//P1OUT ^= BIT6;
__bic_SR_register_on_exit(CPUOFF); // Return to active mode }
}
#pragma vector=TIMER0_A0_VECTOR // Timer0 A0 interrupt service routine
__interrupt void Timer0_A0 (void) {
//contador=contador+1;
//P1OUT ^= BIT6; // Toggle green LED
__bic_SR_register_on_exit(CPUOFF); // Return to active mode }
}
// Function containing ADC set-up
void ConfigureAdc(void)
{
ADC10CTL1 = INCH_4 + SHS_2 + CONSEQ_2; // Channel 4, modo un canal repetidamente, timer ,timer0
ADC10CTL0 = SREF_0 + ADC10SHT_0 + ADC10ON + ADC10IE; // Vcc & Vss as reference, Sample and hold for 64 Clock cycles, ADC on, ADC interrupt enable
ADC10AE0 |= BIT4; // ADC input enable P1.4
}
void ConfigureTimer(void)
{
TA0CCR0 = 1000; // Count limit (16 bit)
TA0CCTL0 = 0x10; // Enable Timer A0 interrupts, bit 4=1
TA0CTL = TASSEL_1 + MC_1; // Timer A0 with ACLK, count UP
}
// ADC sample conversion function
void adc_Sam10(void)
{
ADC10CTL0 &= ~ENC; // Disable Conversion
while (ADC10CTL1 & BUSY); // Wait if ADC10 busy
ADC_valor = ADC10MEM;
ADC10CTL0 |= ENC + ADC10SC; // Enable Conversion and conversion start
__bis_SR_register(CPUOFF + GIE);// Low Power Mode 0, ADC10_ISR
}
I'm debugging the code using the JTAG and CCS Studio, and I see that on the breakpoint inside the Main Loop, the ADC interruption never is triggered and I cant understand where is the problem
Thanks for any help and suggestions.