I am trying to learn about UART communication with my MSP430FR6989 microcontroller from TI (link), and that is a link for the User Guide (link)
The idea of my mini project is to connect the MSP430 uart_tx_pin
to its uart_rx_pin
, and enable the UART Transmit ISR
. When a value is written into the Transmit Buffer, a uart_tx_ifg
will be set and a UART ISR
will be serviced. The Baud rate will be 9600.
In order to change the system's clock, we need to write a password (
0xA500
) at registerCSCTL0
(pg 104/1021 section 3.3.1 of the UG)In order to write into the UART Control Registers, we need to set
UCASWRST
bit at theUCA0CTLW0
control register, and to clear theUCASWRST
bit after we finished writing in order to enable the UART.
(pg 767/1021 section 30.3.1 of the UG)
This is a snippet of my code:
int main (void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
P1DIR |= BIT5;
P1OUT = 0x00;
select_clock_signals ();//configures clock
assign_pins_to_uart ();//assigns GPIO pins to uart tx and rx
config_9600_uart ();//config uart baud rate for 9600
init_uart_isr ();//enable UART TX ISR
_BIS_SR(GIE);//enable Global ISR
UCA0TXBUF = 0xFA;//when value is written service the ISR
while(1);
return 0;
}
EDIT1
Here is the code for select_clock_signals()
void select_clock_signals (void)
{
//DCO 8Mhz select SMCLK
CSCTL0 = CSKEY;//0xA500
CSCTL1 |= (DCORSEL | DCOFSEL_3);//DCO 8Mhz 0x0046
CSCTL2 |= (SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK);//ACLK -> VLO SMCLK,MCLK -> DCO 0x0133
CSCTL3 = 0x0000;
}
end of EDIT1
I build it and there were no issues and started debugging it with my IDE (CCS v9.2).
Stepping into the instructions inside the main function and enter the select_clock_signals () function was not an issue, when I leave the function I got this error.
I tried:
- Writing a simple light the LED program in a new project, and I didn't get the error
- rearrange the code so the
assign_pins_to_uart()
will be called before theselect_clock_signals()
, and I get the error when the debugger leaves the clock signal function.
EDIT2
I tried debugging my code, and at CSCTL2 = 0x0046;
the value of the register automatically changes to CSCTL2 = 0x004E;
. so when DCORSEL = 1, FSEL automatically becomes 7.
I don't understand why that happens, as in the UG and the Datasheet they don't mention anything about the value of CSCTL2 being changed by the MSP430.
(datasheet pg 44/183)
(user guide pg 104/1021)
end of EDIT2
Kindly assist me with this issue, your help would be appreciated.
select_clock_signals ()
? \$\endgroup\$