Helio,
 
This bit of initialization code has been implemented and works provided
you have a crystal properly connected to the device.  One obvious
deficiency of this code is that if the external HF oscillator never
starts the code will hang waiting for it.  I believe this was discussed
in a previous post and improvements could be made to correct.
 
Brian Ott 
 
 
/*********************************************************************************
    unsigned int i;

    WDTCTL = WDTPW + WDTHOLD;             // Stop WDT
 
    BCSCTL1 |= XTS;                                      // ACLK =
LFXT1 = HF XTAL  (0x40)

    do 
    {
           IFG1 &= ~OFIFG;                           // Clear OSCFault
flag
           for (i = 0xFF; i > 0; i--);                 // Time for flag
to set
    }  
    while ((IFG1 & OFIFG) == OFIFG);      // OSCFault flag still set?  
             
 
    BCSCTL2 |= SELM1+SELM0;               // MCLK = LFXT1
(safe)(0x40+0x80=0xC0)
    UCTL0 = CHAR;                                  // 8-bit character
    UTCTL0 = SSEL0;                               // UCLK = ACLK
    UBR00 = 0x74;                                  // 3.58Mhz/9600 -
372
    UBR10 = 0x01;                                  //
    UMCTL0 = 0x00;                                // no modulation
    ME1 |= UTXE0 + URXE0;                  // Enable USART0 TXD/RXD
    IE1 |= URXIE0;                                 // Enable USART0 RX
interrupt
    P3SEL |= 0x30;                                // P3.4,5 = USART0
TXD/RXD
    P3DIR |= 0x10;                                // P3.4 output
direction
    _EINT();                              // Enable interrupts
 
 
/*********************************************************************************

/*********************************************************************************







Reply via email to