Reply by "Jon...@infinitefactors.org [msp430]" May 19, 20142014-05-19
On Mon, 19 May 2014 18:03:18 +1000, you wrote:

>Hi Jon,
> thank you and Al for your time.
>I've had to switch to a different job for a few days, so will let you
>know when I have got back to it and tried your suggestions.
>
>To answer your question at the end, yes one of my aims is to control the
>DCO. But I hope to do more in that one ISR.

Don't do too much there. You want it very tight. If you can,
set flags and let other code do the work when they see the
flags. Do as little as you can get away with directly in the
ISR itself. It's important.

>Let you know how I go.
>Cheers.
>Pete L.

Thanks. I'll be interested in hearing.

Jon


Beginning Microcontrollers with the MSP430

Reply by "Pet...@sensair.com [msp430]" May 19, 20142014-05-19
Hi Jon,
thank you and Al for your time.
I've had to switch to a different job for a few days, so will let you
know when I have got back to it and tried your suggestions.

To answer your question at the end, yes one of my aims is to control the
DCO. But I hope to do more in that one ISR.

Let you know how I go.
Cheers.
Pete L.

On 19/05/2014 5:47 PM, Jon Kirwan j...@infinitefactors.org [msp430] wrote:
> On Thu, 15 May 2014 21:19:30 +1000, you wrote:
>
> >Hi Guys,
> > I'm trying to setup the DCO and timer on a F2013. So far very confused.
> >What I would like to do is setup the DCO for 16MHz from the 32678Hz
> >crystal, then feed the undivided DCO (mclk) to the timer counter, and
> >capture the 32768Hz (undivided aclk) with CCR0.
> >With the output P1.0 toggling I would have expected a freq of 32768/2
> >but I see about 256/2 which I think is because it is not capturing at
> >all, but the interrupt is due to the overflow at 0xffff or
> >16777216/65536 = 256
> >
> >Can someone see what I'm doing wrong?
> >Thanks.
> >Pete L.
>
> Does your code read TAIV or does the C compiler automatically
> generate such code? (I haven't used C itself for handling
> what you are trying to do. Assembly is so much easier to make
> work well on this detail.)
>
> Anyway, I would suggest that you read the MSP430x2xx Family
> User's Guide, bottom of page 375, "12.2.6.2 TAIV, Interrupt
> Vector Generator" where it says: "Any access, read or write,
> of the TAIV register automatically resets the highest pending
> interrupt flag."
>
> In code I write for the CC1/TA event vector, it looks
> something like this:
>
> add &TAIV, PC
> reti ; 00h No interrupt pending
> nop ; 02h TACCR1 CCIFG
> nop ; 04h TACCR2 CCIFG
> nop ; 06h Reserved
> nop ; 08h Reserved
> nop ; 0Ah TAIFG
> nop ; 0Ch Reserved
> nop ; 0Eh Reserved
>
> (In assembly.) Also now read page 381. That one lists out the
> sources shown above. In your case, you want to respond to the
> 0Ah (TAIFG) entry.
>
> If you aren't reading TAIV, I think that may be at least part
> of your problem.
>
> Jon

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com



Reply by "Jon...@infinitefactors.org [msp430]" May 19, 20142014-05-19
On Thu, 15 May 2014 21:19:30 +1000, you wrote:

>Hi Guys,
> I'm trying to setup the DCO and timer on a F2013. So far very confused.
>What I would like to do is setup the DCO for 16MHz from the 32678Hz
>crystal, then feed the undivided DCO (mclk) to the timer counter, and
>capture the 32768Hz (undivided aclk) with CCR0.
>With the output P1.0 toggling I would have expected a freq of 32768/2
>but I see about 256/2 which I think is because it is not capturing at
>all, but the interrupt is due to the overflow at 0xffff or
>16777216/65536 = 256
>
>Can someone see what I'm doing wrong?
>Thanks.
>Pete L.

Does your code read TAIV or does the C compiler automatically
generate such code? (I haven't used C itself for handling
what you are trying to do. Assembly is so much easier to make
work well on this detail.)

Anyway, I would suggest that you read the MSP430x2xx Family
User's Guide, bottom of page 375, "12.2.6.2 TAIV, Interrupt
Vector Generator" where it says: "Any access, read or write,
of the TAIV register automatically resets the highest pending
interrupt flag."

