jazz 209 Posted September 28, 2012 Share Posted September 28, 2012 I was playing last days with MSP5xx UART, and every time after changing baud rate, need to calculate configuration again, and again, and again... I write small program for making configuration depending on clock and baud rate. After generation, just press mouse button on first/second listing (nothing will happen) and use [CTRL]+[C] for copy listing to clipboard. MSP430UartCalc.rar turd, jsolarski-backup, petus and 6 others 9 Quote Link to post Share on other sites
jazz 209 Posted September 28, 2012 Author Share Posted September 28, 2012 In MSP430F5xx USB Developers Package, example C7 (CDC) is USB/Uart bridge project. Don't understand why they (TI) made support for few baud rates (9600, 19200, 38400, 57600, 115200) and not for any possible baud rate (function USBCDC_handleSetLineCoding in usbEventHandling.c). 10 minutes job, 10 minutes. :roll: Quote Link to post Share on other sites
jazz 209 Posted October 8, 2012 Author Share Posted October 8, 2012 In MSP430F5xx USB Developers Package, example C7 (CDC), USB/Uart bridge will work only if uC is running by 20MHz. If any other frequency is defined (USB_MCLK_FREQ in descriptors.h file) it will not work, because uart in USBCDC_handleSetLineCoding function (usbEventHandling.c file) is configured only for 20 MHz. /* This event indicates that new line coding params have been received from the host */ BYTE USBCDC_handleSetLineCoding (BYTE intfNum, ULONG lBaudrate) { UCA0CTL1 |= UCSWRST; UCA0CTL1 = UCSSEL_2; // SMCLK //TO DO: You can place your code here switch (lBaudrate) { case 9600: UCA0BR0 = 0x23; // 20MHz 9600 (see User's Guide) UCA0BR1 = 0x8; // 20MHz 9600 break; case 19200: UCA0BR0 = 0x11; // 20MHz 9600 (see User's Guide) UCA0BR1 = 0x4; // 20MHz 9600 break; case 38400: UCA0BR0 = 0x08; // 20MHz 9600 (see User's Guide) UCA0BR1 = 0x2; // 20MHz 9600 break; case 57600: UCA0BR0 = 0x5B; // 20MHz 9600 (see User's Guide) UCA0BR1 = 0x1; // 20MHz 9600 break; case 115200: UCA0BR0 = 0xAD; // 20MHz 9600 (see User's Guide) UCA0BR1 = 0x0; // 20MHz 9600 break; default: break; } UCA0MCTL = UCBRS_3+UCBRF_0; // Modulation UCBRSx = 3 UCA0CTL1 &= ~UCSWRST; return (FALSE); // return FALSE to go asleep after interrupt // (in the case the CPU slept before interrupt) } I will re-write this function (soon, don't have IAR/CCS downloaded/installed on PC now) to support any baud rate (for example 123456 bps, 345678 bps...) on uC running by any clock frequency. Quote Link to post Share on other sites
oPossum 1,083 Posted October 8, 2012 Share Posted October 8, 2012 Code for USCI bit rate setup: USCI UART bit rate setting Quote Link to post Share on other sites
jazz 209 Posted October 8, 2012 Author Share Posted October 8, 2012 Code for USCI bit rate setup: USCI UART bit rate setting This is OK, but I am using (and in USB Developers Package is used) Low-Frequency Baud Rate Mode, not Oversampling Baud Rate Mode, and input baud rate is changing during program execution, it is not constant value. Quote Link to post Share on other sites
pabigot 355 Posted October 8, 2012 Share Posted October 8, 2012 As long as we're pointing out alternatives, the BSP430 peripheral modules have code to configure support for arbitrary baud rates on the USCI(2xx/4xx), USCI5(5xx/6xx), and eUSCI(FR5xx) boards. ACLK or SMCLK are selected based on the requested baud rate and the current speed of those clocks. The implementation might also be of value as a reference. Also note that though USCI and USCI5 are pretty close in interface, eUSCI is a new beast when it comes to configuring baud rates. Quote Link to post Share on other sites
D^2 24 Posted October 9, 2012 Share Posted October 9, 2012 There's also an online calculator that also provides oversampling config as well as error rates for each setting: Link[FIXED] jsolarski, zeke and bluehash 3 Quote Link to post Share on other sites
petus 11 Posted November 17, 2012 Share Posted November 17, 2012 Uart configurator is functional with ubuntu. Thanks Quote Link to post Share on other sites
jsolarski 94 Posted November 20, 2012 Share Posted November 20, 2012 Thanks, this will help a lot!! Quote Link to post Share on other sites
sean2102 0 Posted September 14, 2016 Share Posted September 14, 2016 Thanks, this helpes me. 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.