Presentation is loading. Please wait.

Presentation is loading. Please wait.

Why Keliang’s code maybe did (or maybe didn’t) work … or High (impedance) Anxiety.

Similar presentations


Presentation on theme: "Why Keliang’s code maybe did (or maybe didn’t) work … or High (impedance) Anxiety."— Presentation transcript:

1 Why Keliang’s code maybe did (or maybe didn’t) work … or High (impedance) Anxiety

2 The code void main(void){ WDTCTL = WDTPW + WDTHOLD; // Kill Watchdog P1DIR |= 0x01; // P1.0 output TACTL |= TASSEL_1 + ID_0 + MC_1; // Select ACLK, select up mode, select divider to be 1 TACCR0 = 6000; // Count up to CCTL0 = CCIE; // CCR0 interrupt enabled _BIS_SR(LPM3_bits + GIE); // Go into lpm3 and enable interrupts } // Timer A0 interrupt service routine #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A (void) { P1OUT ^= 0x01; // Toggle P1.0 } The idea was to use VLO clock (about 12 kHz) to generate interrupts after every 6000 counts When running on Launchpad the interrupts were happening about twice as fast as expected, but specs say VLO can be as high as 20 kHz so this seemed OK. When running on daughterboard, code didn’t work at all. Light would sometimes flash depending on touching circuit… Setting pin 2.6 as output also stopped code from working (even on Launchpad)

3 Timer A module TACTL |= TASSEL_1 + ID_0 + MC_1; // Select ACLK, select up mode, select divider to be 1 TACCR0 = 6000; // Count up to CCTL0 = CCIE; // CCR0 interrupt enabled

4 Clock Module At power up LXFT1Sx=00 so input is from XIN.

5 XIN/P2.6 (Page 3 of datasheet) (Page 53 of datasheet) (Page 341 of User’s Guide) P2Sel.6 = 1, P2Sel.7=1 P2Sel2.6=0, P2Sel2.7=0 Pin 19 is XIN

6 XIN is input (high impedance)! Touching (or getting near) pins can change value. That explains daughterboard behavior. But why did code work otherwise on Launchpad (though faster than expected)? Making P2.6 an output keeps line from oscillating, so light didn’t blink. This explains part of Launchpad behavior.

7 Launchpad PCB Front (as seen from front)Back (as seen from front) 0Ω resistors Test line from debugger Test line from debugger oscillates at 25kHz (a bit more than max on VLO freq of 20 kHz). Capacitance between Test and P2.6 (XIN) caused it to oscillate. Putting finger on PCB near P2.6 stopped light from blinking because of extra capacitance (voltage divider). Also – powering Launchpad from battery (so debugger isn’t on) stopped program from working.

8 The Fix void main(void){ WDTCTL = WDTPW + WDTHOLD; // Kill Watchdog P1DIR |= 0x01; // P1.0 output TACTL |= TASSEL_1 + ID_0 + MC_1; // Select ACLK, select up mode, select divider to be 1 TACCR0 = 6000; // Count up to CCTL0 = CCIE; // CCR0 interrupt enabled BCSCTL3 |= BIT5; // Set ACLK to be VLO _BIS_SR(LPM3_bits + GIE); // Go into lpm3 and enable interrupts }


Download ppt "Why Keliang’s code maybe did (or maybe didn’t) work … or High (impedance) Anxiety."

Similar presentations


Ads by Google