Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 22233

MSP432P401R: Count number of pulses on rising edge triggered

$
0
0

Part Number:MSP432P401R

Hello,

     I want to count number of pulses of encoder on high to low edge triggered on port pin ( rising edge) using MSP432. I have taken variable "a"  in interrupt. when interrupt is occurred on rising edge my count is increment by 1. but my interrupt is triggered on both edge. i got pulses 1000 as i expected is 500 only.

The program is shown below:-


int a = 0;

void main(void)
{
WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD; // stop watchdog timer

P6->DIR &= ~BIT0; // set P6.0 as a input direction
P6->REN = BIT0; // Enable pull-up resistor
P6->IFG &= ~ BIT0; // P1.4 IFG cleared
P6->IES &=~ BIT0; // high to low
P6->IE |= BIT0; // P1.4 interrupt enabled

// Enable Port 1 interrupt on the NVIC
NVIC->ISER[1] = 1 << ((PORT6_IRQn) & 31);

// wake up on exit from ISR
SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk;

for(;;){}
}


// Port 1 interrupt service routine
void PORT6_IRQHandler(void)
{
if(P6IFG & BIT0)
{
a=a+1;
}
P6->IFG &= ~BIT0;
}

please tell me where i am going wrong in code??

Thanks


Viewing all articles
Browse latest Browse all 22233

Latest Images

Trending Articles



Latest Images

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