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.

Timmer as a trigger source to ADC12 - MSP430F2619

Other Parts Discussed in Thread: MSP430F2619

Hello!

How are you all doing? Hope everything's fine.

So, i'm trying to do the following:
Timer ---triggers--> ADC --samples--> DMA --moves to memmory--> end

Right now, i'm facing problems with the timmer and ADC interfacing.

The way i want it to works is that the timmer (not using its interruption) auto
triggers adc samples.
NOTE: I've already made timmer starts ADC sampling with timmer interruption and
an ADC start convertion manually set. But, that's not the way i want it to work!

As i said, timmer must counts and generate a trigger to ADC. ADC's interrupt is
handled by my DMA, moving results from ADC12MEM0 to a certain memory region.

Here goes some codes:

timmer.c

void timer_go_on(void)
{
TACCTL0 = CM_0 + CCIS_0 + OUTMOD_4;
// CM_0 -> Comparation mode
// CCIS_0 -> Comparation by CCIA input
// OUTMOD_0 -> Comparation mode: Toggles pin P2.3 when TAR reaches 159.
TACCR1 = 159;
// Sampling period
TACTL = TASSEL_2 + ID_0 + MC_1 + TACLR;
// TASSEL_2 -> SMCLK as source
// ID_0 -> Clock divided by 1
// MC_1 -> Up mode till TACCR0
// Timming: 1/(8M/1/(159+1)) = 50K Hz
}

1) Why when i add CCIE to TACCTL0 and enter in LPM0 my uC doesn't seens to work?
2) I could not understand completely CCIS... I've searched my msp430f2619
datasheet, but i could found nothing about it (same as user guide).

adc.c

void adc_go_on(void)
{
ADC12CTL0 &= ~ENC;
// Let's configure ADC
ADC12CTL0 |= ADC12ON + MSC;
// MSC -> Multiple start convertion.
// ADC12ON -> ADC on
ADC12CTL1 |= CSTARTADD_0 + SHS_1 + ADC12DIV_0 + ADC12SSEL_3 + CONSEQ_2;
// CSTARTADD_0 -> Adressing samples to ADC12MEM0
// SHS_1 -> Trigger source: Timer A0
// CONSEQ_2 -> Single channel, repetitive
// SHP -> Temporized mode
// ADC12SSEL_3 -> Clk source: SMCLK
// ADC12DIV_0 -> Clk divider = 1.
ADC12MCTL0 |= SREF_0 + INCH_0;
// INCH_0 -> Channel A0 as ADC sampling source
// SREF_0 -> Using Vss and Gnd refs.
ADC12IE = 0x1;
// Enable interrupt.

ADC12CTL0 |= ENC;
// ADC go working
}

#pragma vector=ADC12_VECTOR
__interrupt void adc_sampling(void)
{
// Do DMA transfer from ADC12MEM0.
}

3) Do you know guys what i'm getting wrong on this?

PS: a __bis_SR_register(GIE) is set during a part of my code (after those inits).

Cheers
Fávero

  • F���vero Santos said:
    2) I could not understand completely CCIS...

    CCIS is for capture mode. Capture mdoe captures the current timer count when an external event occurse. CCIS selects which signal (internal or external, depending on chip and CCR module and timer) is monitored.
    Fr triggering the ADC, you use compare mode, so CCIS is meaningless.

    in Tiemr_go_on, you configure TACCTL0, but write your interval time (159) to TACCR1. So TACCR0 is still 0 and the tiemr will run from 0 to 0. I'm not sure whether it will trigger the ADC on every timer tick or never. Possibly on every timer tick, which will actaully bring the main thread execution to a halt when you set CCIE for calling an ISR. Or, if you don't have an ISR at all, it will crash the CPU on the first interrupt.

    It is not necessary to output the capture signal to a port pin. The timer is triggered by the internal signal, even if the port pin is still GPIO.

    You can setup the DMA to do the data transfer directly on ADC12IFG (it makes not much sense calling the ADC12ISR to start the DMA transfer - then you could as well just copy and paste the conversion result). But then ADC12IE must not be set.

    When you set MSC bit, one timer pulse will start a whole sequence. SO if you want to trigger each individual conversion by the timer, then thsi bit msu tbe clear.
    SHP controls the sampling gate. If you set the bit, the sampling time (after timer trigger), the covnersion will be controlled by the SHTx bits. If SHP is not set, the tierm directly controls the sampling time. While the timer outpout signal is high (or low, this is selectable), the sampling gate is opened, when the timer output goes low, the sampling gate is closed and the conversion starts.

    A typical setup would be:

    configure the ADC to do one conversion on each timer trigger, do not set the IE bit for teh conversion result.
    configure the DMA to do n transfers from the ADC12MEM resutl register to a memory buffer (with increasing destination address). When done, teh ADC will trigger an interrupt.
    configure the timer to generate the trigger for the ADC
    start the timer and go into LPM
    Finally, after n conversions, the DMA ISR is called and you're done.

    Many variations of this are possible, depending on your exact requirements.

**Attention** This is a public forum