EmbeddedRelated.com
Forums
Memfault Beyond the Launch

16 MHz Verification

Started by mercstein November 16, 2009
Hey guys,

I'm new to the MSP430, and am having some trouble verifying that my TimerA is operating at 16MHz. I have a scope attached to P1.0, and am watching for the appropriate signal out.

Here is my code. It's a bit pirated from TI's sample code, but i believe i should be getting about 1000 Hz from P1.0.



One problem I'm having is that when I change the DCOCTL and BSCCTL1 to the 16 MHz settings, nothing seems to happen to my scope signal.
I'm open to any ideas.

Beginning Microcontrollers with the MSP430

I think you will see something like 7.63 Hz at P1.0

What did you see?
Try using:

BCSCTL1= CALBC1_16MHZ;
DCOCTL= CALDCO_16MHZ;

instead. Might help.

Jon
I'm just trying out the 1MHz clocking for now, mainly because when I change to the 16 MHz settings (from the 1MHz settings), there is no corresponding change to the period of the output signal.

The output now is at about a 109us period.... about 9174Hz.

Maybe i should mention that i'm using the ez430-RF2500 development tool along with USB debug stick.
Your TACTL setting is using SMCLK (TASSEL_2) in Continuous Mode (MC_2). Thus TAR will count SMCLK from 0 to 65535 repeatedly and match TACCR (00) every 65536 counts. This means P1.0 will flip after every SMCLK/65536 counts.

Your observation on the scope is inconsistent with you code.
I'm pretty sure that when CAP = 0 (in TACTL0), the timerA count hits TACCR0 and sets the interrupt flag (CCIFG). Then, in the interrupt I toggle P1.0, and reset TAR to zero, starting the count over. One reason i'm pretty sure of this, is that if I halve TACCR0, the signal period also cuts in half.

And, oddly, increasing the DCO seems to have no effect. It seems that either way the interrupt trips, the increase in DCO freq should decrease the period.

The only time i get an increase in signal frequency on the scope is when i go from default DCO settings (commenting out clock controllers) to enabling them.

//BCSCTL1 |= CALBC1_16MHZ_;
//DCOCTL |= CALDCO_16MHZ_;

When i enable them, it doesnt matter which i use, whether 16MHZ, 8MHZ, whatever... they all cause the same output frequency.
I'm wondering if i cant have the interrupt occuring at that frequency for some reason?
You are right. Sorry, I missed the line in the ISR that clears TAR. Most people would not do that, they use Up Mode (MC_1) to accomplish that automatically and more precisely.

Did you check if the factory DCO calibrations are valid? They are stored in InfoA Flash by TI and you could have erased them or altered them.
m...@gmail.com wrote:
>
> I'm pretty sure that when CAP = 0 (in TACTL0), the timerA count hits
> TACCR0 and sets the interrupt flag (CCIFG). Then, in the interrupt I
> toggle P1.0, and reset TAR to zero, starting the count over. One reason
> i'm pretty sure of this, is that if I halve TACCR0, the signal period
> also cuts in half.
>
> And, oddly, increasing the DCO seems to have no effect. It seems that
> either way the interrupt trips, the increase in DCO freq should decrease
> the period.
>
> The only time i get an increase in signal frequency on the scope is when
> i go from default DCO settings (commenting out clock controllers) to
> enabling them.
>
> //BCSCTL1 |= CALBC1_16MHZ_;
> //DCOCTL |= CALDCO_16MHZ_;
> When i enable them, it doesnt matter which i use, whether 16MHZ, 8MHZ,
> whatever... they all cause the same output frequency.
>
> I'm wondering if i cant have the interrupt occuring at that frequency
> for some reason?
>

Perhaps your DCO calibration values have been overwritten or erased. That would
explain why your DCO frequency does not change when using the different CALBC1
and CALDCO values.

-Greg
Thanks Greg and Old Cow.

I am going to double check the cal values right now, .

Old Cow, you're right about the count mode, I should change it to make it
more accurate. I was doing it dirty just to get a quick result. I appreciate
the help from both of you.
Although i believe the Cal values may be hosed in my previous uC, I'm still having issues with resultant frequencies in a new uC.



Right now, i feel i should be getting a square wave frequency of 5kHz from P3.1. Instead, i'm getting about 8230Hz.
Also, when i change the BCSCTL1 and DCOCTL to 8 MHz settings, i get about 10x measured frequencies. Not 8x.

Also, i checked the memory address in IAR, and 0x10F(8-F), where the calibration settings reside, is not all FF's.

Any ideas?

Memfault Beyond the Launch