Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 64959

Forum Post: ccs not update values + keypad implementation into msp430g2

$
0
0
Hello Everybody, I've purchase a msp-exp430g2 experimenter board and i have a 4x4 keypad matrix. I've started to write a program that communicate with keypad I have 2 problems: 1. the values of the msp430 variables(P2OUT,P2IN...) not changing even when i'm using operators to manipulate the bits. 2. i don't know what is wrong with my code. it would br great if someone could help me to see what i'm doing wrong I've attached below images of the reult of operator and i've copied my code Thank you for all you help. #include /* * main.c */ #define P1_3 BIT3 #define P1_4 BIT4 #define P1_5 BIT5 #define P1_7 BIT7 #define P2_0 BIT0 #define P2_1 BIT1 #define P2_2 BIT2 #define P2_3 BIT3 #define LEN 4 char matrix[LEN][LEN] ={'1','2','3','4', '5','6','7','8', '9','0','a','b', 'c','d','e','f'}; char ScanKey(); void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P2DIR |= (BIT0 + BIT1 + BIT2 + BIT3); // Output Direction p2.0,p2.1,p2.2,p2.3 P2OUT &= ~(BIT0 + BIT1 + BIT2 + BIT3); // Put output to low P1DIR &= ~(BIT3 + BIT4 + BIT5 + BIT7); P1REN |= (BIT3 + BIT4 + BIT5 + BIT7); P1OUT |= (BIT3 + BIT4 + BIT5 + BIT7); P1IES |= (BIT3 + BIT4 + BIT5 + BIT7); P1IE |= (BIT3 + BIT4 + BIT5 + BIT7); P1IFG = 0; //Clear Port1 IFG P2IFG = 0; //Clear Port2 IFG _EINT(); } char ScanKey() { unsigned char row_sel=0; unsigned char key_in=0; unsigned char keyrow=0; unsigned char i=0; unsigned char j=0; for (i = 0 ; i > 1; } row_sel=0; switch(i) { case 0: P2OUT &= ~BIT0; break; case 1: P2OUT &= ~BIT1; break; case 2: P2OUT &= ~BIT2; break; case 3: P2OUT &= ~BIT3; break; } } P2DIR |= (BIT0 + BIT1 + BIT2 + BIT3); // Output Direction p2.0,p2.1,p2.2,p2.3 P2OUT &= ~(BIT0 + BIT1 + BIT2 + BIT3); // Put output to low } #pragma vector=PORT1_VECTOR __interrupt void port_1(void) { char key; P1IFG = 0; //Clear Port1 IFG P2IFG = 0; //Clear Port2 IFG key = ScanKey(); }

Viewing all articles
Browse latest Browse all 64959

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>