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.

MSP430FR6922: Timer is not operated on 1000 hz when msp430 fet is disconnected from controller board

Part Number: MSP430FR6922
Other Parts Discussed in Thread: MSP-FET

Hello,

   I want to run the timer @1000 hz freq in continuous mode and I am doing some comparisons in timer interrupt and take AD7190 adc data values. I am transmitting this adc's values in seperate while loop. When MSP-FET is connected timer interrupt is working fine and correct data transmit to to rpi. But, after flash the cde in MCU and disconnected the emulator from MCU timer  adc's value are not change. in while loop data transmit to rpi i.e. adc values. but those values are constant its not change.

What is the issue. I have attached code for your ref.

#include "common.h"

int main(void)
{
   WDTCTL = WDTPW | WDTHOLD;                 // Stop WDT

   variable_Set_zero();
   pin_init();
   dev_init_16M();                           // Microcontroller set on 16MHz
   RPI_UART();
   Timer();
   SPI_INT();                                // SPI initialization
   AD7190_register_read();

   __enable_interrupt();                     // Re-enable all interrupts
   __bis_SR_register(GIE);                   // Enter LPM3, interrupts enabled


  while (1)
  {
    
     if(DelayStart==1)                       // For sample 1 send LC data after every 1 sec to tare the LC readings
      {
         // (DCO=MCLK=16MHZ )so,
         // Count/MCLK freq=Time
         // 16000000/16MHz=1sec
         __delay_cycles(16000000);                        // delay calculate on 16 MHz
         AD7190_CH1_setup();
        //while(!((P1IN&BIT7)==0)){}     // Wait until data ready
         CurrentLCValue=ReadData();                       // Read load cell data
         CurrentLCValue1=CurrentLCValue&0x7FFF;

         LongtoInt.LongData=CurrentLCValue;               // Split 3 byte data into single byte
         giTransmitBuffer[0]=LongtoInt.ByteSplit[1];
         giTransmitBuffer[1]=LongtoInt.ByteSplit[0];
         giTransmitBuffer[2]=0x00;

         for(i=0;i<3;i++)      // Upto array from start to CRC lenth
         {
             while(!(UCA0IFG&UCTXIFG));
             UCA0TXBUF =  giTransmitBuffer[i];
         }
      }

     if (DataStart==1)
     {
         __delay_cycles(16000);

         LongtoInt.LongData=CurrentLCValue;//LoadCellData is in 16 bit first 2 byte;
         giTransmitBuffer[0]=LongtoInt.ByteSplit[1];
         giTransmitBuffer[1]=LongtoInt.ByteSplit[0];
         giTransmitBuffer[2]=0x00;

         for(i=0;i<3;i++)      // upto array from start to CRC lenth
         {
             while(!(UCA0IFG&UCTXIFG));
             UCA0TXBUF =giTransmitBuffer[i];
         }
     }

     /*******************************Test Stop if overload+***************************/
    if (teststop==1)
     {
        //timer stop
        TA0CCTL0 &= ~CCIE;

        RTCCTL0_L &= ~RTCTEVIE;    //rtc disabled

        // relay off
        P7OUT &=~BIT0;

        teststop=0;
     }
  }
}

void send_start_command(void)
{
    giTransmitBuffer[0]=0xAA;
    giTransmitBuffer[1]=0xBB;
    giTransmitBuffer[2]=0xCC;
    giTransmitBuffer[3]=0xDD;
    giTransmitBuffer[4]=0xEE;
    giTransmitBuffer[5]=0xFF;

    for(i=0;i<6;i++)      // Upto array from start to CRC lenth
    {
        while(!(UCA0IFG&UCTXIFG));
        UCA0TXBUF =  giTransmitBuffer[i];
    }
}
/*
 * Timer.c
 *
 *  Created on: 09-Sep-2022
 *      Author: Admin
 */
#include "common.h"

void Timer(void)
{
    //Timer Period in Seconds = DIV x (TACCR0 + 1)/Input Clock in Hz
    //freq=1/timer period
    //TA0CCR0=(Input Clock in Hz/DIV*Freq)-1;
    //TA0CCTL0 = CCIE;                          // TACCR0 interrupt enabled
    TA0CCR0 = 4000;                             //(4MHz/4000=1000 Hz)
    TA0CTL = TASSEL__SMCLK | MC__CONTINUOUS;     // SMCLK, continuous mode

}

// Timer0_A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) TIMER0_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
      if(Data==1)
       {
           send_start_command();
           AD7190_CH1_setup();
           //while(!((P1IN&BIT7)==0)){}           // Wait until data ready
           CurrentLCValue=ReadData();             // Read load cell data
           DataStart=1;
       }

       Data=0;

       AD7190_CH1_setup();
       //while(!((P1IN&BIT7)==0)){}           // Wait until data ready
       CurrentLCValue=ReadData();             // Read load cell data
       CurrentLCValue3=CurrentLCValue&0x7FFF;

       if(CurrentLCValue3>=0x1F59)     // if 9F5961=10443105=9.567mV=675 psi (90 percent of 10.63 mV means 750 psi) is reached test stop
           //9F59&7FFF=0x1F59
         {
             Error[0]=0x10;
             Error[1]=0x10;
             Error[2]=0xAA;
             teststop=1;
         }

       TA0CCR0 += 4000;                         // Add Offset to TA0CCR0
}

  

  • Hello,

    The debugger for MSP430 is very intrusive and will skew timings and sometimes hide race conditions in your code. It also doesn't allow you to truly get down to the lowest LPMs. When debugging in this manner, I would suggest running in "Free Run" mode that disconnects the debugger interface so the device runs as if no debugger connected.  I also see you are setting the LPM to LPM3, while having the Timer clocked form SMCLK. (at least that's what your comments say, although I don't see where you actually go to LPM.)  SMCLK is turned off in LPM3, so a couple things can/will happen in this scenario. The timer won't run as its source clock is off. Once you do try to wake up from LPM3, you not only get the LPM3 wakeup penalty, but also SMCLK startup penalty. 

**Attention** This is a public forum