[msp430] problems setting 8MHz CPU frequency

Hi,

I'm trying to clock the CPU (MSP430F1611) to 8,000,000 Hz and I've run into some problems. Making the CPU to actually run at 8MHz was easy enough:

DCOCTL = DCO0 + DCO1 + DCO2; /* 0xE0 */ BCSCTL1 = XT2OFF + RSEL0 + RSEL1 + RSEL2; /* 0x87 */

However, the UART1 stopped working. What I've got so far is:

void uart1_init( unsigned int ubr ) { /* RS232 */ P3DIR &= ~0x80; /* Select P37 for input (UART1RX) */ P3DIR |= 0x40; /* Select P36 for output (UART1TX) */ P3SEL |= 0xC0; /* Select P36,P37 for UART1{TX,RX} */

UCTL1 = SWRST | CHAR; /* 8-bit character, UART mode */

U1RCTL &= ~URXEIE; /* even erroneous characters trigger interrupts */

UTCTL1 = SSEL1; /* UCLK = MCLK */

/* ubr is 8000000/baud */ UBR01 = ubr; /* assuming 19200 bps: UBR01 = 0xA0; */ UBR11 = ubr >> 8; /* assuming 19200 bps: UBR11 = 0x01; */

/* UMCTL1 calculated using

formatting link

*/ UMCTL = 0x5B; /* assuming 19200 bps */

ME2 &= ~USPIE1; /* USART1 SPI module disable */ ME2 |= ( UTXE1 | URXE1 ); /* Enable USART1 TXD/RXD */

UCTL1 &= ~SWRST;

IE2 |= URXIE1; /* Enable USART1 RX interrupt */ }

What am I missing here? Any help appreciated!

-- Oskar

Reply to
Oskar
Loading thread data ...

Speaking generally rather than about your specific chip:

Try writing a loop to send a character on the serial endlessly, and then looking at the serial output timing on a scope.

You could also look at the timing values that worked at the old clock rate and proportionally correct for the new one, but someones the dividers get interesting (programmed value + 1 for example) such that it won't quite be a linear ratio.

There's always reading the manual, but sometimes the value of the other approaches is catching misunderstandings of what the manual was trying to say.

Reply to
cs_posting

'U' is a good value to send (alternating 1s and 0s).

Leon

Reply to
Leon

Un bel giorno Oskar digitò:

The safe operating frequency of the MSP430 depends on the supply voltage; in order to run it safely at 8 MHz you need to apply the maximum specified voltage, i.e. 3.6 V. Maybe you are using a lower supply voltage?

--
emboliaschizoide.splinder.com
Reply to
dalai lamah

I don't have a scope available at the moment, I will have to match a set of characters and try different register settings using some automation technique.

Now, what registers are actually frequency dependant besides UBR01, UBR11, and UMCTL1?

Reply to
Oskar

Too bad 19200 Hz is probably beyond the range of hearing, otherwise I'd suggest audibly comparing the bit clock (use the 'U' suggestion) to a PC endlessly sending the same thing.

Maybe wire up a divider IC to knock down the frequency?

(Yeah, I realize this may not be the best course of action... but it would be FUN!)

Reply to
cs_posting

Err.. Reversals at 19200 baud gives 9600 Hz. But talking of using a PC one could record the signal with a program such as CoolEdit and use the FFT function to check the frequency. Rocky

Reply to
Rocky

If you send 0xF0, there will be five "0"-bits (start bit+4 data bits) and five "1" bits (4 data bits+stop bit) in 8N1 format, so you have a

1920 Hz square wave.

Paul

Reply to
Paul Keinanen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.