Since I do not have much more hair left to tear out after struggling (for more than a day) with the TAIV problems occurring if it is watched using CCS V5, (shades of Schrodinger's cat) I have a question about TA0, in continuous, up/down mode and, that "OUT" in TA0CCTLx (x = 1 or 2) does not seem to appear in the CCS "register display" regardless of which OUTMOD (0-7) I try, stepped or "breakpointed."
Searching E2E solved my TAIV problem, but has been fruitless with my present hassles.
I have a fairly good grasp of the MSP430 (mostly enjoyable) and if this is (perhaps) just an idiosyncrasy of CCS (Launchpad emulation) then I can work my way around it. If the problem has already been covered, I apologize, and please point me to the relevant discussion.
Essentially I am trying to do a few ADC samples (with averaging) with long intervals (5-30+ minutes) between (thus the up/down mode use and also later probably more "toggling") AND all this with absolute minimum power consumption, so I use VLO whenever possible but have to change clock speeds for minimum (resolvable) REFON settling times and perhaps also the longer sampling times required for the internal temperature reference and to run the CPU at a power effective speed when necessary etc.
I am an old 'b" who learned programming from hardware (discrete TTL - yes that old) upwards, therefore the "asm" and some redundant lines of programming. (This redundancy is just "to make sure", due to MSP430 unfamiliarity, and I clean up after I get the routines to work) If this C stuff catches on, I may learn more of it (lol)
The code below is an attempted general timing template/toy which includes all the CCR interrupts and the TA overflow interrupt -which in Up/Down mode is (almost) a "zero interrupt." It does not include any of the ADC stuff yet.
The present CCR1 and CCR2 values (20 & 40) are arbitrary - used them to confirm that TA was actually using VLO and DCO (1MHz) inputs when requested
I get all the interrupts/handling/routines doing whatever I need but as mentioned can not "see OUTs" when I try (even if OUTMOD1 ( =SET) is tried)
As I am very competent and experinced at being an idiot, I am sure it is something that I am doing wrong.
I tend to work much in isolation so if I have broken any conventions, vocabulary, etc,- it is absolutely not intentional, inform me, I will apologize and go into my corner and set myself in flames.
Thank you in anticipation, and waiting with a lighter in my hand - james
.cdecls C,LIST, "msp430g2553.h" .text ;PROGRAM START;------------------------------------------------------------RESET mov.w #0280h,SP ;Initialize SPStopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ;Stop WDT bis.w #0020h,BCSCTL3 ;VLO select - redundant?SetupP1 bis.b #001h,&P1DIR ;P1.0 LEDSetupC0 mov.w #CCIE+OUTMOD0,&CCTL0 ;CCR0 IE mov.w #20000,&CCR0SetupC1 mov.w #CCIE+OUTMOD_0,&CCTL1 ;CCR1 IE mov.w #040,&CCR1SetupC2 mov.w #CCIE+OUTMOD_0,&CCTL2 ;CCR2 IE mov.w #020,&CCR2SetupTA mov.w #TAIE+TASSEL_1+MC_3,&TACTL ;ZeroIE,ACLK,UpDown nopMainloop bis.w #LPM3+GIE,SR ;LowPower & IE nop ;For debugger;-----------------------------------------------------------------TAX_ISR ; Common ISR for CCR1-4 and TAIE add.w TAIV,PC ;ISR routerJmpTab1 retiJmpTab2 jmp CCR1_ISR ;CCR1 JmpTab4 jmp CCR2_ISR ;CCR2 JmpTab6 retiJmpTab8 retiJmpTab10 jmp Zero_ISR ;TAIEJmpTab12 reti;CCR1_ISR nop mov.w #0018h,&027Ch ;change stack,RETI SCG0 SCG1 onFAST mov.w #TAIE+TASSEL_2+MC_3, &TACTL ;input=fastSMCLK retiCCR2_ISR nopSLOW mov.w #TAIE+TASSEL_1+MC_3,&TACTL ;input=slowACLK retiZero_ISR nop retiCCR0_ISR xor.b #001h,&P1OUT ;LED demo
reti ;;-----------------------------------------------------------------; Interrupt Vectors .sect ".reset" ; RESET Vector .short RESET .sect ".int08" ; Timer_AX Vector .short TAX_ISR .sect ".int09" ; Timer_R0 Vector .short CCR0_ISR .end
Hi, your program has some issue, please get a water glass than a flame ;)
ecstatist I get all the interrupts/handling/routines doing whatever I need but as mentioned can not "see OUTs" when I try (even if OUTMOD1 ( =SET) is tried)
If you use setmod you enable timer logic to do some action but you need select the related output pin to TAx output funnction and to do that you need an instruction setting the bit related to that.
ecstatistSetupP1 bis.b #001h,&P1DIR ;P1.0 LED
Example
bis.b BIT1,&P1Sel ; This select pin p1.x as TA output sconnecting from OUT register
ecstatistCCR1_ISR nop mov.w #0018h,&027Ch ;change stack,RETI SCG0 SCG1 on
AAAARRRRRGGGGGHHHHHHH WHAT IS THIS ORRIBLE RUBBISH??? DONT DO THAT!!!!!!!!!!!!!!!!!!!!!!!!!!
Please use SP relative addressing and NEVER use hardwired stack manipulation, you can disrupt another interrupt handle or some other data losing control of program!
BIS
BIC #xxx,&[offset]SP
ecstatistFAST mov.w #TAIE+TASSEL_2+MC_3, &TACTL ;input=fastSMCLK retiCCR2_ISR nopSLOW mov.w #TAIE+TASSEL_1+MC_3,&TACTL ;input=slowACLK reti
Again to set reset bit use BIC and BIS otherwise you can set a wrong state and hang subsystem, this is not the case of your simple program but as I see you are using a bad programming style.
To have OUTMOD visible select a pair of TA1 and TA2 pin and enable corresponding bit on PxSEL and you can watch OUTMOD action on hardware.
Regards
Roberto
Please login & click Verify Answer if this post answered your question.
Roberto, thank you for your quick reply - I only noticed it now and will try your suggestions tomorrow or at least by Monday.
"To have OUTMOD visible select a pair of TA1 and TA2 pin and enable corresponding bit on PxSEL and you can watch OUTMOD action on hardware."
I understand this as - connecting an LED or voltmeter to the correct pin out to "watch OUTMOD action" - Do you think that when I have done the correct P1SEL and P1DIR's that I will be able to "watch OUTMOD action" in the REGISTER view of CCS? I'll check.
"AAAARRRRRGGGGGHHHHHHH WHAT IS THIS ORRIBLE RUBBISH??? DONT DO THAT!!!!!!!!!!!!!!!!!!!!!!!!!!" I'm still laughing - I'm so sorry - for the crude programming!
Sometimes when I get rolling along (desperate and crazy), I use quickly "cut and try" rather than "measure and think." So far, I have not had to write many complex programs so I have got away with this lack of rigour.
Again thank you and I will keep you informed
ecstatistin continuous, up/down mode and, that "OUT" in TA0CCTLx (x = 1 or 2) does not seem to appear in the CCS "register display" regardless of which OUTMOD (0-7) I try, stepped or "breakpointed."
However, in no case, OUT will change by its own, so you'll never see it changing in the debugger register view, unlexss your code has changed it manually.
As Roberto already pointed out, your trick to exit LPM by stack content manipulation won't work. As soon as your main uses one more local variable, it will access the wrong memory location. Other reasons may shift the stack content too.
Something likebic #LPM3_BITS, 2(R1)will do better (in this case accessing the word on top of stack, clearing the LPM bits
_____________________________________Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.
Jens-Michael Gross ecstatistin continuous, up/down mode and, that "OUT" in TA0CCTLx (x = 1 or 2) does not seem to appear in the CCS "register display" regardless of which OUTMOD (0-7) I try, stepped or "breakpointed."Indeed, OUT is not a reflection of the current pin state. It defines the pin state in OUTMOD_0.OUT only returns what was written to it.If you switch from any OUTMOD_x to OUTMOD_0, the content of OUT will be written to the internal state of the output unit and to the pin. If you switch back to any toggle mode, the internal state will remain on what OUT was, and then toggle. So you can define a 'start condition' for the toggle mode. Or use this bit as pendant to PxOUT.y in OUTMOD_0 without need to change PxSEL. This is useful if you do PWM, as in PWM mode, you cannot program both, 0% and 100% duty cycle. Since both mark the same place on teh counting circly, only one of the m can be directly progreammed (depends on polarity), while the other one has to be done by switching to OUTMOD_0 with the proper value written to OUT bit. However, in no case, OUT will change by its own, so you'll never see it changing in the debugger register view, unlexss your code has changed it manually.
This is a great explanation of the timer module OUT bit.
ecstatist I understand this as - connecting an LED or voltmeter to the correct pin out to "watch OUTMOD action" - Do you think that when I have done the correct P1SEL and P1DIR's that I will be able to "watch OUTMOD action" in the REGISTER view of CCS? I'll check.
You can actually use the CCI bit to monitor the current state of the pin where you are currently outputting the timer-generated signal/PWM. So you can look at this CCI bit (instead of the OUT bit) in the TACCTLx register in CCS to see the current state when you hit a breakpoint. Though I do recommend hooking up an oscilloscope if you really want to see how the timing is coming out on the pin.
Regards,
Katie
Please click the Verify Answer button on this post if it answers your question.
Roberto RomanoBIC #xxx,&[offset]SP
OOOOPPS..
sorry for malformed instruction, the correct stack manipulation for BIC or BIS is
BIC #xxx,(offset)SP
I don't use anymore assembly but MSP has a beautiful clean orthogonal and effective instruction set. It resemble me old good day with motorola 68000 and PDP11 at early uP revolution age.
Katie EnderleYou can actually use the CCI bit to monitor the current state of the pin where you are currently outputting the timer-generated signal/PWM.
However, I never used this myself (PxIN does the job fine on most MSPs) and the users guide isn't very "talkative" about this.
Hi Jens-Michael,
I've used the CCI bit in this way on the G2xx parts and on the F5529 when using the timer module in the app note SLAA513. So I've tried it out on these parts. The user's guide indicates that the CCI signals are connected even in compare mode and can be read at any time using the CCI bit, and that the input signal on CCI is latched into SCCI in compare mode when TAR counts to the value in TACCRX (see p. 371 section 12.2.4.2 of the 2xx user's guide) . In the app note (SLAA513) where we're using continuous mode on the timer to generate multiple different PWM frequencies at once. The CCI bit was used to determine if we are in the high or low portion of the PWM to determine the correct offset to add to TACCRx to generate the correct duty cycle.
Hi Katie, first thank a lot for all information on document, is not so different from what I done with MSP but is appreciated for all hint found.
I used CCI and SCCI bit to capture input status when I wrote serial communication software, this function is invaluable to reduce external hardware but as I remember, what I read again on user manual, as Jeans pointed to you also to me this bit appear as is connected to Input selected by. So our friend has no output pin connected to Timer subsystem and from my knowledge I fear OUTMOD status cannot be read from internal. Did you know more about internal silicon implementation? On weekend I get the hardware and I try do some test on this bit.
I am running late with the results of my "hardware" tests, but I will post them in the next 48 hours.
I did one quick test on the OUT working. The minimalist code below runs on a LaunchPad, flashing
the green LED 50% at approx 1 second. (VLO).
This uses the OUT of CCR1 (and no peripheral interrupts need to be specifically enabled)
I had a quick look at CCS v5 debug "register display" and it did not show the OUT bit or the CCI bit doing anything.
PIN 1.6 register did show the correct responses. I will double check and test more soon.
Still grateful to you all - james
.cdecls C,LIST, "msp430g2553.h" .text RESET mov.w #0280h,SP ;Initialize SP mov.w #WDTPW+WDTHOLD,&WDTCTL ;Stop WDT mov.w #12000,&CCR0 ;set period mov.w #OUTMOD_3,&CCTL1 ;OUT set/reset mov.w #00,&CCR1 ;yields 50% duty cycle bis.w #040h,&P1SEL ;set up P1.6 as second bis.w #040h,&P1DIR ;output option TA0.1 mov.w #TASSEL_1+MC_3,&TACTL ;ACLK,UpDownContinuous bis.w #LPM3+GIE,SR ;LowPower & IE nop ;For debugger .sect ".reset" ; RESET Vector .short RESET .end
ecstatist bis.w #040h,&P1SEL ;set up P1.6 as second bis.w #040h,&P1DIR ;output option TA0.1 bis.w #LPM3+GIE,SR ;LowPower & IE
All these registers are BYTE registers, so .B and not .W is to be used.In case of P1xxx you're also programming P2xxx (this combo is identical to PAxxx)And SR must not be written with a word at all. The behavior is undefined in this case.
ecstatistThis uses the OUT of CCR1 (and no peripheral interrupts need to be specifically enabled)
As I said, the OUT bit inside TACCTLx only changes its value if you manually change it in software. It is not changing its value based on any hardware action. So that's the expected and intended behavior.
the CCI bit, well does what i expected: nothing. P1.6 is TA0.1 output only and not available for CCI. It is P1.2 which has both, TA0.1 output and CCI1A capture input. It is stil not clear whether CCI is updated when in compare mode, as in compare mode, (obviously) no capture takes place.
Hi guys,
About the CCI bit (and the SCCI bit) - the CCI bit will change IF you are outputting the timer output on a pin - but the pin has to be configured to timer function using the PxSEL bits. When you select that pin to be configured for the timer, the CCI bit is then tied to that pin and will change with that pin (even in compare mode). I've tested this out on a G2553 and a launchpad with just a simple timer code example that toggles (OUTMOD_4) P1.1 configured to timer output. if you put a breakpoint in the ISR, then you can see that CCI/SCCI bit in the corresponding TACCTLx register toggles every time (output was set to toggle mode). This is the same methodology that is used in my app note SLAA513 that I mentioned before - since we are outputting PWMs on pins, then we can use the CCI bit while we're in the ISR to see the current state of the pin.
See also 2xx user's guide section 12.2.4.2 Compare Mode, which talks about CCI behavior in Compare mode (not just capture mode):
2xx user's guide12.2.4.2 Compare Mode The compare mode is selected when CAP = 0. The compare mode is used to generate PWM output signals or interrupts at specific time intervals. When TAR counts to the value in a TACCRx: Interrupt flag CCIFG is set Internal signal EQUx = 1 EQUx affects the output according to the output mode The input signal CCI is latched into SCCI
The compare mode is selected when CAP = 0. The compare mode is used to generate PWM output signals or interrupts at specific time intervals. When TAR counts to the value in a TACCRx:
Katie Enderle the CCI bit will change IF you are outputting the timer output on a pin
I'll collect the outcome of this thread for the timer chapter in my book - if I ever proceed that far (haven't written a word for two months now)