Hello,
When I am executing my code, if I press down the button P1.1 during debugging mode, LED associated with P1.0 stops blinking. When I pause the debugging session, this file pops up
;******************************************************************************
;* ISR_TRAP.ASM - v16.9.4 *
;* *
;* Copyright (c) 2003-2017 Texas Instruments Incorporated *
;* http://www.ti.com/ *
;* *
;* Redistribution and use in source and binary forms, with or without *
;* modification, are permitted provided that the following conditions *
;* are met: *
;* *
;* Redistributions of source code must retain the above copyright *
;* notice, this list of conditions and the following disclaimer. *
;* *
;* Redistributions in binary form must reproduce the above copyright *
;* notice, this list of conditions and the following disclaimer in *
;* the documentation and/or other materials provided with the *
;* distribution. *
;* *
;* Neither the name of Texas Instruments Incorporated nor the names *
;* of its contributors may be used to endorse or promote products *
;* derived from this software without specific prior written *
;* permission. *
;* *
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
;* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
;* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
;* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
;* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
;* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
;* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
;* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
;* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
;* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
;* *
;******************************************************************************
;-----------------------------------------------------------------------------
;-- default ISR handler if user does not supply
;-- simply puts device into lpm0
;-----------------------------------------------------------------------------
.sect ".text:_isr:__TI_ISR_TRAP"
.align 2
.global __TI_ISR_TRAP
__TI_ISR_TRAP:
BIS.W #(0x0010),SR
JMP __TI_ISR_TRAP
NOP ; CPU40 Compatibility NOP
;******************************************************************************
;* BUILD ATTRIBUTES *
;* HW_MPY_INLINE_INFO=1: file does not have any inlined hw mpy *
;* HW_MPY_ISR_INFO =1: file does not have ISR's with mpy or func calls *
;******************************************************************************
.battr "TI", Tag_File, 1, Tag_HW_MPY_INLINE_INFO(1)
.battr "TI", Tag_File, 1, Tag_HW_MPY_ISR_INFO(1)
My code
// Author: Matt Dxxxxxxxx
// Lab: 3
// Section: Button Delay
// Device: FR6989
#include <msp430.h>
volatile unsigned int button_count;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
P1DIR |= BIT0; // Set P1.0 to output direction -- LED
P9DIR |= BIT7; // Set P9.7 to output direction --- LED
P1DIR &= ~BIT1; // Set P1.1 to button input
P1REN |= BIT1; // Enable Pull Up Resistor for pin1.1
P1OUT |= BIT1; //SPECIFIED AS A PULLUP FOR P1.1
P1IES &= ~BIT1; //Have flag set on Low to High
P1IE |= BIT1; //enable interrupts for Pin 1.1
P1IFG &= ~BIT1; //Clear Pin 1.1 flag so no immediate interrupt
P1DIR &= ~BIT2; // Set P1.2 to button input
P1REN |= BIT2; // Enable Pull Up Resistor for pin1.2
P1OUT |= BIT2; //SPECIFIED AS A PULLUP FOR P1.2
P1IES |= BIT2; //Have flag set on High to Low
P1IE |= BIT2; //enable interrupts for Pin 1.1
P1IFG &= ~BIT2; //Clear Pin 1.1 flag so no immediate interrupt
TA0CCTL0 |= CCIE; // TA0CCR0 interrupt enabled
TA0CCR0 = 3277; //Set value of TA0CCR0 for comparison
TA0CTL |= TASSEL_1 + MC_1; //Pick ACLK & Set Counter to Up Mode
TA0CTL |= TACLR; //Clear Timer A0
TA1CCTL0 |= CCIE; // TA1CCR0 interrupt enabled
TA1CCR0 = 512; //Set value of TA1CCR0 for comparison
TA1CTL |= ID_3; //Divide clock by 8, ACLK will be chosen, so 4096 hz
TA1EX0 |= TAIDEX_7; //Divide ACLK further by 8 to 512 hz
TA1CTL |= TACLR; //Clear Timer A1
_enable_interrupt();
for(;;)
{
while(!(P1IN & BIT1))
{
if(TA1R == 0)
{
TA1CTL |= TASSEL_1 + MC_1; //Pick ACLK & Set Counter to Up Mode
}
}
}
}
#pragma vector = TIMER0_A0_VECTOR
__interrupt void TimerA0_ISR (void)
{
P1OUT ^= BIT0;
}
#pragma vector = TIMER1_A1_VECTOR
__interrupt void TimerA1_ISR (void)
{
P9OUT ^= BIT7;
button_count++;
}
#pragma vector = PORT1_VECTOR
__interrupt void P1_ISR(void)
{
switch(P1IV)
{
case P1IV_P1IFG1:
{
TA0CCR0 = 3277*button_count; //slow down blink speed
break;
}
case P1IV_P1IFG2:
{
TA0CCR0 = 3277; //reset blink speed
break;
}
}
}
What I am attempting to do is count the number of seconds that I have the button associated with P1.1 held down, so when I hold down the button, Timer A1 gets activated, every second it enters TimerA1_ISR, blinks LED P9.7 (to indicate a second has passed), and increments button_count. When I let go of button P1.1, I should enter P1_ISR and change the value TA0CCR0, which alters the led frequency (slowing it down) of P1.0
I think something is wrong with my TimerA1_ISR but Idk what. I set a break for it, but never enter it. When I hold down the button, the LED P1.0 stops blinking, I pause the debugger and the isr_trap comes up.
edit: when the LED stops blinking and I pause the debug, SR_CPUOFF = 1, indicating LPM0, which makes sense that the LED stops blinking.