Hi I am working on a project which I need a timer to be running all the time and sampling ADC every 5 minutes , the problem is that I also need to create a PWM pulse sometime and it has to be with different frequency. I am using MSP430F2013 which does not have 2 timers. Below there is an example of the code. When it runs the LED flash very fast and the 5 minutes sampling doesn't work . Can anybody help ? I don't have the ADC sample part in this code, because it would be too big to post, but I have the timer part that I want to fix.
Thanks
void main(void)
{
CCTL0 = CCIE; // CCR0 interrupt enable
DCOCTL = CALDCO_1MHZ;
BCSCTL1 = CALBC1_1MHZ;
P1OUT &= ~ 0X40; // Sets the output to low GPIO
P1DIR |= 0X40; // Set pin P1.6 to output direction
while(1)
{
_BIS_SR(LPM0_bits + GIE); // Enter LPM0
//****************************************************************************************************************************************
// LED Control Begine
//****************************************************************************************************************************************
if (Solar_Volts >= 5024) // If Solar panel is more than 1 Volts turn LED OFF;
P1OUT &= ~0x40; // Turn LED OFF;
if (Solar_Volts <= 4521) // If Solar panel is more than 1 Volts turn LED OFF;
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
CCR0 = 1250-1; // PWM Period
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR1 = 500; // CCR1 PWM duty cycle
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
P1SEL |= 0x40; // Turn LED ON;
}
//****************************************************************************************************************************************
// LED Control Finish
//****************************************************************************************************************************************
//***************************************************************************************
// 5 MINUTES SAMPLE TIME STARTS
//
CCR0 = 61439; // CCR1 counts value for 15 seconds
TACTL = TASSEL_1 + MC_1 + ID_3; // SMCLK UP MODE
//***************************************************************************************
}
}
// Timer A0 interrup service routine
#pragma vector = TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
P1OUT |= 0X40; // Turn LED ON
}