Jump to content
43oh

rivalslayer

Members
  • Content Count

    14
  • Joined

  • Last visited

Posts posted by rivalslayer

  1. I was working on a Simon Game which runs on LPM4 most of the time, and I was having some issues with bouncing. So I did waste a few CPU cycles for two specially placed delays. I have written the test code to light up two LEDs when a button is pressed and made it totally with external interrupts.

     

    When I used to work with AVRs, I used timers to debounce, but here I thought I can save too much battery if I used a little CPU utilization. I could use the timer with external interrupts but that would waste my only timer, which I have to use other purposes. ;)

     

    Here it goes,

     

    Two LEDs are wired to P1.0, P1.1 (with 220 ohms in series) and the button is hooked between GND and P1.4. I had to use internal pull ups and make this work. It is working pretty fine.

     

    #include
    
    long a;
    int counter = 0; //To check if the interrupt are working properly
    
    void init();
    
    int main(){
    init();
    _EINT();
    LPM4;
    while(1);
    }
    
    void init(){
    // Stop watchdog timer to prevent time out reset
     	WDTCTL = WDTPW + WDTHOLD;
    //Setting up the I/O
    P1DIR = BIT0 + BIT1;
    P1REN = BIT4;
    P1IE = BIT4;
    P1IES = BIT4;
    P1OUT = BIT4;
    P1IFG = 0x0;
    }
    
    #pragma vector = PORT1_VECTOR
    __interrupt void button_handler(){
    LPM4_EXIT;
    _DINT();
    P1OUT ^= BIT0 + BIT1;
    for(a = 0; a <= 0x200; a++);
    P1IES ^= BIT4;
    counter++;
    P1IFG = 0x0;
    for(a = 0; a <= 0x200; a++);
    _EINT();
    LPM4;
    }
    

     

    I like LPM4. :)

     

    I changed the PxIES register to toggle the edge selection of interrupts. And basically that did the trick. I had to write two little delays specially placed so no misleading edges are detected.

     

    Usually I don't put a while loop there in the main when I go to LPMs, but I saw that after a few ISRs, it stops working, and at the debugger I saw that it got restarted. So I put this while loop. I used the counter variable to see if the ISRs are working properly.

     

    I used some standard buttons (Those comes with LaunchPad, I dunno the names). :D

  2. @simpleavr I used external interrupt, with a button. It did the trick. :)

     

    @bluehash Thanks a lot! I have this footprint only and I am afraid the width of the real device is greater than the footprint. Have to modify is a bit. :)

     

    @GeekDoc Ya I know, but the width was not really correct there...

     

    BTW, This is my smallest PCB. :D

  3. I was wondering what I could do with all the low-power I got and I decided I can make a pretty small message box, which will display a message with the press of a button. This time, it's only a message in Binary ASCII form. :P

     

    I used a TicTac Lozenge box and made a small home brew through hole PCB, and powered it with a CR2032. I used the MSP430G2101 micro, as that was all I needed. I went up to LPM4 mode, to save a lot of power, and ran the whole application through timers and interrupts. I hope this thing will run for a few months on a single battery. (It never turns off, it just displays the message and sleeps again)

     

    Problem was the footprint of MSP430G2101 in EAGLE. It was not really up to the size of the real device (I got it from the internet, I forgot where). Had to improvise. Will be making a new footprint. This project is the first one where I made a PCB footprint (for the CR2032 battery holder) myself. :)

     

    Here is the thing...

    IMG_4402_Desktop_Resolution.jpg

  4. Hii...

     

    I recently got a LAUNCHPAD. TI has made shipping free in India, that was great! Saved me a lot. Thanks a lot to TI.

     

    I am excited about the fact that I can run a MSP430 for months with a single CR3032 Battery. It's awesome. Thought lacking project ideas currently, I am experimenting on various peripherals.

     

    I had some trouble with vectors on the beginning as I was more used to AVRs and WinAVR. Did have some trouble setting up IAR Embedded Workbench for MSP430, but had it working finally. Now I use CCS.

×
×
  • Create New...