I assume that you are using F2001 and you have a 32768Hz crystal.
See my comments start with *** below.
--- In m..., "Richard Cooke" wrote:
>
> Hi Folks,
>
> I folks I'm the knucklehead that needed help with Timer_A and
> reading/decoding and IR signal. I think I (sort of) know what I
want
> to do but I can't figure out how to set up the
TACCTL0 register.
I'm
> using the free IAR compiler (I've never been all
that comfortable
with
> assemblers).
>
> I want to be able to capture the timer value when a pulse comes in.
> My signal is connected to P1.1 which I've set up as an input and set
> up CCI0A.
*** In order to do that, you need:
P1DIR:BIT2=0 (it is already 0 after reset)
P1SEL:BIT2=1 (*** your code need to do this)
CAPD:BIT2=0 (it is already 0 after reset)
TACCTL0:CCIS1&0 (it is already 00 after reset)
> What exactly is the SCCI bit? When do you use it?
*** In Compare Mode, when TAR equals TACCRx, the selected input is
latched at this bit and can be read later. This is useful to "sample"
the input at a given time (when TAR==TACCRx).
> I'm assuming that
> since I'm not outputting anything I don't have to worry about the
> OUTMOD0 bits. I'll need to enable the Capture/compare interrupt
> enable bit (CCIE) since I plan on using the interrupt.
*** You are correct. But you need to do more than enable CCIE.
After reset, LFXT1 is enabled and ACLK=LFXT1/12768Hz.
After reset, DCO is running at ~1MHz and MCLK=SMCLK/1=~1MHz.
You need to set TACTL=TASSEL0+MC1 so that TA uses ACLK continously.
You also need to set TACCTL0:CM1&0 to either 01 or 10.
And the rest of TACCTL0 |= SCS+CAP+CCIE.
You need an interrupt service routine.
And you need to set GIE in the SR.
> What does the CCI bit do? The User's guide
defines it as:
> "Capture/compare input. The selected input signal can be read
> by this bit".
*** That is correct.
> Are they saying that the Capture/compare input select
source
> (I've used CCI0A as my IR signal input) will toggle this bit as it
> goes high and low?
*** Yes. When the input is high, it reads 1.
When the input is low, it reads 0.
As long as P1SEL:BIT2=1, you read this bit instead of P1IN:BIT2.
> If this is the case is this bit latched at the
> time the interrupt occurred?
*** No. I do not think you are not wrong ;)
> Does anybody know of any examples of using the
Timer_A in capture
> mode? I've looked at the TI SLAA134 (Decode TV IR Signals) but the
> code is only in assembly I know only real men and women use
> assemblers and only wimps use C so call me a wimp.
*** The IAR MSP430 compiler complains about:
int a = P1IN + P1IN;
But does not complain about:
int b = P1IN + P2IN;
Why?
> Thanks again,
>
> Richard Cooke
> Lake Forest, CA
>