EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Using timmer A0 as trigger to ADC12 - msp430f2619

Started by "favero.santos" October 8, 2012
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.
}

Thx!

Cheers
Fero

Beginning Microcontrollers with the MSP430

Hello,

I did not read your full code but i can see a good starting point.

First, you are not configuring TACCTL1 which is the one that can trigger
ADC sample. For some reason you are configuring TACCTL0 and setting TACCR1
value.

About CCIS you can look at page 20 of the datasheet, It does explain all
the CCIS sources for all CCPs channels.

Regards,

On Mon, Oct 8, 2012 at 9:32 AM, favero.santos wrote:

> **
> 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.
> }
>
> Thx!
>
> Cheers
> Fero
>
>
>

--
Lu Filipe Rossi
Electrical Engineer
Biomechatronics Lab. / Grupo de Sensores Integreis e Sistemas
Escola Politnica
Universidade de S Paulo
Cel. +55 (11) 7662-9234


Hello, Luis

Thx for the point out.

I found in datasheet that table, but i just cannot understand it...
I just can't understand the connection from module block CCR1 to my
internal ADC signal....

And why should i set P2.3 port as output? I'm using the internal signal,
not the pin...

Well, as you can see, i'm totally lost with this timmer operation....

Thanks

Cheers

Fero

On Mon, Oct 8, 2012 at 1:52 PM, Luis Filipe Rossi wrote:

> Hello,
>
> I did not read your full code but i can see a good starting point.
>
> First, you are not configuring TACCTL1 which is the one that can trigger
> ADC sample. For some reason you are configuring TACCTL0 and setting TACCR1
> value.
>
> About CCIS you can look at page 20 of the datasheet, It does explain all
> the CCIS sources for all CCPs channels.
>
> Regards,
>
> On Mon, Oct 8, 2012 at 9:32 AM, favero.santos > >wrote:
>
> > **
> >
> >
> > 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.
> > }
> >
> > Thx!
> >
> > Cheers
> > Fero
> >
> >
> > --
> Lu Filipe Rossi
> Electrical Engineer
> Biomechatronics Lab. / Grupo de Sensores Integreis e Sistemas
> Escola Politnica
> Universidade de S Paulo
> Cel. +55 (11) 7662-9234
>
>
>
Hello!

Luis,

Timmer + ADC + DMA totally worked with your hint on TACCTL1....

Still, i have not fully understood what just happened...

Thx

Fero
Universidade Tecnolica Federal do Paran UTFPR
On Mon, Oct 8, 2012 at 2:12 PM, Fero Santos wrote:

> Hello, Luis
>
> Thx for the point out.
>
> I found in datasheet that table, but i just cannot understand it...
> I just can't understand the connection from module block CCR1 to my
> internal ADC signal....
>
> And why should i set P2.3 port as output? I'm using the internal signal,
> not the pin...
>
> Well, as you can see, i'm totally lost with this timmer operation....
>
> Thanks
>
> Cheers
>
> Fero
>
> On Mon, Oct 8, 2012 at 1:52 PM, Luis Filipe Rossi wrote:
>
>> Hello,
>>
>> I did not read your full code but i can see a good starting point.
>>
>> First, you are not configuring TACCTL1 which is the one that can trigger
>> ADC sample. For some reason you are configuring TACCTL0 and setting TACCR1
>> value.
>>
>> About CCIS you can look at page 20 of the datasheet, It does explain all
>> the CCIS sources for all CCPs channels.
>>
>> Regards,
>>
>> On Mon, Oct 8, 2012 at 9:32 AM, favero.santos >> >wrote:
>>
>> > **
>> >
>> >
>> > 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.
>> > }
>> >
>> > Thx!
>> >
>> > Cheers
>> > Fero
>> >
>> >
>> >
>>
>> --
>> Lu Filipe Rossi
>> Electrical Engineer
>> Biomechatronics Lab. / Grupo de Sensores Integreis e Sistemas
>> Escola Politnica
>> Universidade de S Paulo
>> Cel. +55 (11) 7662-9234
>>
>>
>>

Memfault Beyond the Launch