hello all,
i am having trouble setting baud rate 9600 using 1MHz DCO frequency. i am not using the internal calibrated DCO settings. I am getting interrupts from my computer, however, the value that i send is in-correct, moreover, I get UCRXERR, UCPE,UCOE bit errors, can anyone please suggest what i am doing wrong.? chip used : MSP430F2xxx. i am confident that computer sends correct character, as the setup works with 32,768 ACLK and 9600 baud. however, i would like to reduce the error%, hence increasing baud rate
code:
void main()
{
UART_Init();
while(1)
{}
}
void UART_Init()
{
P3SEL = ENABLE_UART_MODE; //enable the USCI_A0 mode
P3DIR = ASSIGN_UART_RX_TX; // P3.4 = o/p, P3.5 = i/p
Clock_1MHz(); // Change the clock to 1MHz
UCA0CTL1 |= UCSSEL_2; // CLK = SMCLK
UCA0CTL0 = UCPEN; // ODD Priority
UCA0BR0 = 112; // 1.078MHz/9600 = 112
UCA0BR1 = 0x00;
UCA0MCTL = UCBRS2; // Modulation UCBRSx = 2
//UCA0MCTL = 0X44;
//end of init of registers//
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
Recvd_Char[Buffer_Index] = UCA0RXBUF; // Take Data from RX Buffer
if(Recvd_Char[Buffer_Index] == 'Z') // check the end of data stream from computer
{
__bic_SR_register_on_exit(LPM0_bits);
}
else
Buffer_Index++;
}
void Clock_1MHz()
{
IE1 &= ~(OFIE); //Disable OSC fault interrupt
DCOCTL = DCO1;
BCSCTL1 = XT2OFF | RSEL2 | RSEL1 | RSEL0;
//BCSCTL1 = XT2OFF | 7;
BCSCTL2 = 0x00u; //MCLK=DCO; SMCLK = DCO
__delay_cycles(100);
IFG1 &= ~(OFIFG); //Clear the OSC flag
IE1 |= OFIE; //Enable OSC fault interrupt
}