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.

MSP430G2955: Not work as expected

Guru 24520 points
Other Parts Discussed in Thread: MSP430G2955, MSP-TS430DA38

Hi community member,

Please provide your advice in order to resolve the following phenomenon.

[Phenomenon]

When added one line as below in the interrupt routine of Time A, not outputted the expected frequency from the port 4.5 which controlled by Timer B interrupt.


[Inserted line]

InterruptVectors_init.c: Line 56

 //      P2SEL &= ~(BIT1); // reset P2.1 for output ???

[Overview of program]

Timer B input clock source is set ACLK which was provided by external crystal(32.768kHz).

Timer A input clock source is set TAICLK(P2.0).  SMCLK(P2.1) is connected to TAICLK(P2.0) in order to supply the clock from SMCLK to TAICLK.

Use the DCO(8MHz) as MCLK. And DCO supply the frequency that divided  4 the DCO frequency to SMCLK.

Operation of interrupt

 * Timer A interrupt: Stop the Timer A and clear the LPM1 and set the P2.1 as output pin

During the Timer A is stopping, customer would like to use this port(P2.1) as output pin.

So, they will change the function from SMCLK output to GPIO output pin in timer A service routine.

   [Code]

///////////////////////////////////////////

   __interrupt void TIMER1_A1_ISR_HOOK(void)
{
    /* USER CODE START (section: TIMER1_A1_ISR_HOOK) */
    /* replace this comment with your code */
    char iflag;
    
    iflag = TA1IV & 0x0e;

    if(iflag == 0x0A){

      // Stop Timer0_A1
      TA1CTL &= ~(MC1 + MC0); // Clear MCx bits

      //P2SEL &= ~(BIT1); // reset P2.1 for output ???

      __bic_SR_register_on_exit(LPM1_bits);   // Exit LPM
    }

    /* USER CODE END (section: TIMER1_A1_ISR_HOOK) */
}

///////////////////////////////////////////

 * Timer B interrupt: Start the Timer A and clear the LPM3 and invert the output status of P4.5.

  [Code]

///////////////////////////////////////////

  __interrupt void TIMERB1_ISR_HOOK(void)
{
    /* USER CODE START (section: TIMERB1_ISR_HOOK) */
    /* replace this comment with your code */
    char iflag;
    
    iflag = TB0IV & 0x0e;
    
    if(iflag == 0x02){

      // Clear and start Timer0_A1
      TA1CTL |= MC_1 | TACLR; // Upmode

      /* Port 2.1 : output SMCLK */
      P2SEL |= BIT1; // P2.1 SMCLK output

      P4OUT ^= BIT5; // measure ACLK 32kHz

      __bic_SR_register_on_exit(LPM3_bits);   // Exit LPM

    }
    /* USER CODE END (section: TIMERB1_ISR_HOOK) */
}

///////////////////////////////////////////

The interrupt of Timer A is stopped until happen the interrupt of Timer B.

 (i.e. In order to enable the Timer A  is trigger the Timer B interrupt.)

And they enter the LPM at the following timing.

 * Disable Timer A: LPM3.

 * Enable Timer A: LPM1

I attached the used program as below.

[Used program]

8182.crystal_test.zip

[Used Evaluation Board]

 * MSP-FET430U38 with external crystal(32.768kHz) and load capacitors.
   -> Connect the pin of P2.0 and P2.1

 * MSP430G2955

 * CCS ver 5.5

[Others]

1. When we set the High for P2.1, this phenomenon was improved. I do not understand this reason.

2. The correct operation did not confirm with connecting JTAG. So we need to write the program to flash and stop the debug. I do not understand this reason why we can confirm the correct operation by disconnected the JTAG.

If you have any questions, please let me know.

Best regards.

Kaka

  • Do anyone check for my post?

    If possible, would you please your advices by end of this week in Japan time?

    I need your help.....

    Best regards.

    Kaka

  • Hey Kato,
    PxSELx and PxSEL are used for primary and secondary functions. As you were  disabling
    P2SEL I suppose you were using Secondary module. 
    P2SEL2 and P2SEL 1 should go togeather. Try this. P2SEL2 & = ~BIT1; P2SEL &= ~BIT1;

     

  • Hi Sri,

    Thank you for your advice.

    I checked the operation whether this problem will improve by changing your code.

    However, the phenomenon did not improve.

    Also, I checked whether the crystal can be oscillated at this time, but the crystal on EVM was not stabled.

    I captured the waveform as below.

    7851.TEK00000.TIF

    CH1: Port 4.5(Generated approximately 512kHz square, if work correct)

    CH2: Port 2.1 and P2.0

    Ch3: Crystal

    If you have any questions, please let me know.

    Best regards.

    Kaka

  • Kaka,

    What are you trying to check with this line? (main.c)

    state = TA1CTL & 0x30; // check timerA1


    In other words, what are you checking for here?   You really shouldn't check the control register while the Timer is running. This can cause unexpected behavior. If youa re just trying to see if Timer A is one, may I suggest using a a flag / or the variable state itself to do this?  It would need to be set and cleared in the Timer Interrupts. So every time you go into the TimerA interrupt to turn off Timer A, set it to 0, when you go to TimerB to turn on TimerA, set it to 1.

    Regards,

    JH

  • Hi JH,

    Thank you for your response.

    I removed the function of entering the LPM in order to be simpler code, but this phenomenon did not improved.

    Please check the following project.

    2480.crystal_test.zip

    I captured some waveforms and attached them to this post.

    Note: CH1: P2.1/P2.0  CH2: P4.5  CH3: XOUT

    6082.1_Output_H.TIF

    The above waveform is set "H" for P2.1.

    6835.2_Output_Default.TIF

    The above waveform is set "Default state(L)" for P2.1.

    Regarding layout data of this EVM, the P2.1/P2.0 and XOUT pin is cross.  So, this is the cause of effecting some noise to XOUT line from P2.1/P2.0.  This is the reason why I think this phenomenon was occurred by noise which is caused by layout of MSP-TS430DA38.  But I cannot understand the definite reason why the phenomenon was improved by setting P2.1 the state of  "H".

    How do you think?

    Best regards.

    Kaka

  • Hello Kaka,

    Interference from pin crossing does seem a likely culprit. As far why it improves with leaving output high instead of low, I do not have a full answer for you here, but I can take a guess. I would have to guess it has to do with some type of coupling to ground happens when the pin is set to low. The xtal can't drive the extra board capacitance introduced that way. Again this is only a guess. In order for you to keep developing your application, I would try a custom board, or change how you feed your clocks.

    I just realized you are driving TimerA via SMCLK. Why are you doing this via TACLK input and external connection to SMCLK output?  TimerA can be setup in such a way to have an internal connection to SMCLK to drive it. Please see the TimerA control register in the user guide for this configuration. This should make this much easier and you will not have to worry about interference problems on the board.

    Regards,

    JH

  • Hi JH,

    Thank you for your comments.

    I have explained to customer about your guess.  And closed this question.

    Thank you for your help and  efforts.

    And your suggestion, I and customer have known it. But I heard that customer need to use this usage.

    I do not have clearly reason for this.

    Best regards,

    Kaka
     

**Attention** This is a public forum