void msp430_set_cpu_speed(uint32_t speed) { dint(); __msp430_cpu_speed = speed; msp430_init_dco(); uint16_t br; U0CTL = SWRST; U0CTL = SWRST | CHAR; // 8-bit character U0TCTL = SSEL1 | TXEPT; // UCLK = SCLK U0RCTL = 0; // activate ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD br = (uint16_t)((__msp430_cpu_speed & 0xFFFFF0) / 115200uL); UBR00 = br; // set baudrate UBR10 = br>>8; UMCTL0 = calc_umctl(br); // set modulation U0CTL &= ~SWRST; //URCTL0 |= URXEIE; // allow chars to interrupt IE1 |= URXIE0; // enable rx interrupt IFG1 &= ~UTXIFG0; eint(); }
void msp430_set_cpu_speed(uint32_t speed) { dint(); __msp430_cpu_speed = speed; msp430_init_dco(); uint16_t br; UCTL1 = SWRST | CHAR; // 8-bit character UTCTL1 |= SSEL1 | URXSE; // UCLK = MCLK // activate U1ME |= UTXE1 | URXE1; // Enable USART1 TXD/RXD br = (uint16_t)(__msp430_cpu_speed / 115200uL); UBR01 = br; // set baudrate UBR11 = br>>8; UMCTL1 = calc_umctl(br); // set modulation UCTL1 &= ~SWRST; //clock_init(); eint(); }