Other Parts Discussed in Thread: MSP430G2553
Hi,
I'm trying to implement a 1 MHz frequency on the DCO in order in implement UART using the Argenox tutorial (I've attached their code at the bottom). But they use a MSP430G2 microcontroller. After looking in the msp430fr2311.h file and data sheet, I see that it doesn't have the DCOCTL register. I've found in the data sheet that in order to have a DCO of 1 MHz the following can be set:
After looking up a few of these in the header file, I have found that they are in the CSCTL1 register.
My question is how to set the CSCTL1 register in order to have a 1 MHz frequency. I couldn't find a layout of the register in the data sheet, and couldn't figure out which bit corresponds to what.
Argenox Code:
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
/* Use Calibration values for 1MHz Clock DCO*/
DCOCTL = 0;
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
/* Configure Pin Muxing P1.1 RXD and P1.2 TXD */
P1SEL = BIT1 | BIT2 ;
P1SEL2 = BIT1 | BIT2;
/* Place UCA0 in Reset to be configured */
UCA0CTL1 = UCSWRST;
/* Configure */
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
/* Take UCA0 out of reset */
UCA0CTL1 &= ~UCSWRST;
/* Enable USCI_A0 RX interrupt */
IE2 |= UCA0RXIE;
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}
/* Echo back RXed character, confirm TX buffer is ready first */
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; // TX -&gt; RXed character
}
Any help would be great! Thanks.
