german010 发表于 2011-5-23 09:06:18

此时 msp430系统 的时钟系统 是 怎么选择的呢?

如下面所示 程序,没有设置 时钟源,为何能以 9600正确接收到数据?
此时 cpu的晶振使用 DCO,而uart的晶振使用 LFXT1(9600)吗?
void main(void)
{
unsigned int i,n;
WDTCTL = WDTPW + WDTHOLD; // 停止看门狗
uart0Init();
P5DIR |= 0x01; // 设P5.0为输出口

// BCSCTL1= 0x80; //分频电阻选择为0(此时闪烁频率较慢)
// BCSCTL1= 0x87; //分频电阻选择为7(此时闪烁频率较快)

// BCSCTL2= 0xc0; //选择外部32768低频晶振作为MCLK(此时闪烁频率极慢)
// BCSCTL2= 0x10; //选择外部8M高频晶振作为MCLK(此时闪烁频率较快)
n =0;
for (;;)
{

    i = 80000; // 循环
    do i--; while (i);
    P5OUT = 0x00; // 通过异或取反P5.0
    i = 50000; // 循环
    do i--; while (i);
    P5OUT = 0x01; // 通过异或取反P5.0
   uart0tx(n);
   n++;
   if(n>9)
   {
       n = 0;
   }
}
}
//////////////
void uart0Init(void)
{
UCTL0=SWRST;          //Ready for configurating serial's parameters
//UCTL0 |=CHAR;//+LISTEN;//Data frame format(8-N-1) with listen
UTCTL0=SSEL0+URXSE;   //Selection of SMCLK becomes baud ratio clock,edge of starting singal available
//URCTL0=URXEIE;      //Wrong message interrupt of reception enable
UBR10=0x00;            //Baud ratio adjustiing
UBR00=0x03;             //115200 @ 7.3728MHz External Oscillator
UMCTL0=0x4A;
UCTL0 &=~SWRST;//Functions of serial port enable
UCTL0 |=CHAR;//+LISTEN;//Data frame format(8-N-1) with listen
U0ME=URXE0+UTXE0; //Functions of reception and transmitter enable
//UCTL0 &=~SWRST;//Functions of serial port enable
U0IE=URXIE0;//+UTXIE0;   //Enable interrupt of reception
P3SEL |=0x30;    //P3.5(URXD0),P3.4(UTXD0)
P3OUT &=0xDF;    //Setting P3.5 input
P3OUT |=0x10;    //Setting p3.4 output
P3DIR |=0x10;    //Setting P3.4 direction to output

//tx0flg=1;
//rx0flg=0;
//_BIS_SR(LPM0_bits + GIE);               // Enter LPM0 w/ interrupt

//_EINT(); // 整个系统使能中断(开总中断)
//LPM1; // 进入LPM1模式


}

voiduart0tx(unsigned int i)
{
//unsigned int i;
/*
//while(!(UTCTL0 & TXEPT));
if(!(UTCTL0 & TXEPT))
{}
else
{if(uart0sendb)
   { uart0sendb=0;
   TXBUF0=rxbuf0;
   if(countt==10) countt=0;
   }
}
*/
//for(i=0;i<10;i++)
TXBUF0=txbuf;
}

songshanxiaozi 发表于 2011-5-23 10:51:04

显然使用了内部的DCO,默认的MCLK时钟源是DCO,SMCLK也是,其它的外设可以从SMCLK分频得到

german010 发表于 2011-5-23 19:53:11

tosongshanxiaozi 宁宁,
如果是这样则
UBR10=0x00;            
UBR00=0x03;            
的设置就 不对了,此处是按32.768kHz,频率和 9600波特率 的计算 来 设置UBR10和UBR00的?
如果uart用的dco,其频率为1点几 MHz吧,9600波特率 时候 UBR10 , UBR00的设置应该 改成别的
///////////////////
void uart0Init(void)
{
UCTL0=SWRST;          //Ready for configurating serial's parameters
//UCTL0 |=CHAR;//+LISTEN;//Data frame format(8-N-1) with listen
UTCTL0=SSEL0+URXSE;   //Selection of SMCLK becomes baud ratio clock,edge of starting singal available
此处应该是选择了 ACLK作为uart的 时钟吧

german010 发表于 2011-5-29 22:36:27

大家 看看 我想的对吗?
没人知道吗?
页: [1]
查看完整版本: 此时 msp430系统 的时钟系统 是 怎么选择的呢?