The code below should to use interruptions to modify the time delay.
#include "msp.h" #include <inttypes.h> int i=0; int T=50000; int Tp; int Ta; int contador=0; void main(){ WDTCTL= WDTPW+WDTHOLD; P1SEL0 = 0x00; P1SEL1= 0x00; P1DIR|= (BIT5); P1DIR&=~BIT6; P1REN|=BIT6; P1OUT|=BIT5; P1IES |= BIT6; P1IFG &=~BIT6; P1IE |= BIT6; NVIC_ISER1 = 1 << ((INT_PORT1 - 16) & 31); __enable_interrupt(); while(1){ P1IE |= BIT6; if(contador == 0) { Tp=T/4; Ta=T-Tp; } if(contador == 1) { Tp=T/2; Ta=T-Tp; } if(contador == 2) { Tp=(3*T)/4; Ta=T-Tp; } if(contador == 3) { Tp=T; Ta=T-Tp; } if(contador == 4) { Tp=T/4; Ta=T-Tp; contador = -1; } P1OUT |= (BIT5); for(i=0;i<Tp;i++); P1OUT &= ~(BIT5); for(i=0;i<Ta;i++); // } } void interrupcion( void ) { contador=contador+1; P1IFG &= ~ BIT6; P1IE &= ~ BIT6; P1IES &= ~ BIT6; }
here is the start up file:
#include <stdint.h>
/* Forward declaration of the default fault handlers. */
static void resetISR(void);
static void nmiISR(void);
static void faultISR(void);
static void defaultISR(void);
/* External declaration for the reset handler that is to be called when the */
/* processor is started */
extern void _c_int00(void);
/* Linker variable that marks the top of the stack. */
extern unsigned long __STACK_END;
/* External declarations for the interrupt handlers used by the application. */
extern void interrupcion (void)
/* To be added by user */
/* Interrupt vector table. Note that the proper constructs must be placed on this to */
/* ensure that it ends up at physical address 0x0000.0000 or at the start of */
/* the program if located at a start address other than 0. */
#pragma RETAIN(interruptVectors)
#pragma DATA_SECTION(interruptVectors, ".intvecs")
void (* const interruptVectors[])(void) =
{
(void (*)(void))((uint32_t)&__STACK_END),
...
defaultISR, /* DMA_INT2 ISR */
defaultISR, /* DMA_INT1 ISR */
defaultISR, /* DMA_INT0 ISR */
interrupcion, /* PORT1 ISR */
defaultISR, /* PORT2 ISR */
defaultISR, /* PORT3 ISR */
defaultISR, /* PORT4 ISR */
...
};
.....
The problem is that the interruption does not works, every time I push the interruption button, the output LED (p1.5)remains in the last state, it looks like the interruption gets stuck and does not return to the main code.
I am using CCS v6 in UBUNTU