In code I write for the CC1/TA event vector, it looks
something like this:

add &TAIV, PC
reti ; 00h No interrupt pending
nop ; 02h TACCR1 CCIFG
nop ; 04h TACCR2 CCIFG
nop ; 06h Reserved
nop ; 08h Reserved
nop ; 0Ah TAIFG
nop ; 0Ch Reserved
nop ; 0Eh Reserved

(In assembly.) Also now read page 381. That one lists out the
sources shown above. In your case, you want to respond to the
0Ah (TAIFG) entry.

If you aren't reading TAIV, I think that may be at least part
of your problem.

Jon


Reply by "Jon...@infinitefactors.org [msp430]" May 19, 20142014-05-19
On Thu, 15 May 2014 20:59:19 +1000, you wrote:

>Hi Guys,
> I'm trying to setup the DCO and timer on a F2013. So far very confused.
>What I would like to do is setup the DCO for 16MHz from the 32678Hz
>crystal, then feed the undivided DCO (mclk) to the timer counter, and
>capture the 32768Hz (undivided aclk) with CCR0.
>With the output P1.0 toggling I would have expected a freq of 32768/2
>but I see about 256/2 which I think is because it is not capturing at
>all, but the interrupt is due to the overflow at 0xffff or
>16777216/65536 = 256
>
>Can someone see what I'm doing wrong?

I would suggest that you read the MSP430x2xx Family User's
Guide, bottom of page 375, "12.2.6.2 TAIV, Interrupt Vector
Generator" where it says:

"Any access, read or write, of the TAIV register
automatically resets the highest pending interrupt flag."

In code I write for the CC1/TA event vector, it looks
something like this:

add &TAIV, PC
reti ; 00h No interrupt pending
nop ; 02h TACCR1 CCIFG
nop ; 04h TACCR2 CCIFG
nop ; 06h Reserved
nop ; 08h Reserved
nop ; 0Ah TAIFG
nop ; 0Ch Reserved
nop ; 0Eh Reserved

Also now read page 381. That one lists out the sources shown
above.

In your case, you want to respond to the 0Ah (TAIFG) entry.

I think that may be at least part of your problem. I didn't
look at the rest of your code, though. I do have code that I
haven't looked at in a few years that does use the 32.768kHz
xtal to calibrate and hold the 16MHz DCO, using a
proportional integral control loop, though. Not sure if that
is what you are trying to achieve. But it's been tested and
works. Could unearth it and test it out again, if that would
help.

Jon


Reply by "One...@bigpond.net.au [msp430]" May 15, 20142014-05-15
Yes, I noticed your interrupt there after I'd written that, forgot to
scroll down!

OK, first of all your interrupt is clearing the TACTL TAIFG flag for the
rollover interrupt TAIE, which is where your toggle is coming from, when
you should have used the CCIFG interrupt in TACTL0. It also looks like
you've used the common vectored interrupt address for TA1, without
using the Vector register TAIV. You should have used the TIMERA0_VECTOR
for CCR0. The TACTL |= TACLR is unnecessary, and resets the timer twice
potentially. So gdo this

> // Timer setup
> CCTL0 = CM_1 + CCIE + CCIS_1 + CAP;
> TACTL = TASSEL_2 + MC_2 + TACLR;
>

Then get rid of the TIMERA1_VECTOR handler you don't need it but replace
it with

> #pragma vector=TIMERA0_VECTOR
> __interrupt void Timer_A (void)
> {
> CTTL0 &= ~CCIFG;
> P1OUT ^= 0x01; // Toggle P1.0
> }

Or something similar, I don't do C on micros for this very reason, the above is not as obvious as BIS/BIC etc

Al

