Optronik 0 Posted April 2, 2015 Share Posted April 2, 2015 I am currently working on a project that is transferring data to a host computer via UART. Standard baud rate is 9600bps, UART is clocked with SMCLK 8MHz (using calibrated DCO values). I am not using the launchpad, the MSP430 is connected to the computer by a Prolific serial to USB converter. So far so good. To speed up the data transfer I implemented the feature to increase the baud rate by a command send from the computer. Target idea was to change from 9600 to 38400. It did not work, the MSP430 changed the baud rate but the PC could not identify the characters (I changed the baud rate on the PC as well). I changed the UART settings to 19200bps and it worked. Back to 38400, same problem. Double checking the settings revealed nothing. The suggested settings for 38400Bps are: UCA0BR0 = 0xD0 UCA0BR1 = 0x00 UCA0MCTL = 0x03 I then added some test code (see below) that looped the UART settings, varying the modulator value since this caused significant distortion at an other issue. It turned out that every time the modulator value has an even number 2, 4, 6, 8 the 38400 setting is working correctly. What can be the reason why the recommended modulator setting is not working? for (i=0; i<16; i++) { IE2 &= ~UCA0RXIE; IE2 &= ~UCA0TXIE; UCA0CTL1 |= UCSWRST; // UART state machine Reset UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 0xD0; //0xD0; // 8 MHz, 38400 Bps UCA0BR1 = 0x00; //0x00; // 8 MHz, 38400 Bps UCA0MCTL = i; //0x03; // 8 MHz, 38400 Bps UCA0CTL1 &= ~UCSWRST; // UART state machine IE2 |= UCA0RXIE + UCA0TXIE; tempChar=i+48; transmitByte_UART(tempChar); transmitBytes_UART ("\r\n", 2); } Quote Link to post Share on other sites
Optronik 0 Posted April 2, 2015 Author Share Posted April 2, 2015 Oh sh**!, I just realized that I used the value from the datasheet table directly. But the UCA0MCTL register is placing the value at an other position. UCA0MCTL: UCBRFx [7:4], UCBRSx [3:1], UCOS16 [0] Baud rate table: UCBRx = 208 = 0x00, 0xD0 UCBRSx = 3 = 0b011 UCBRFx = 0 UCA0MCTL: 0000,011,0 = 0x06 Quote Link to post Share on other sites
jazz 209 Posted April 3, 2015 Share Posted April 3, 2015 BTW, you can use calculator that will give you register setup values for any baud rate. http://forum.43oh.com/topic/2640-uart-configurator/ Quote Link to post Share on other sites
Optronik 0 Posted April 6, 2015 Author Share Posted April 6, 2015 Yes, this is what I did after I figured the problem out. There are other online calculators. They give you a numeric value that end up in the same problem I had. If one is as stupid as I was and using the value as a register content then it will not work reliably. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.