Other Parts Discussed in Thread: MSP430FR6047
Hi
I'm currently using EUSCI_A1 for comms with PC, when I change to EUSCI_A3 the comms don't work,
All I've done is,(hal_uart.c and .h), change port base address and initialize the pins respectively, (P4.1 and P4.2), parameters remain the same.
hal_uart.h
/*! Define UART baudrate used by serial communication */ //#define HAL_UART_BAUDRATE (57600) #define HAL_UART_BAUDRATE (115200) /*! Define UART (eUSCI) base address */ //#define HAL_UART_BASE_ADDR (EUSCI_A1_BASE) #define HAL_UART_BASE_ADDR (EUSCI_A3_BASE)
hal_uart.c
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
);*/
/*
* Select Port 4
* Set Pin 1, 2 to input Primary Module Function or PySEL1,0 = [01],
* (UCA3TXD/UCA1SIMO, UCA3RXD/UCA1SOMI).
*/
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P4,
GPIO_PIN1 + GPIO_PIN2,
GPIO_PRIMARY_MODULE_FUNCTION
);
// Configure UART
EUSCI_A_UART_initParam param = {0};
param.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_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, BRSx = 0x92
param.secondModReg = 0x92;
param.overSampling = EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION;
#else
#error "UART Baudrate Configuration not supported "
#endif
if(STATUS_FAIL == EUSCI_A_UART_init(HAL_UART_BASE_ADDR, ¶m))
{
return;
}
EUSCI_A_UART_enable(HAL_UART_BASE_ADDR);
}
The pins for this port are used for the LCD, but I have disabled the function;
hal_lcd.h
#ifndef _MSP430FR6047_HAL_LCD_H_
#define _MSP430FR6047_HAL_LCD_H_
/*! Enables/disables the external resistor ladder */
#define LCD_USE_RES_LADDER
/*! Enables/disables the internal charge pump */
//#define LCD_USE_CHARGEPUMP
/*! Enables/disables the LCD */
//#define ENABLE_LCD
/*! Maximum number of digits in LCD */
#define HAL_LCD_DIGIT_MAX 6
/*! Size of LCD Memory map */
#define HAL_LCD_MEMMAP_SIZE 30
Thanks in advance.