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.

help



sir,

i need to write a program like by varying the input voltage i can change the pulse width .For that i used the following code,but i dont know how to see the output and how should i coonnect potentiometer to change the input voltage.Plz help me.

#include <io430x22x4.h>
#include <intrinsics.h>
void main (void)
{
WDTCTL = WDTPW | WDTHOLD;
P2SEL = BIT6;
P2OUT = 0;
P2DIR = BIT6|BIT7;
P1OUT = BIT5;
P1DIR = BIT3|BIT5|BIT6|BIT7;
TACCR0 = BITA;
TACCTL0 = CCIE;
TACCR1 = BIT9;
TACCTL1 = OUTMOD_7;
TACTL = TASSEL_2 | ID_3 | MC_1 | TACLR;
ADC10CTL0 = SREF_0 | ADC10SHT_0 | ADC10ON;
ADC10CTL1 = INCH_1 | SHS_0 | ADC10DIV_0 | ADC10SSEL_0 | CONSEQ_0;
ADC10AE0 = BIT1;
ADC10CTL0_bit.ENC = 1;
for (;;)
{
__low_power_mode_0 ();
}
}
#pragma vector = TIMERA0_VECTOR
__interrupt void TIMERA0_ISR (void)
{
TACCR1 = ADC10MEM;
ADC10CTL0_bit.ADC10SC = 1;
}

regards

chandrika.

  • chandrika surapaneni said:
    how should i coonnect potentiometer to change the input voltage

    That one is easy: connect the potentiometer etween either VREF (if using the internal VREF) or simply VCC and GND. The 3rd pin in the middle goes to the analog input. Using a linear potentiometer of e.g. 10k (to keep its impedance well below the input impedance), the voltage on teh output changes linear with the slider position. If using VCC as top point, VCC must be selected as reference in the ADC setup. Since we just need a relative position, VCC as reference is exactly as good as using the internal (usually more precise) 2.5 or 1.5V reference.

    chandrika surapaneni said:
    i dont know how to see the output

    Provided your ADC setup is working (I didn't check), well, I don't exactly understand what you try to do. You set P2.6 to module use. But the module use on this pin is XIN. So do you attach a digital oscillator for external clocking? I ask because for a crystal, you'd have to set BIT7  on P2SEL too, and ther eis no other module use for these pins than attaching a crystal or oscillator. Yet I don't see any handling of the clock module, so this remains a mystery.

    To get TACCR1 output appear on any device pin, you need to either do

    P1SEL |= BIT2; P1DIR|=BIT2;

    for getting the signal from CCRA0 on device pin 33, or

    P2SEL |= BIT3; P2DIR|=BIT3;

    and get the TA0CCR1 signal on pin 29, which is also the input for the external reference or the internal reference output, if selected, or for the OA. Or

    P1SEL |= BIT6; P1DIR|=BIT6;

    for pin 37, which probably is what you tried. But if so, you forgot to do the P1SEL too, so all you got is a constant GPIO output, not the signal from the CCR1 unit.

    It's not easy to interpret what an undocumented (uncommented) code is intended to do, especially if it is a known fact that it actually does NOT do what it is intended to do. This leaves way too much room for interpretation and guessing.

**Attention** This is a public forum