Hi there. I'm using a MSP430F149 in my graduation project and I'd like to ask some questions about the UART and clock generation. The project and the problem: I'm trying to develop an IrDA compliant communication board using the MSP uC. I'm using the TI IrDA Encoder/Decoder TIR1000 and a Vishay Telefunken TFDU4100 transceiver. The TIR1000 is connected to the MSP UART1. Transmission is OK but reception is buggy. I believe the cause is lack of synchronism between the UART and the TIR1000 because the TIR needs a input clock signal 16x the baud rate (pin 16XCLK). How can I generate this clock signal? My Clock configuration: I have a 8Mhz crystal and a 32768 Hz watch crystal and my clock configuration follows: // MCLK is 8 MHz (from XT2) // SMCLK is 8 MHz (from XT2) // ACLK is 32 kHz (from XT1) I don't use SMCLK and ACLK to anything so I can change the clock source to any other configuration. My UART configuration: I just want a 9600 connection. Here is my code for UART config (in C): // No parity, one stop bit, 8 bit data length, UART mode U1CTL = CHAR; U1TCTL = SSEL1; // UCLK = SMCLK U1BR0 = 0x41; // 8Mhz / 9600 = ~833.33 = 0341h U1BR1 = 0x03; UMCTL1 = 0x21; // Modulation .33 = 21h ME2 |= UTXE1 + URXE1; // Enable USART1 TXD/RXD IE2 |= UTXIE1 + URXIE1; // Enable USART1 TX/RX interrupt The Question: For a 9600 speed the 16XCLK pin should receive a 153.6kHz clock signal. I tried to use Timer_A P1.2/TA1 but no good. Here's the question: Is there a way to use the SMCLK (8MHz) to generate a exact 153.6kHz clock? If no, can I source the SMCLK from the DCO, calibrate it to 153.6k and put it through pin P1.2? If yes, how (I'm not familiar with DCO)? Can someone share some C code that does the trick? Any other suggestions? Note: I'm using a 3.6V suply so the clock system is really running at ~8MHz. Any help will be greatly apreciated. Thanks for your attention, Eduardo Zambon. ______________________________________________________________________
MSP UART and TIR1000
Started by ●March 27, 2004
Reply by ●March 28, 20042004-03-28
Hi Eduardo Keep in mind that the DCO can vary in frequency with changing temperatures. If you want to eliminate that, use an external Rosc. A 100K value to Vcc will make the default value about 2MHz (plus or minus a couple percent), and it won't be temperature dependent. You can adjust from there to get your 8 Mhz. You can calibrate the 8MHz by using the 32KHz clock. You just count the number of SMCLK pulses inside one or more 32KHz periods and adjust the DCO bits accordingly. Since you're using an external Rosc, you only need to do this at power-up, and can reuse the timers for other functions. For your external 153.6 clock, you can take your 8MHz into one of the timers (via SMCLK) and divide it, and put it out on one of the timer outputs. For example, if you have 8 mHz going into TimerA, then set one of the timer channels to count to 8,000,000/153,600/2 26. Everytime you get a interrupt, you flip the signal and add 26 so that it looks for the next interrupt. Since it's not an exact multiple of 8MHz, you have to handle the rollover also. Or if you have a completely empty timer, just have it roll over at 26 and use that. Good job setting Vcc to 3.6V. Many users overlook that. TI will also be releasing an IrDA appnote in the next couple of months with a full IrDA stack. I think it's being written for the 'F169. Might be a little late for you though... Send me an e-mail offline and we can discuss. Mike. --- In msp430@msp4..., Eduardo Zambon <zambon_e@y...> wrote: > Hi there. > > I'm using a MSP430F149 in my graduation project and > I'd like to ask some questions about the UART and > clock generation. > > The project and the problem: > > I'm trying to develop an IrDA compliant communication > board using the MSP uC. > I'm using the TI IrDA Encoder/Decoder TIR1000 and a > Vishay Telefunken TFDU4100 transceiver. The TIR1000 is > connected to the MSP UART1. Transmission is OK but > reception is buggy. I believe the cause is lack of > synchronism between the UART and the TIR1000 because > the TIR needs a input clock signal 16x the baud rate > (pin 16XCLK). How can I generate this clock signal? > > My Clock configuration: > > I have a 8Mhz crystal and a 32768 Hz watch crystal and > my clock configuration follows: > // MCLK is 8 MHz (from XT2) > // SMCLK is 8 MHz (from XT2) > // ACLK is 32 kHz (from XT1) > I don't use SMCLK and ACLK to anything so I can change > the clock source to any other configuration. > > My UART configuration: > > I just want a 9600 connection. Here is my code for > UART config (in C): > > // No parity, one stop bit, 8 bit data length, UART > mode > U1CTL = CHAR; > U1TCTL = SSEL1; // UCLK = SMCLK > U1BR0 = 0x41; // 8Mhz / 9600 = ~833.33 = 0341h > U1BR1 = 0x03; > UMCTL1 = 0x21; // Modulation .33 = 21h > ME2 |= UTXE1 + URXE1; // Enable USART1 TXD/RXD > IE2 |= UTXIE1 + URXIE1; // Enable USART1 TX/RX > interrupt > > The Question: > > For a 9600 speed the 16XCLK pin should receive a > 153.6kHz clock signal. > I tried to use Timer_A P1.2/TA1 but no good. Here's > the question: Is there a way to use the SMCLK (8MHz) > to generate a exact 153.6kHz clock? If no, can I > source the SMCLK from the DCO, calibrate it to 153.6k > and put it through pin P1.2? If yes, how (I'm not > familiar with DCO)? Can someone share some C code that > does the trick? > > Any other suggestions? > > Note: I'm using a 3.6V suply so the clock system is > really running at ~8MHz. > > Any help will be greatly apreciated. > > Thanks for your attention, > Eduardo Zambon. > > _____________________________________________________________________ _ > >