Jump to content

Search the Community

Showing results for tags 'button'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks

Calendars

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Sparkfun


Github

Found 3 results

  1. I've been working on a project for MSP-EXP430G2 which requires two buttons and hit the problem that S1 is set up as a reset button. Unlike S2 it's not connected to a regular GPIO pin; instead it's connected to the nRST/NMI pin. I looked for information on using the reset button as a user input and found some examples, but they all used the NMI ISR to track rising and falling edges. For example, see this post from the 43oh blog: Using the MSP430G2xx1 nRST NMI Pin as an Input. I really wanted some way to sample the current state of the button directly, which is tricky because there's no PxIN equivalent for the NMI input. Here's a snippet demonstrating the method I ended up using: #include <msp430.h> int main(void) { WDTCTL = WDTPW | WDTHOLD; P1DIR = BIT0; P1OUT = 0; while(1) { // Poll S1 WDTCTL = WDTPW | WDTHOLD | WDTNMI; // Detect NMI rising edges IFG1 &= ~NMIIFG; // Clear latched value WDTCTL = WDTPW | WDTHOLD | WDTNMI | WDTNMIES; // Detect NMI falling edges unsigned char buttonPressed = (IFG1 & NMIIFG) ? 1 : 0; // Read latched value if(buttonPressed) { P1OUT |= BIT0; } else { P1OUT &= ~BIT0; } __delay_cycles(20000); } } The nice thing about this is that the polling code is self-contained and can be dropped in wherever you like. How it works The schematic for the reset/NMI pin in the G2 family looks like this: The output of a rising-edge detector is latched to give the value of NMIIFG. If the WDTNMIIES bit is set an inverter is switched in ahead of the edge detector so it detects falling edges instead. To poll the state of the nRST/NMI pin WDTNMIES is cleared, followed by NMIIFG. Next WDTNMIES is set high and finally NMIIFG is read. When read, the NMIIFG bit will be set if: S1 was pressed between when WDTNMIES went high and NMIIFG was read S1 was released between when NMIIFG was cleared and WDTNMIES went high (ie it was pressed but you just released it) The internal switch controlled by WDTNMIES is used to force an edge transition. This is what lets the edge detector output high even if the button was held down for a long time. Note that NMIIE is not set, so the NMI interrupt is never requested. Warnings These warnings apply to any use of the nRST/NMI pin for user input: S1 cannot be used while SBW debugging is active. You need to disable or "free run" the debugger so the two functions don't interfere with each other If S1 is held down and the MCU crashes or resets it will be held in reset until you release the button.
  2. Hi Everybody; I am newbei about C200O programming with CodeComposerStudio. I tried simple code which is led blinking. But I want to use button. And I can't run it. Anyway I attached code and screenshot. What's wrong my code? GPIO_setMode(myGpio, GPIO_Number_12, GPIO_12_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_12, GPIO_Direction_Input ); int state = GPIO_getData(myGpio, GPIO_Number_12); GPIO_setLow(myGpio, GPIO_Number_0); GPIO_setLow(myGpio, GPIO_Number_1); GPIO_setLow(myGpio, GPIO_Number_2); GPIO_setLow(myGpio, GPIO_Number_3); while(1) { if(state != 1) { GPIO_setHigh(myGpio, GPIO_Number_0); GPIO_setHigh(myGpio, GPIO_Number_1); GPIO_setHigh(myGpio, GPIO_Number_2); GPIO_setHigh(myGpio, GPIO_Number_3); } else { GPIO_setLow(myGpio, GPIO_Number_0); GPIO_setLow(myGpio, GPIO_Number_1); GPIO_setLow(myGpio, GPIO_Number_2); GPIO_setLow(myGpio, GPIO_Number_3); } } }
  3. Hi everyone, it is probably a very stupid question. But i'm simply trying to toggle a LED(P1.0) by using the button S2(P1.1) which is on the launch pad of FR5969. but it is not wotking at all... #include <msp430.h> void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR |= 0x01; // Set P1.0 to output direction P1REN = 0x02; ? P1OUT= 0x02; ? P1IE |= 0x02; // P1.1 interrupt enabled P1IES |= 0x02; // P1.1 Hi/lo edge P1IFG &= ~0x02; // P1.1 IFG cleared _BIS_SR(LPM3_bits + GIE); // Enter LPM4 w/interrupt } // Port 1 interrupt service routine #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { P1OUT ^= 0x01; // P1.0 = toggle P1IFG &= ~0x02; // P1.4 IFG cleared } any suggestions? Thanks in advance Irene
×
×
  • Create New...