On 16/05/2014 9:59 AM, Peter Lissenburg p...@sensair.com [msp430] wrote:
> Hi Al,
> thanks for that.
> Yes I don't know why I put that output statement there, desperation I
> suppose!
> I do have an ISR at the bottom. That's where I'm getting the toggled
> signal from. But I thought I would have got a capture interrupt at a
> count of about 512 by the aclk coming from the 32k Xtal.
> (Sorry I realize now that setting up the DCO has nothing to do with the
> 32k Xtal).
> But the interrupt comes later at about the TAR rollover.
> So
> CCTL0 = CM_1 + CCIE + CCIS_1 + CAP;
> #define CM_1 (1*0x4000u) /* Capture mode: 1 - pos. edge */
> #define CCIE (0x0010) /* Capture/compare interrupt enable */
> #define CCIS_1 (1*0x1000u /* Capture input select: 1 - CCIxB */
> #define CAP (0x0100) /* Capture mode: 1 /Compare mode : 0 */
>
> is not setting the CCR0 to interrupt at the leading edge of aclk.
> Everything looks OK, but then it doesn't work so I must be wrong!
>
> Pete L.
> On 15/05/2014 11:48 PM, Onestone o...@bigpond.net.au [msp430] wrote:
>> To access the timer functions on pins for output you need to set the
>> relevant bits in the SEL register
>> P1.0 is not connected to a timer as an output, only as an input for TACLK
>> OUTMOD is an output or compare function and does nothing in capture mode
>>
>> to make this work you will need to implement an ISR on the capture event
>> and toggle a pin manually
>>
>> Al
>>
>> On 15/05/2014 8:29 PM, Peter Lissenburg p...@sensair.com [msp430] wrote:
>> > Hi Guys,
>> > I'm trying to setup the DCO and timer on a F2013. So far very confused.
>> > What I would like to do is setup the DCO for 16MHz from the 32678Hz
>> > crystal, then feed the undivided DCO (mclk) to the timer counter, and
>> > capture the 32768Hz (undivided aclk) with CCR0.
>> > With the output P1.0 toggling I would have expected a freq of 32768/2
>> > but I see about 256/2 which I think is because it is not capturing at
>> > all, but the interrupt is due to the overflow at 0xffff or
>> > 16777216/65536 = 256
>> >
>> > Can someone see what I'm doing wrong?
>> > Thanks.
>> > Pete L.
>> >
>> > #include
>> >
>> > int main(void)
>> > {
>> > unsigned int x = 0;
>> > WDTCTL = WDTPW +WDTHOLD
>> > //DCO setup 16Mhz from ti example
>> > if (CALBC1_16MHZ==0xFF)
>> > {
>> > while(1);
>> > }
>> > DCOCTL = 0;
>> > BCSCTL1 = CALBC1_16MHZ;
>> > DCOCTL = CALDCO_16MHZ;
>> >
>> > // Timer setup
>> > CCTL0 = CM_1 + CCIE + CCIS_1 + CAP + OUTMOD_4;
>> > TACTL = TASSEL_2 + MC_2 + TAIE + TACLR;
>> >
>> > P1DIR |= 0x03;
>> > _BIS_SR(GIE);
>> >
>> > while(1){;}
>> > }
>> >
>> > #pragma vector=TIMERA1_VECTOR
>> > __interrupt void Timer_A (void)
>> > {
>> > TACTL |= TACLR;
>> > TACTL &= ~TAIFG;
>> > P1OUT ^= 0x01; // Toggle P1.0
>> > }
>> >
>> >
>> > ---
>> > This email is free from viruses and malware because avast! Antivirus
>> protection is active.
>> > http://www.avast.com
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
Reply by "Pet...@sensair.com [msp430]" May 15, 20142014-05-15
Hi Al,
thanks for that.
Yes I don't know why I put that output statement there, desperation I
suppose!
I do have an ISR at the bottom. That's where I'm getting the toggled
signal from. But I thought I would have got a capture interrupt at a
count of about 512 by the aclk coming from the 32k Xtal.
(Sorry I realize now that setting up the DCO has nothing to do with the
32k Xtal).
But the interrupt comes later at about the TAR rollover.
So
CCTL0 = CM_1 + CCIE + CCIS_1 + CAP;
#define CM_1 (1*0x4000u) /* Capture mode: 1 - pos. edge */
#define CCIE (0x0010) /* Capture/compare interrupt enable */
#define CCIS_1 (1*0x1000u /* Capture input select: 1 - CCIxB */
#define CAP (0x0100) /* Capture mode: 1 /Compare mode : 0 */

is not setting the CCR0 to interrupt at the leading edge of aclk.
Everything looks OK, but then it doesn't work so I must be wrong!

Pete L.

