Jump to content

Matjaz

Members
  • Content Count

    8
  • Joined

  • Last visited

About Matjaz

  • Rank
    Noob Class

Profile Information

  • Gender
    Not Telling
  1. Ha! Got it. line "CACTL1 = CAON;" should have been "CACTL1 |= CAON;" of course. My bad. Thanks again, @@tripwire, because that extra piece of info was crucial, too! Adding here full working code for later reference. This now does work: #include <msp430.h> int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog P1DIR = BIT0; // config P1.0 as output to drive LED CACTL1 = CAREF1 + CARSEL + CAIE; // 0.5 Vcc ref on - pin, enable interrupts on rising edge. // CACTL1 = CAREF_2 + CARSEL + CAIE; // equivalent - CAREF1 and CAREF_2 are both 0x20 in the .h file CACTL2 = P2CA4 + CAF; // Input CA1 on + pin and add some filtering CACTL1 |= CAON; // activate comparator __bis_SR_register(GIE); // general enable of maskable interrupts // _BIS_SR(LPM0_bits + GIE); // alternative to above // __enable_interrupt(); // yet another alternative for (; { } // await eternity here } #pragma vector=COMPARATORA_VECTOR __interrupt void my_isr (void) { P1OUT ^= BIT0; // flip red LED state } // EOF
  2. Thanks @@tripwire, that was definitely missing. Added now, but still doesn't work. :-( Still trying...
  3. Dear all, I'm using CCS on Win7 and Launchpad 430g2 with a 2452 chip. I cannot get the ISR to execute when I externally drive comparator input voltage up and down. Minimal code is here. I think it should toggle LED whenever I go up. (Other code examples are reading P1.1 comparator correctly in same setup and also LED is connected correctly as tested with other code.) Any idea? Any obvious fault in code? Thanks! Matjaz #include <msp430.h> int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timeractivate comp P1OUT = 0; P1DIR = BIT0; CACTL1 = CAREF1 + CARSEL + CAIE; // 0.5 Vcc ref on - pin, enable interrupts on rising edge. CACTL2 = P2CA4; // Input CA1 on + pin CACTL1 = CAON; // activate comparator for (; { } } #pragma vector=COMPARATORA_VECTOR __interrupt void my_isr (void) { P1OUT ^= BIT0; } // EOF
  4. The multitasking mode is a temptingly possible culprit, but it is really funny that it behaves _exactly_ as the watchdog reset does. (I know from the tests compiled via CCS where I do have a working control over it). Ok, let's assume this is not WDT kicking in, but something else with a timing pattern that is, by chance, exactly the same. Then, a version of code with WDT enabled and another one with WDT reset disabled, it should still make a difference: an extra delay would still appear when WDT enabled. Reductio ad absurdum. So.. for the time being, I'm concluding this is a possible Energia feature. I will speculate here: Energia disables WDT resets in a way that does not really block it (as CCS does) but rather calls an empty function which returns in a couple of microseconds? thanks! Matjaz
  5. Yup, I understand that.. I wasn't wondering where it occurs but rather where I'll be thrown back at after it does. One would think that at start of code, right...? That's the beast's purpose...
  6. ...did as per @@tripwire suggestion now - fiddled the LED bit some just before the while(1): I see it does not really restart (no difference in bit banging pattern). This leads me into thinking that the WDT does not reset the chip but rather that it calls some sort of Interrupt handling routine which does nothing and returns, simply losing the 12us each time. I'm still kinda convinced it's really the WDT kicking in because in the test compiled in CCS this behavior depends exactly on the state of WDTHOLD bit. cheers
  7. No prob @@mgh, thanks anyway. @@tripwire, I think it's the watchdog because in one of my my two cross checks (with same board but another compiler) I can switch this behavior on and off by (un)commenting the WDTCTL line. BTW, I did try a similar test that you suggest but with LED toggling in setup(). It did not show up during resets. How come the watchdog reset is not throwing me in the setup routine but rather into loop()? cheers M
  8. Hi, guys, I cannot seem to be able to stop the watchdog on the Energia + MSP432 combo. (MSP-EXP432P401R Rev 1.0 + Energia 0101E0016 on Win7-64bit) // My minimal code buzzes the red led at 2MHz: #include "msp432p401r.h" void setup() { WDTCTL = WDTPW | WDTHOLD; // Stop WDT pinMode(RED_LED, OUTPUT); // configure pin } void loop() { while (1) { P2OUT ^= 0x01; P2OUT ^= 0x01; // flip pin twice }; } The 2MHz output signal freezes for 12us in either "1" or "0" state every 1ms. WDTHOLD bit does not help (in fact, any WDTCTL actions seem to be ignored). Cross testing done: - TI CCS Cloud correctly builds C code for same MSP-EXP432 board (i.e. WDTCTL line does make a difference there) - Same Energia IDE correctly builds equivalent code for a MSP-EXP430G2 /2452 board (WDTCTL line again does make a difference). (In addition, if it matters: pure C compiling in Energia as per https://bennthomsen.wordpress.com/engineering-toolbox/ti-msp430-launchpad/using-energia-to-code-in-c/ does not work for the 432 (compiles and flashes OK, but board remains dead) while it does work for a plain ol' 430 board.) There, hope there's enough data. Any ideas? Thanks a lot! Matjaz
×
×
  • Create New...