Hi,
I am interfacing two sensors through i2c protocol and simultaneously i am also trying to attach a timestamp for the data i getting from those peripherals. For time stamp i have created timer library using the timer_B. Both the I2c library and Timer Library are working fine on their own space. But when i try to compile together the timer interrupt is not getting triggered only the i2c protocol is working and i tried with RTC also i got the same result. I am attaching by timer code here please go through it and let me know your suggestions
Thankyou
Timer code:
#include <msp430.h>
#include <stdio.h>
#include <stdint.h>
volatile uint32_t millis=4294967294;
uint8_t secs=0;
uint8_t minutes=0;
uint8_t hours=0;
uint32_t fun()
{
secs= seconds%60;
minutes = seconds/60;
hours = seconds/60/60;
return seconds;
}
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Configure GPIO
P1DIR |= BIT0;
P1OUT |= BIT0;
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
TB0CTL |=TB0CTL; //Clears the timer
TB0CTL = TBSSEL__ACLK | MC__CONTINOUS; // SMCLK, continuous mode
TB0CTL|= TBIE;
__enable_interrupt(); // Enter LPM0 w/ interrupt
while(1)
{
i=fun();
}
}
// Timer0_B0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER0_B1_VECTOR
__interrupt void TIMER0_B1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_B1_VECTOR))) TIMER0_B1_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(TB0IV, TBIV__TBIFG))
{
case TBIV__NONE: break; // No interrupt
case TBIV__TBCCR1: break; // TB0CCR1 interrupt
case TBIV__TBCCR2: break; // TB0CCR2 interrupt
case TBIV__TBCCR3: break; // TB0CCR3 interrupt
case TBIV__TBCCR4: break; // TB0CCR4 interrupt
case TBIV__TBCCR5: break; // TB0CCR5 interrupt
case TBIV__TBCCR6: break; // TB0CCR6 interrupt
case TBIV__TBIFG: // overflow
seconds=seconds+1;
P1OUT ^= BIT0;
break;
default: break;
}
}