On 15/05/2014 11:48 PM, Onestone o...@bigpond.net.au [msp430] wrote:
> To access the timer functions on pins for output you need to set the
> relevant bits in the SEL register
> P1.0 is not connected to a timer as an output, only as an input for TACLK
> OUTMOD is an output or compare function and does nothing in capture mode
>
> to make this work you will need to implement an ISR on the capture event
> and toggle a pin manually
>
> Al
>
> On 15/05/2014 8:29 PM, Peter Lissenburg p...@sensair.com [msp430] wrote:
> > Hi Guys,
> > I'm trying to setup the DCO and timer on a F2013. So far very confused.
> > What I would like to do is setup the DCO for 16MHz from the 32678Hz
> > crystal, then feed the undivided DCO (mclk) to the timer counter, and
> > capture the 32768Hz (undivided aclk) with CCR0.
> > With the output P1.0 toggling I would have expected a freq of 32768/2
> > but I see about 256/2 which I think is because it is not capturing at
> > all, but the interrupt is due to the overflow at 0xffff or
> > 16777216/65536 = 256
> >
> > Can someone see what I'm doing wrong?
> > Thanks.
> > Pete L.
> >
> > #include
> >
> > int main(void)
> > {
> > unsigned int x = 0;
> > WDTCTL = WDTPW +WDTHOLD
> > //DCO setup 16Mhz from ti example
> > if (CALBC1_16MHZ==0xFF)
> > {
> > while(1);
> > }
> > DCOCTL = 0;
> > BCSCTL1 = CALBC1_16MHZ;
> > DCOCTL = CALDCO_16MHZ;
> >
> > // Timer setup
> > CCTL0 = CM_1 + CCIE + CCIS_1 + CAP + OUTMOD_4;
> > TACTL = TASSEL_2 + MC_2 + TAIE + TACLR;
> >
> > P1DIR |= 0x03;
> > _BIS_SR(GIE);
> >
> > while(1){;}
> > }
> >
> > #pragma vector=TIMERA1_VECTOR
> > __interrupt void Timer_A (void)
> > {
> > TACTL |= TACLR;
> > TACTL &= ~TAIFG;
> > P1OUT ^= 0x01; // Toggle P1.0
> > }
> >
> >
> > ---
> > This email is free from viruses and malware because avast! Antivirus
> protection is active.
> > http://www.avast.com
> >
> >
> >
> >
> >
> >
> >
> >
Reply by "One...@bigpond.net.au [msp430]" May 15, 20142014-05-15
To access the timer functions on pins for output you need to set the
relevant bits in the SEL register
P1.0 is not connected to a timer as an output, only as an input for TACLK
OUTMOD is an output or compare function and does nothing in capture mode

to make this work you will need to implement an ISR on the capture event
and toggle a pin manually

Al
On 15/05/2014 8:29 PM, Peter Lissenburg p...@sensair.com [msp430] wrote:
> Hi Guys,
> I'm trying to setup the DCO and timer on a F2013. So far very confused.
> What I would like to do is setup the DCO for 16MHz from the 32678Hz
> crystal, then feed the undivided DCO (mclk) to the timer counter, and
> capture the 32768Hz (undivided aclk) with CCR0.
> With the output P1.0 toggling I would have expected a freq of 32768/2
> but I see about 256/2 which I think is because it is not capturing at
> all, but the interrupt is due to the overflow at 0xffff or
> 16777216/65536 = 256
>
> Can someone see what I'm doing wrong?
> Thanks.
> Pete L.
>
> #include int main(void)
> {
> unsigned int x = 0;
> WDTCTL = WDTPW +WDTHOLD
> //DCO setup 16Mhz from ti example
> if (CALBC1_16MHZ==0xFF)
> {
> while(1);
> }
> DCOCTL = 0;
> BCSCTL1 = CALBC1_16MHZ;
> DCOCTL = CALDCO_16MHZ;
>
> // Timer setup
> CCTL0 = CM_1 + CCIE + CCIS_1 + CAP + OUTMOD_4;
> TACTL = TASSEL_2 + MC_2 + TAIE + TACLR;
>
> P1DIR |= 0x03;
> _BIS_SR(GIE);
>
> while(1){;}
> }
>
> #pragma vector=TIMERA1_VECTOR
> __interrupt void Timer_A (void)
> {
> TACTL |= TACLR;
> TACTL &= ~TAIFG;
> P1OUT ^= 0x01; // Toggle P1.0
> }
> ---
> This email is free from viruses and malware because avast! Antivirus protection is active.
> http://www.avast.com
>
>
>
>
Reply by "Pet...@sensair.com [msp430]" May 15, 20142014-05-15
Hi Guys,
I'm trying to setup the DCO and timer on a F2013. So far very confused.
What I would like to do is setup the DCO for 16MHz from the 32678Hz
crystal, then feed the undivided DCO (mclk) to the timer counter, and
capture the 32768Hz (undivided aclk) with CCR0.
With the output P1.0 toggling I would have expected a freq of 32768/2
but I see about 256/2 which I think is because it is not capturing at
all, but the interrupt is due to the overflow at 0xffff or
16777216/65536 = 256

