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.

MSP430G2553 硬件 辅助时钟不稳定问题

Other Parts Discussed in Thread: MSP430G2553

我现在用MSP430G2553处理器,用ACLK时钟实现串口9600波特率和定时器应用,发现有少部分会有出问题的,硬件布局布线感觉没啥大问题,经查发现是32768晶体不起震,无时钟,不知道问题出在哪里,32768负载电容更换6pf、12pf、22pf都无反应,感觉是晶振这出的问题

 

软件设置如下:

void init_clock(void)
{
     BCSCTL1 = CALBC1_8MHZ;
     DCOCTL  = CALDCO_8MHZ;
     BCSCTL3 &= ~0x30;       //选择LFXT1CLK为时钟源
      BCSCTL3 |= XCAP_3;
}

void init_uart(void)
{

   UCA0CTL1 |= UCSWRST;    //set UCSWRST     //UCA0CTL0   UCA0CTL0 remains in  resetted state
   UCA0CTL1 &=~ (UCSSEL0+UCSSEL1);       //清除之前的时钟设置

  UCA0CTL1 |= UCSSEL_1;                     //ACLK
  UCA0BR0 = 3;                              // ACLK 32768Hz 9600   32768Hz/9600 = 3.41
  UCA0BR1 = 0;                              // 32768Hz 9600
  UCA0MCTL = UCBRS1 + UCBRS0;               // Modulation UCBRSx = 3 
  P1SEL|=BIT1+BIT2; //将P1.1 P1.2设为第二功能
  P1SEL2|=BIT1+BIT2;
    
  IE2 |= UCA0RXIE;                         // Enable USCI_A0 RX interrupt  接收中断使能

 UCA0CTL1&=~UCSWRST;                        //禁止软件复位!
}


void timer1_init(void)
{
  TA0CTL |= TASSEL_1+MC_2+TACLR;       //选择ACLK时钟作为计数时钟源,不分频   必须连续计数模式 
  TA0CCTL0 = CCIE;                                     //7.8125ms定时
  TA0CCTL1 = CCIE;
  TA0CCR1 = 327;                                          //10ms         256->7.8125ms定时
}

  • 楼主,

        如果想使用外部的晶振,你的初始化时钟的代码可能需要修改一下,建议参考User guide中的汇编范例来编写时钟初始化代码:

    5.2.7.1 Sourcing MCLK from a Crystal
    After a PUC, the basic clock module+ uses DCOCLK for MCLK. If required, MCLK may be sourced from
    LFXT1 or XT2 - if available.
    The sequence to switch the MCLK source from the DCO clock to the crystal clock (LFXT1CLK or
    XT2CLK) is:
    1. Turn on the crystal oscillator and select the appropriate mode
    2. Clear the OFIFG flag
    3. Wait at least 50 μs
    4. Test OFIFG, and repeat steps 2 through 4 until OFIFG remains cleared.
    ; Select LFXT1 (HF mode) for MCLK
    BIC.W #OSCOFF,SR ; Turn on osc.
    BIS.B #XTS,&BCSCTL1 ; HF mode
    MOV.B #LFXT1S0,&BCSCTL3 ; 1-3MHz Crystal
    L1 BIC.B #OFIFG,&IFG1 ; Clear OFIFG
    MOV.W #0FFh,R15 ; Delay
    L2 DEC.W R15 ;
    JNZ L2 ;
    BIT.B #OFIFG,&IFG1 ; Re-test OFIFG
    JNZ L1 ; Repeat test if needed
    BIS.B #SELM1+SELM0,&BCSCTL2 ; Select LFXT1CLK

  • 您好,我想使用32768晶体作为ACLK的时钟,上面的设置和ACLK的设置没关系吧?还有我想知道使用汇编代码和C写寄存器区别在哪里,IAR中输入这些代码,编译器会报错!目前晶体中使用32768晶体,我的外部电路负载电容应该如何设置,以及CPU内部电容CAP的配置?

           系统采用低功耗设计,

        采用LPM3休眠唤醒模式,软件如何设计可以最大化降低功耗呢,目前是这么写的,您看下是否合理,谢谢

    #pragma vector=TIMER0_A1_VECTOR
    __interrupt void Timer0_A1(void)
    {

          __bic_SR_register_on_exit(LPM3_bits);     

        user_idle();

    }

    主函数:

    main{

    while(1){

     __bis_SR_register(LPM3_bits+GIE);

    }

    }