Question 1: The customer is using the MSP430FR6043 ultrasonic gas meter solution. The customer is testing the 6000V electrostatic discharge test and finds that the external 32.768K clock output is normal and the serial port baud rate from the external clock source is abnormal. The crystal oscillator test pin is directly tested and the 32.768Khz waveform is found. correct. MSP430FR6043 returns to normal after reset. This problem almost has a high recurrence rate. The customer initialization code attachment and the hardware circuit diagram are consistent with the TI ultrasonic Demo board.
The following is the 32.768K clock initialization
----------------------------------------------------------------------
void CS_initClockSignal(uint8_t selectedClockSignal,
uint16_t clockSource,
uint16_t clockSourceDivider)
{
//Verify User has selected a valid Frequency divider
assert(
(CS_CLOCK_DIVIDER_1 == clockSourceDivider) ||
(CS_CLOCK_DIVIDER_2 == clockSourceDivider) ||
(CS_CLOCK_DIVIDER_4 == clockSourceDivider) ||
(CS_CLOCK_DIVIDER_8 == clockSourceDivider) ||
(CS_CLOCK_DIVIDER_16 == clockSourceDivider) ||
(CS_CLOCK_DIVIDER_32 == clockSourceDivider)
);
//Unlock CS control register
HWREG16(CS_BASE + OFS_CSCTL0) = CSKEY;
uint16_t temp = HWREG16(CS_BASE + OFS_CSCTL3);
switch(selectedClockSignal)
{
case CS_ACLK:
assert(
(CS_LFXTCLK_SELECT == clockSource) ||
(CS_VLOCLK_SELECT == clockSource) ||
(CS_LFMODOSC_SELECT == clockSource)
);
clockSourceDivider = clockSourceDivider << 8;
clockSource = clockSource << 8;
HWREG16(CS_BASE + OFS_CSCTL2) &= ~(SELA_7);
HWREG16(CS_BASE + OFS_CSCTL2) |= (clockSource);
HWREG16(CS_BASE + OFS_CSCTL3) = temp & ~(DIVA0 + DIVA1 + DIVA2) |
clockSourceDivider;
break;
case CS_SMCLK:
assert(
(CS_LFXTCLK_SELECT == clockSource) ||
(CS_VLOCLK_SELECT == clockSource) ||
(CS_DCOCLK_SELECT == clockSource) ||
(CS_HFXTCLK_SELECT == clockSource) ||
(CS_LFMODOSC_SELECT == clockSource)||
(CS_MODOSC_SELECT == clockSource)
);
clockSource = clockSource << 4;
clockSourceDivider = clockSourceDivider << 4;
HWREG16(CS_BASE + OFS_CSCTL2) &= ~(SELS_7);
HWREG16(CS_BASE + OFS_CSCTL2) |= clockSource;
HWREG16(CS_BASE + OFS_CSCTL3) = temp & ~(DIVS0 + DIVS1 + DIVS2) |
clockSourceDivider;
break;
case CS_MCLK:
---------------------------------------------------------------
The following is the program for serial port initialization
--------------------------------------------------------------
void hal_uart_Init(void)
{
/*
* Select Port 1
* Set Pin 2, 3 to input Primary Module Function or PySEL1,0 = [01],
* (UCA1TXD/UCA1SIMO, UCA1RXD/UCA1SOMI).
*/
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P1,
GPIO_PIN2 + GPIO_PIN3,
GPIO_PRIMARY_MODULE_FUNCTION
);
// Configure UART
EUSCI_A_UART_initParam param = {0};
param.parity = EUSCI_A_UART_NO_PARITY;//EUSCI_A_UART_NO_PARITY;
param.msborLsbFirst = EUSCI_A_UART_LSB_FIRST;
param.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT;
param.uartMode = EUSCI_A_UART_MODE;
#if ((HAL_SYS_SMCLK_FREQ_HZ ==8000000) && (HAL_UART_BAUDRATE == 57600))
param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK;
param.clockPrescalar = 8; // 8000000/16/57600 = 8.68
param.firstModReg = 10; // UCOS16=1, BRFx = 10, BRSx = 0xF7
param.secondModReg = 0xF7;
param.overSampling = EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION;
#elif ((HAL_SYS_SMCLK_FREQ_HZ==8000000) && (HAL_UART_BAUDRATE == 115200))
param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK;
param.clockPrescalar = 4; // 8000000/16/115200 = 4.34
param.firstModReg = 5; // UCOS16=1, BRFx = 5, BRSx = 0x55
param.secondModReg = 0x55;
param.overSampling = EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION;
#elif ((HAL_SYS_SMCLK_FREQ_HZ==8000000) && (HAL_UART_BAUDRATE == 19200))
param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK;
param.clockPrescalar = 26; // 8000000/16/19200 = 26.0416
param.firstModReg = 0; // UCOS16=1, BRFx = 0, BRSx = 0xD6
param.secondModReg = 0xD6;
param.overSampling = EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION;
#elif ((HAL_UART_BAUDRATE == 9600) && (HAL_SYS_ACLK_FREQ_HZ==32768))
param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_ACLK;
param.clockPrescalar = 3; // 32768/9600 = 3.41
param.firstModReg = 0; // UCOS16=0 BRFx = 0,
-------------------------------------------------------------------
Question 2: The ultrasonic measurement of MSP430FR6043 currently uses an external 8M measurement crystal oscillator. Can the internal crystal oscillator be used for ultrasonic measurement?