This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR6047: MSP430FR6047 UART POWER CONSUMPTION

Part Number: MSP430FR6047

1.I'm sending data from MSP430FR6047 through UART, i have measured 20mA power consumtion

2.When no data is transmitted throught UART, i have measured 0.4mA Power consumption

 I need to achive low power consumption when data is transmitted through UART, Give me a suggestion 

For reference i have attached my UART Code

#include <msp430.h>
#define ENABLE_PINS 0xFFFE

void UART_init(void);
void UART_sendData(unsigned char data);
char UART_receiveData(void);

int main(void) {
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
PM5CTL0 = ENABLE_PINS; // Prepare pins for I/O usage
PM5CTL0 &= ~LOCKLPM5;

P2SEL0 = 0x00;
P2SEL1 = 0x00;

P8SEL0 = BIT2 | BIT3; // Select P8.2 for UART RX and P8.3 for UART TX
P8SEL1 &= ~(BIT2 | BIT3);

UART_init(); // Initialize UART module

while (1)
{
char receivedChar = UART_receiveData(); // Receive character via UART
if (receivedChar != '\0') {
// Transmit received data to PuTTY
while (!(UCA3IFG & UCTXIFG)); // Wait until UART buffer is ready
UCA3TXBUF = receivedChar; // Transmit the received character
}

// Code for transmitting data (change or add your transmit data logic)
UART_sendData('H'); // Send the character 'H'
UART_sendData('e'); // Send the character 'e'
UART_sendData('l'); // Send the character 'l'
UART_sendData('l'); // Send the character 'l'
UART_sendData('o'); // Send the character 'o'
UART_sendData('\n');
__delay_cycles(1000000); // Delay for demonstration purposes
}

return 0;
}

void UART_init(void)
{
// Configure UART pins
UCA3CTLW0 |= UCSWRST; // Put UART module in reset state
UCA3CTLW0 |= UCSSEL__SMCLK; // Select SMCLK as clock source
UCA3BR0 = 104; // Set Baud rate to 9600 (adjust based on your setup)
UCA3MCTLW = 0x2000;
UCA3BR1 = 0;
UCA3CTLW0 &= ~UCSWRST; // Initialize UART module
}

void UART_sendData(unsigned char data)
{
while (!(UCA3IFG & UCTXIFG));
UCA3TXBUF = data; // Send data via UART
}

char UART_receiveData(void)
{
if (UCA3IFG & UCRXIFG) {
// __delay_cycles(1000000);
return UCA3RXBUF; // Return received data
} else {
return '\0'; // No data received
}
}

  • The high current while sending suggests a load on the serial out pin.

    For low power consumption, your send data code is lacking. It spends a lot of time just waiting for the TXIFG bit to be set. Use interrupts and a low power mode.

    Oh, I have no idea what you expect PM5CTL0 = ENABLE_PINS;  to do. There is exactly one meaningful bit in that register so this does exactly what the next line of code does.

  • Hi David,

    Sure, I will use the interrupt. 

    Could you please share data about current consumption for an UART on?

    BR.

  • It is in the data sheet. Section 8.11.

  • #include <msp430.h>

    int main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // Stop Watchdog

    // Configure GPIO
    P2SEL0 &= ~(BIT0 | BIT1);
    P2SEL1 |= BIT0 | BIT1; // USCI_A0 UART operation

    // Disable the GPIO power-on default high-impedance mode to activate
    // previously configured port settings
    PM5CTL0 &= ~LOCKLPM5;

    // Startup clock system with max DCO setting ~8MHz
    CSCTL0_H = CSKEY_H; // Unlock CS registers
    CSCTL1 = DCOFSEL_3 | DCORSEL; // Set DCO to 8MHz
    CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
    CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers
    CSCTL0_H = 0; // Lock CS registers

    // Configure USCI_A0 for UART mode
    UCA0CTLW0 = UCSWRST; // Put eUSCI in reset
    UCA0CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK
    // Baud Rate calculation
    // 8000000/(16*9600) = 52.083
    // Fractional portion = 0.083
    // User's Guide Table 24-4: UCBRSx = 0x04
    // UCBRFx = int ( (52.083-52)*16) = 1
    UCA0BRW = 52; // 8000000/16/9600
    UCA0MCTLW |= UCOS16 | UCBRF_1 | 0x4900;
    UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI
    UCA0IE |= UCTXIE; // Enable USCI_A0 TX interrupt

    while (1)
    {
    // Transmit "HELLO" through UART
    UCA0TXBUF = 'H';
    while (!(UCA0IFG & UCTXIFG));
    UCA0TXBUF = 'E';
    while (!(UCA0IFG & UCTXIFG));
    UCA0TXBUF = 'L';
    while (!(UCA0IFG & UCTXIFG));
    UCA0TXBUF = 'L';
    while (!(UCA0IFG & UCTXIFG));
    UCA0TXBUF = 'O';
    while (!(UCA0IFG & UCTXIFG));

    __delay_cycles(1000000); // Delay for demonstration purposes
    }
    }

    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=EUSCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(EUSCI_A0_VECTOR))) USCI_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    switch (__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))
    {
    case USCI_NONE: break;
    case USCI_UART_UCRXIFG:
    while (!(UCA0IFG & UCTXIFG));
    UCA0TXBUF = UCA0RXBUF;
    __no_operation();
    break;
    case USCI_UART_UCTXIFG: break;
    case USCI_UART_UCSTTIFG: break;
    case USCI_UART_UCTXCPTIFG: break;
    default: break;
    }
    }

    In this code i have reduced UART data transmission power consumption to 1.6mA. Can you give me some suggestion to reduce power consumption from this.

  • What kind of load is on the TX pin? 3300 ohms is enough to draw 1 mA of current at 3.3 V.

  • I have connected UART to usb converter

  • Try running it without the convertor attached.

  • Without converter 0.6mA measured

  • This program is spending almost all its time (spinning) in 

    __delay_cycles(1000000); // Delay for demonstration purposes

    i.e. it's always in Active Mode, for which 0.6mA is pretty good. To get further, you need to use Low Power Mode (LPM).

    In the simplest case, change that "__delay_cycles();" into "LPM0;" ( which is "__bis_SR_register(LPM0_bits)", but easier to type), which will pause the CPU until something happens. In your ISR, add "LPM0_EXIT;" ("__bic_SR_register_on_exit(LPM0_bits)") which will wake it up.

    You should also change "UCTXIE" to "UCRXIE", and add "__enable_interrupt();" somewhere before the while(1) loop.

    Based on your current code, the wakeup will happen when you type something into your terminal emulator. Doing it based on time will require more/different code, depending on what (long term) you want to do with this code. 

    TI Example msp430fr60x7_euscia0_uart_03.c illustrates:

    https://dev.ti.com/tirex/explore/node?node=A__AG6U47Gs2xP-4tSVJKT3eg__msp430ware__IOGqZri__LATEST

    [Edit: Fixed macro name]

  • You added an interrupt service routine which echoes received data. Nothing more. You still aren't using interrupts to transmit which means the CPU is active.

**Attention** This is a public forum