Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void SetUSART0Rate(uint8 BaudRate) {
   uint16 divisor;
   uint8 * div;
  
   UCA0CTL1 |= UCSWRST;
   
   
   divisor = 500000 / BaudRate;
   
   //   Superpose a uint8 pointer
   div = (uint8 *)(&divisor);
   UCA0BR0 = div[1];
   UCA0BR1 = div[0];
   //   Re-enable the module
   UCA0CTL1 &= ~UCSWRST;
}