This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC REPEAT SECUENCE (2 CHANNELS) AND PWM

Other Parts Discussed in Thread: MSP430G2553

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)
}

  • Instead of using all the possible advanced stuff (like DTC) and getting result that "nothing works" and you don't understand what's wrong, u shall start from very basic approach: single channel sampling using ADC ISR which contain single line, TACCR1 = ADC10MEM; When this is working - THEN scale it up if needed.

  • Thank u, I finally solved that trouble. The issue was in the pin that I was using, the pin P1.3 is not able to get a PWM signal created from the TACCR1 register, the pins that are able to do that are P1.2, P1.6 and P2.6; I used the pin P1.6 as output f the PWM and everything wrks well.

  • ADC10CTL1 = INCH_2 + CONSEQ_3; // A1/A0, repeat multi channel

    You are actually reading A2, A1, A0 so I think the data in pointer[1], pointer[0] will constantly vary.

**Attention** This is a public forum