Hello,
I'm new on the MSP430 family and started to play around with the Launchpad and the Cap.-Touch Boosterback. I quickly changed to my own touch board since I need a functionality which I cannot get with the Boosterpack. And here is my problem:
Configuration:
MSP430G2553
P2.0 Sensor left
P2.2 to P2.5 Sensor down, right, up, middle
Feedback LEDs on P1.0, P1.3, P1.4, P1.5, P1.6
PWM out on P2.1 for TIMER_A1
Touch alone: works fine
PWM alone: works fine
Touch and PWM together: sucks, the PWM LED flickers
My idea was to use the TIMER_A1 for PWM because the TIMER_A0 is used for TouchSense. But it seems that there is a problem which causes the TIMER_A1 to stutter.
Any ideas (I did'nt find anything using search)? I can provide the code if necessary.
Frank
Frank BoehmeBut it seems that there is a problem which causes the TIMER_A1 to stutter.
You should post your code, as there is no known 'TimerA1 PWM fails if TimerA0 is used for TouchSense" hardware bug.
However, I have a guess. Maybe you confused the two timers with the two vectors for each timer.
TIMER0_A0_VECTOR and TIMER0_A1_VECTOR (or their aliases TIMER_Ax_VECTOR) belong both to Timer0.Timer1 has the vectors TIMER1_A0_VECTOR and TIMER1_A1_VECTOR.
You really should post your code.
_____________________________________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.
This is the Code. I stripped it down to the essentials. It is a standard CCS 5 project for the MSP430G2553. All of "my" Code is in main.c. I use the standard files
CTS_HAL.c CTS_HAL.h CTS_Layer.c CTS_Layer.h
from slac489.zip and the mode "RO_PINOSC_TA0_WDTp" with the files structure.c and structure.h from "RO_PINOSC_TA0_WDTp_One_Button" example without modifications.
Comment the line: FeedbackLED(one_button, BIT0, 0); to run only the PWM and it works fine
Comment the line: Timer1_A3_init(); to run only the touch and it works fine
Use both lines and the PWM LED stutters
//****************************************************************************** // Schematic Description: // // MSP430G2452 // +---------------+ // | // OUT--------|P1.0 (Feedback LED) // PWM----------|P2.1 (LED) // C------|P2.5 (Touch) // //****************************************************************************** #include "CTS_Layer.h" // Uncomment to have this compiler directive run characterization functions only // Comment to have this compiler directive run example application //#define ELEMENT_CHARACTERIZATION_MODE #ifdef ELEMENT_CHARACTERIZATION_MODE // Delta Counts returned from the API function for the sensor during characterization unsigned int dCnt; #endif int up = 1; int disable = 0; /* * ======== Timer1_A3_init ======== * Initialize MSP430 Timer1_A3 timer * Conf. made with GRACE, Comments removed */ void Timer1_A3_init(void) { TA1CCTL0 = CM_0 + CCIS_0 + OUTMOD_0; // + CCIE; TA1CCTL1 = CM_0 + CCIS_0 + OUTMOD_7;// + CCIE; TA1CCR0 = 9999; TA1CCR1 = 500; TA1CTL = TASSEL_2 + ID_0 + MC_1; } //Feedback LED anschalten void FeedbackLED(const struct Sensor Sens, int Pin, int disable) { if(disable == 0) { if(TI_CAPT_Button(&Sens)) P1OUT |= Pin; // Turn on LED else P1OUT &= ~Pin; } else P1OUT &= ~Pin; } // Main Function void main(void) { // Initialize System Clocks WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1, 8, 12 or 16MHz DCOCTL = CALDCO_1MHZ; BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO P1OUT = 0x00; // Clear Port 1 bits P1SEL = BIT6; P1DIR |= BIT0 + BIT3 + BIT4 + BIT5 + BIT6 + BIT7; // Set output pins P2SEL &= ~(BIT6 + BIT7); // Configure XIN (P2.6) and XOUT (P2.7) to GPIO P2SEL |= BIT1; // P2.1 to PWM P2OUT = 0x00; // Drive all Port 2 pins low P2DIR = 0xFF; // Configure all Port 2 pins outputs Timer1_A3_init(); // Initialize Baseline measurement TI_CAPT_Init_Baseline(&one_button); // Update baseline measurement (Average 5 measurements) TI_CAPT_Update_Baseline(&one_button,5); // Main loop starts here while (1) { #ifdef ELEMENT_CHARACTERIZATION_MODE // Get the raw delta counts for element characterization TI_CAPT_Custom(&middle_button,&dCnt); __no_operation(); // Set breakpoint here #endif #ifndef ELEMENT_CHARACTERIZATION_MODE FeedbackLED(one_button, BIT0, 0); #endif } } // End Main
You may also have a look on the complete project if you wish 6136.oneButtonPWMTest.zip
BTW: When I change the ".measGateSource" in structure.c to SMCLK, it looks much better, but the sensitivity decreases dramatically and I am not really happy with that workaround.
I think I have it!
In the original CTS_HAL.c is the code
if(group->measGateSource == GATE_WDT_ACLK) { __bis_SR_register(LPM3_bits+GIE); // Wait for WDT interrupt } else { __bis_SR_register(LPM0_bits+GIE); // Wait for WDT interrupt }
which causes the MCU going in Low Power Mode 3 when using the ACLK which disables the SMCLK and therefore the TIMER_A1 in my code.
I changed LPM3 to LPM0 and it works.
Can anyone confirm this?
It's well possible that the funciton TI_CAPT_Custom and TI_CAPT_Button or something they do (especially the 'Custom' looks suspicious) causes a compatibility problem.
Your TIemr setup doesn't use itnerrupts and runs in plain hardware. But it is possible that the CAPT code somehow requires the timer by itself.
IIRC, the touch pins are oscillating and the oscillations are counted by Timer0. However, to make any sense, you'll need to know how many oscillations per time period happen. And since TimerA0 is used for counting pulses, only TimerA1 is available for measuring the period. So both tiemrs are implicitely used for CapSense and your use of TimerA1 conflicts with this.
I don't know the actual TI library code, but I bet it is a good guess.
Thank you for the response.
The TI_CAPT_Custom and TI_CAPT_Button functions are TI code, I just used them, hoping that they know what they do.
I think they use the TimerA0 for counting and the WDT for the time period, which leaves the TimerA1 free. The problem was that the MCU was sent to LPM3 at each touch cycle which disabled my PWM.
I now happy with that.
Thanks again
Frank BoehmeThe problem was that the MCU was sent to LPM3 at each touch cycle which disabled my PWM.
Frank Boehme TI code, I just used them, hoping that they know what they do