pvoluitd 0 Posted October 24, 2017 Share Posted October 24, 2017 Hallo guys, I am working on MSP430 and want to use incremental rotary encoder to control the menu, that I will later make. I decide to try to flicker the both LED first to see if I have the right programm to take input from the rotary encoder. I have the A_Output (CLK) and B_Output (DT) on Pins 2.1 and 2.2 #include "msp430g2553.h" char c_P2IN; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P2OUT |= 0x07; P2REN |= 0x07; P1DIR |= 0x41; // Set P1.0 and P1.6 to output direction P2IE |= 0x07; // P2 (Bit0, Bit1 und Bit2) interrupt enabled P2IFG = 0x00; // P2IFG cleared _BIS_SR(LPM4_bits + GIE); // Enter LPM4 w/interrupt while(1) { c_P2IN = P2IN; //Monitoring the P2IN; } } // Port 1 interrupt service routine #pragma vector=PORT2_VECTOR __interrupt void Port_2(void) { if(P2IFG&BIT1) { if (!(c_P2IN&BIT2)) { P1OUT^= BIT6; _delay_cycles(100); P2IFG = 0x00; } } if(P2IFG&BIT2) { if (!(c_P2IN&BIT21)) { P1OUT^= BIT0; _delay_cycles(100); P2IFG = 0x00; } } } It works for maybe 4-5 turns, and then it doesn't for 2 turns, and for the next few turns it works again. Can you please give me idea how to do it? Quote Link to post Share on other sites
zeke 693 Posted October 24, 2017 Share Posted October 24, 2017 @pvoluitd Feast your eyes on this thread: http://forum.43oh.com/topic/947-rotary-encoder-and-the-lp/ I am sure you will find the information that you need right there. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.