This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430FR5987: msp430fr5987

Part Number: MSP430FR5987
Other Parts Discussed in Thread: MSP430FR5889

Tool/software: Code Composer Studio

I have a working design written for the msp430fr5889 that I am porting to a msp430fr5987 in an effort to standardize on one msp430 for all our projects. I am having trouble with the code on the 5987.

I have created my own flag to bypass some of the complexity from the original author.

I have optimization turned off and my new flag is set to volatile.

I am setting a flag (timer_flag) in the Timer A0 ISR. The main loop of my code sees the flag set one time but never again?


extern int timer_flag;

//////////////////////////////////////////////////////////////////////
// Main Loop uses periodic timer to update the system based on serial data
//
//       calls main application function
//
//////////////////////////////////////////////////////////////////////
int main(void)
{
unsigned int test;

Init_System_BSP();                                               // Initialize system and controller

  while(1)                                                       // continuous loop
  {
     Comm_Process_Msg(comm_buff0, sys_data);                     // check any messages

     test = sys_timers[32];

//     if(System_Timers_Check_Flag(TMR_0, sys_timers))             // check system timer 0
     if(timer_flag)
     {
         timer_flag =0;
         Update_Sys_State_Machine(adc_rslt,comm_buff0, sys_data);  // update state machine
      }                                                          // end check system periodic timer
  }                                                              // end main while(1) loop
}                                                                // end main function

The TimerA0 ISR sets the flag (timer_flag). I have a break point on this and can see it working.

The original designer has a array to hold timer info(sys_timers[]) so he can effectively control 16 timers from one ISR.

The code is only setting one entry in his array, index 0 and is working correctly.

I have bypassed that and set my global timer_flag. A break point confirms that this flag is repeatably being set to 1.

It looks like the man routine does not see any changes made by the ISR?? Other than the first one???

///////////////////////////////////////////////////////////////
// System_Timer_Lib.c
//
//  Created on: Apr 13, 2016
//      Author: jpogge
//
// System Timers uses a global integer array of 4 - 16 timers
// set by #define TMR_NUM_TMRS in System_Timers_Lib.h The last index is
// used as a bit flag
//
// index 0 is timer counter 0
// index 1 is timer counter 1
// index 2 is timer counter 2
// index 3 is timer counter 3

// |TMR_CNT_0|TMR_CNT_1| |TMR_CNT_2|TMR_CNT_3|TMR_CNT_4|TMR_FLGS
///////////////////////////////////////////////////////////////

#include <msp430.h>
#include "System_Timer_Lib.h"
#include "Stream_Utility_Lib.h"
#include "Bit_Lib.h"
#include "Timers_Lib.h"

volatile int timer_flag =0;

unsigned int sys_timers[TMR_REG_SZE];   // Timer data xxxx

////////////////////////////////////////////////////////////////////////////////////////////
// System Timer Tick Interrupt
//
///////////////////////////////////////////////////////////////////////////////////////////

#pragma vector = TIMER0_A0_VECTOR
interrupt void System_Tick_IRQ(void)
{
       // Call timer loop here

     __disable_interrupt();                                     // disable interrupts
       System_Timers_Update(sys_timers);
     __enable_interrupt();                                     // re-enable interrupts
}


//////////////////////////////////////////////////////////////////////////////////
// Timers_Update    uses uint 16 timer structure
//
//  increments each at tick rate, period determined when trigger count reached
// flag corresponding bit set in register 1  TMR_FLAGS  0 - 15
//
//
//
//////////////////////////////////////////////////////////////////////////////////
void System_Timers_Update(unsigned int *sys_tmrs)
{
    unsigned int i;

    for(i = 0; i < TMR_NUM_TMRS; ++i)                           // loop through each timer active
        {
          if(sys_tmrs[i] > 0x0000)                                // if timer greater than zero
            {
               --sys_tmrs[i];                                   // decrement if greater than zero
            }
          if(sys_tmrs[i] == 0x0000)                             // if the zero no update timer expire or not used
            {
              if(sys_tmrs[i + TMR_RST_IDX])                     // if there is a reset value timer is active
                {
                System_Timers_Reset(i, sys_tmrs);               // reload rest value if counter reaches zero
//                sys_tmrs[32] =1;            // set the flag
//                sys_timers[32] =1;
                timer_flag=1;
//                System_Timers_Set_Flag(i, sys_tmrs);            // set the flag
                }
            }

        }
}

**Attention** This is a public forum