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

MSP432P401R: Pulse counter Interrupt difficulty

$
0
0

Part Number:MSP432P401R

Okay, I'm a newbie and I'm trying to implement a pulse counter using the TACLK input pin on the launchpad. All I want is an interrupt to be triggered when i press a push button which will then increment a counter which is a global variable. I may be doing something stupid here but any help is appreciated

//*****************************************************************************
//
// MSP432 main.c template - Empty main
//
//****************************************************************************

#include "msp.h"

float g_fCount;

void main(void)
{
	
    WDTCTL = WDTPW | WDTHOLD;           // Stop watchdog timer

    TA1CTL = TASSEL_0 + MC_2 + TAIE; //TACLK source, Cont mode, enable TA1 Interrupt

    __enable_interrupt();
	
    while(1){

    }
}

void TA1_N_IRQHandler (void){
    g_fCount++; //Increment Counter
    TA1CTL = !TAIFG; //Set interrupt flag to 0
}


Viewing all articles
Browse latest Browse all 21946

Trending Articles



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