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.

smclk stops working when we disconnect the debugger

Other Parts Discussed in Thread: MSP430F5438A, MSP430F5438

We have an application that is using USCIA1 for PC communication.

                                                                   USCIA0 for XBEE communication

Development software  is IAR 5.40, debugger is MSP430FET-UIF, MCU msp430f5438A.

Development platform is TI MSP430f5438 dev board and also our custom designed board with same MCU.

By the following code below, we init clock module with 12 MHz DCO setting, then usarts etc...

* When we run the code with the debugger, everything works.  Although we made this setting;

P11DIR |= 0x07;                           // ACLK, MCLK, SMCLK set out to pins
P11SEL |= 0x07;                           // P11.0,1,2 for debugging purposes

we could not measure smclk on regarding pin, we could only see aclk wave form.

* then we deattach the debugger, it continues working

* after a power on reset, uart stops working, then we can not get any respond from the mcu's uart. But at this time a led continues blinking which is toggling in timer0 interrupt.

* after a long investigation, we assumed that smclk stops working after power on reset, because when we make a new configuration for uarts that are using aclk for the clock source, it continues working

/* clock init , 12MHz DCO */

void init_clock(void)
{
  P11DIR |= 0x07;                           // ACLK, MCLK, SMCLK set out to pins
  P11SEL |= 0x07;                           // P11.0,1,2 for debugging purposes.

  UCSCTL3 |= SELREF_2;                      // Set DCO FLL reference = REFO
  UCSCTL4 |= SELA_2;                        // Set ACLK = REFO

  __bis_SR_register(SCG0);                  // Disable the FLL control loop
  UCSCTL0 = 0x0000;                         // Set lowest possible DCOx, MODx
  UCSCTL1 = DCORSEL_5;                      // Select DCO range 24MHz operation
  UCSCTL2 = FLLD_1 + 366;                   // Set DCO Multiplier for 12MHz
                                            // (N + 1) * FLLRef = Fdco
                                            // (366 + 1) * 32768 = 12MHz
                                            // Set FLL Div = fDCOCLK/2
  __bic_SR_register(SCG0);                  // Enable the FLL control loop

  // Worst-case settling time for the DCO when the DCO range bits have been
  // changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
  // UG for optimization.
  // 32 x 32 x 12 MHz / 32,768 Hz = 375000 = MCLK cycles for DCO to settle
  __delay_cycles(375000);
    
  // Loop until XT1,XT2 & DCO fault flag is cleared
  do
  {
    UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
                                            // Clear XT2,XT1,DCO fault flags
    SFRIFG1 &= ~OFIFG;                      // Clear fault flags
  }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag
}

void init_usart(void)
{
  P5SEL |= BIT6 + BIT7 ;  //* PC Usart pins, P5.6,7 = USCI_A1 TXD/RXD *//
  UCA1CTL1 |= UCSWRST;    /* Reset UART. */
  UCA1CTL1 = UCSSEL_2;   /* Use SMCLK. */
  UCA1BR0 = 78; //    /* Setup baud rate low byte. */
  UCA1BR1 = 0;//  /* Setup baud rate high byte. */
  UCA1MCTL = UCOS16 + UCBRF_2 + UCBRS_0;  
  UCA1CTL1 &= ~UCSWRST;   /* Take out of reset. */
  UCA1IE |= UCRXIE;   /* Enable interrupts. */
   
  /* XBEE USART initialisation */
  P3SEL |= BIT4 + BIT5;   //* XBEE Usart pins, P3.4,5 = USCI_A0 TXD/RXD *//
  UCA0CTL1 |= UCSWRST;    /* Reset UART. */
  UCA0CTL1 = UCSSEL_2;   /* Use SMCLK. */
  UCA0BR0 = 78;   /* Setup baud rate low byte. */
  UCA0BR1 = 0; /* Setup baud rate high byte. */
  UCA0MCTL = UCOS16 + UCBRF_2 + UCBRS_0;
  UCA0CTL1 &= ~UCSWRST;   /* Take out of reset. */
  UCA0IE |= UCRXIE;   /* Enable interrupts. */     
}

Looking forward your suggestions.

thanks in advance,

Gloin

  • we realized that when we use LPM0 for low power mode, our code could still run without debugger, we were using LPM3 and after a POR, the code does not run without debugger.

    I saw a comment on msp430f5xx family user guide as follows; "The TEST/SBWTCK pin is used for interfacing to the development tools via Spy-Bi-Wire and JTAG. When the TEST/SBWTCK pin is high, wakeup times from LPM2, LPM3, and LPM4 may be different compared to when TEST/SBWTCK is low. Pay careful attention to the realtime behavior when exiting from LPM2, LPM3, and LPM4 with the device connected to a development tool (for example, MSP-FET430UIF). See the PMM chapter for details. "

    what should we do in our code?

  • Gloin said:
    what should we do in our code?

    Change it to use ACLK because in LPM3 CPU, MCLK, SMCLK, DCO are disabled. DC generator disabled. ACLK is active. For more info please refer to User's Guide.

  • Ilmars said:

    what should we do in our code?

    Change it to use ACLK because in LPM3 CPU, MCLK, SMCLK, DCO are disabled. DC generator disabled. ACLK is active. For more info please refer to User's Guide.

    [/quote]

    helllo, thank your for your reply, do you mean sourcing uart with aclk? But we need to use 57600 baudrate for pc and xbee communication via Uart. With aclk sourcing we can not get higher baudrates. I want to catch a clue that why does the code run with debugger and without debugger it stops running. I think it is because of Vcore, Pmm or sth like that.. 

  • Gloin said:
    With aclk sourcing we can not get higher baudrates

    Right. Then don't use LPM3 but LPM1 instead.

    Gloin said:
    I want to catch a clue that why does the code run with debugger and without debugger it stops running.

    Because debugger does not allow CPU to enter LPM3.

  • Ilmars said:

    With aclk sourcing we can not get higher baudrates

    Right. Then don't use LPM3 but LPM1 instead.

    Gloin said:
    I want to catch a clue that why does the code run with debugger and without debugger it stops running.

    Because debugger does not allow CPU to enter LPM3.

    [/quote]

    thanks a lot Ilmars, we will change it to lpm1 and continue..

**Attention** This is a public forum