Can someone see what I'm doing wrong?
Thanks.
Pete L.

#include

int main(void)
{
unsigned int x = 0;
WDTCTL = WDTPW +WDTHOLD
//DCO setup 16Mhz from ti example
if (CALBC1_16MHZ==0xFF)
{
while(1);
}
DCOCTL = 0;
BCSCTL1 = CALBC1_16MHZ;
DCOCTL = CALDCO_16MHZ;

// Timer setup
CCTL0 = CM_1 + CCIE + CCIS_1 + CAP + OUTMOD_4;
TACTL = TASSEL_2 + MC_2 + TAIE + TACLR;

P1DIR |= 0x03;
_BIS_SR(GIE);

while(1){;}
}

#pragma vector=TIMERA1_VECTOR
__interrupt void Timer_A (void)
{
TACTL |= TACLR;
TACTL &= ~TAIFG;
P1OUT ^= 0x01; // Toggle P1.0
}
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com



Reply by "Pet...@sensair.com [msp430]" May 15, 20142014-05-15
Hi Guys,
I'm trying to setup the DCO and timer on a F2013. So far very confused.
What I would like to do is setup the DCO for 16MHz from the 32678Hz
crystal, then feed the undivided DCO (mclk) to the timer counter, and
capture the 32768Hz (undivided aclk) with CCR0.
With the output P1.0 toggling I would have expected a freq of 32768/2
but I see about 256/2 which I think is because it is not capturing at
all, but the interrupt is due to the overflow at 0xffff or
16777216/65536 = 256

Can someone see what I'm doing wrong?
Thanks.
Pete L.

#include

int main(void)
{
unsigned int x = 0;
WDTCTL = WDTPW +WDTHOLD
//DCO setup 16Mhz from ti example
if (CALBC1_16MHZ==0xFF)
{
while(1);
}
DCOCTL = 0;
BCSCTL1 = CALBC1_16MHZ;
DCOCTL = CALDCO_16MHZ;

// Timer setup
CCTL0 = CM_1 + CCIE + CCIS_1 + CAP + OUTMOD_4;
TACTL = TASSEL_2 + MC_2 + TAIE + TACLR;

P1DIR |= 0x03;
_BIS_SR(GIE);

while(1){;}
}

#pragma vector=TIMERA1_VECTOR
__interrupt void Timer_A (void)
{
TACTL |= TACLR;
TACTL &= ~TAIFG;
P1OUT ^= 0x01; // Toggle P1.0
}
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com



Reply by "art...@granzeier.com [msp430]" May 14, 20142014-05-14
John,

Tayda has them for $0.19 each (qty 1 to qty 49).

http://www.taydaelectronics.com/connectors-sockets/stackable-headers/stackable-header-10-pins-2-54mm.html http://www.taydaelectronics.com/connectors-sockets/stackable-headers/stackable-header-10-pins-2-54mm.html

They are located in China, and it takes a while (couple of weeks) to get them to the U.S. (not sure where you live, but...) If you just need a few, let me know and I will pop a couple into an envelope and ship them to you by USPS First Class. Go to my store (zenstore.granzeier.com,) register (so that I have your shipping address) and then send me an email from the link, mention that I offered them, and how many you need, and I will get them out. (Now you can see why I am not a millionaire. ;-) )

Good luck,

Art

---In m..., wrote :

On Mon, May 12, 2014 at 6:27 PM, art3@... mailto:art3@... [msp430] wrote:

Steve,

I have a couple at my store. There are two versions: one with a solderless breadboard, and passthrough headers for stacking multiple booster packs



Hi Art,
I know they shouldn't be too hard to find, but would you happen to have a manufacturer and part number for the passthrough headers you mentioned?
Thanks,
-John