Hi!
I'm working with the launchpad MSP430G2553, and I'm trying to read two channels of the ADC10 module and based on the values that I read, set the PWM module to an specific duty cycle. I already read two channels of the ADC succesfully and the program that I use update the TACCR1 register of the PWM module but I don't know why my PWM signal doesn't change. Can anybody help me please please please :) ?. This is an important part of my tesis.
This is the code of my program :/ :
#include <msp430.h>
unsigned int pointer[2];
int jum;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL1 = INCH_2 + CONSEQ_3; // A1/A0, repeat multi channel
ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE;
ADC10AE0 = 0x06; // P1.1,2 ADC option select
ADC10DTC1 = 0x20; // 16 conversions
P1DIR |= 0x08; // P1.3 = output
P1SEL |= 0x08; // P1.3 = TA1 output
TACCR0 = 1024 - 1; // PWM Period
TACCTL1 = OUTMOD_7; // TACCR1 reset/setje
TACCR1 = 512; // TACCR1 PWM Duty Cycle
TACTL = TASSEL_2 + MC_1; // SMCLK, upmode
for (;;)
{
ADC10CTL0 &= ~ENC;
while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active
ADC10SA = (unsigned int)&pointer; // Data buffer start
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion ready
__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
_NOP(); // space for debugger
_NOP(); // Set Breakpoint here to read ADC
}
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{ jum = pointer[0];
TACCR1 = jum;
//ADC10SA = (unsigned int)&TACCR1; // Data transfer location
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}