rahulr30
Newbie level 2
Hi everyone,
I am doing some motor control project in msp430g2553. I need to configure P1.2 as an interrupt. I looked up a few examples and wrote the following code. I have left certain other irrelevant parts of the code for brevity. I am using ccp for capture as well as compare. I am using adc as well. All of this are in ISRs. The clock is at 16 Mhz, the max possible from DCO. The code is below. While testing, I can see the P1.2 pin going high and low while I make it high and low. But the P1IFG flag just does not get set, due to which it is not going to the ISR. Any help will be appreciated. Thanks in advance.
I am doing some motor control project in msp430g2553. I need to configure P1.2 as an interrupt. I looked up a few examples and wrote the following code. I have left certain other irrelevant parts of the code for brevity. I am using ccp for capture as well as compare. I am using adc as well. All of this are in ISRs. The clock is at 16 Mhz, the max possible from DCO. The code is below. While testing, I can see the P1.2 pin going high and low while I make it high and low. But the P1IFG flag just does not get set, due to which it is not going to the ISR. Any help will be appreciated. Thanks in advance.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 void main(void) { ConfigWDT(); ConfigClocks(); ConfigCcp(); ConfigAdc(); P1DIR = BIT0 + BIT6; // P1.6 and P1.0 outputs P1SEL = BIT1 + BIT2; P1OUT = 0x00; P2DIR = 0xFF; P2OUT = 0x00; P1IE = BIT2; // BIT 2 USED FOR CORRECTOR PULSE //P1IES &= ~BIT2; // LOW TO HIGH TRANSITION P1IFG = 0x00; __enable_interrupt(); _BIS_SR(GIE); while(1) { //for (i = 1000; i > 0; i--); } } #pragma vector=PORT1_VECTOR __interrupt void count_reset (void) { count=0; P1IFG &= ~BIT2; }
Last edited by a moderator: