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.

Compiler/MSP430I2020: IAR

Part Number: MSP430I2020

Tool/software: TI C/C++ Compiler

I want to set the MSP430I2020 into the lowest power state, However, i still want to receive the uart signal when this lowest power state. My baud rate is set as 19200 bps. What can i do? Set which mode LPMX? Can use LPM4.5? How min. current i can get?

  • Hi,

    with a requested baud rate of 19200 you need a high frequency clock running. Please compare table 10-5 of the User's Guide

    In that case you need to run from SMCLK which is active in LPM0/1.

    To run in the lower power mode, you need to decrease the baud rate to at least 9600. Then you can use the ACLK=32768Hz and run in LPM3 @ 210uA.

    Best regards,

    Andre

  • I find that when I have set to LPM4, it can detect the interrupt. However, why I immediately to wake up (AM). The MCU cannot catch the data! I think it should miss the 1st byte, but it will miss at least 4 bytes

    Best regards,

    Mr. Hung

  • Mr. Hung,

    what is your configuration of the USCI module? Which clock do you use? The module cannot work in LPM4 as all clocks are disabled. Please check chapter 6.5 of the data sheet.

    What is possibly happening is, that you try to enable LPM4, but as you configure e.g. SMCLK it does not enter LPM4 because SMCLK is still requested. 

    Please have a look into our code examples on how to configure the UART module with : MSP430i20xx Code Examples (Rev. F) There you can find the example msp430i20xx_euscia0_uart_01

    Best regards,

    Andre

  • All,

    you also can use the AutoWake Up feature which activate the selected clock on request e.g. if a receive is detected.
    However you have to consider the corresponding wake-up times of the selected clock source. This can be checked in the wake-up characteristics of the device specific datasheet.



    Normally we recommend in such use cases to configure the RX pin as GPIO wake-up via port interrupt to ensure clocks are started and the reconfigure to UART and receive data. Alternatively your sender can send dummy data to ensure the wake-up time is achieved. And your receiver rejects data until certain data verify the correct start of information.

  • I have try to send several byte data, by the wake-up characteristics, it should be wake up to get my data in the 2nd byte since after interrupt, I have change to AM mode (i.e. : 1 byte time = 1/19200 x 10 bit = 520us). However, the result is I miss many bytes. Can any setting to flush the buffer, reset the control flag or error flag?  Thanks!

    Best regards,

    Hung

  • Hung,

    do you have the chance to trace the RX pin together with a GPIO showing you the interrupt is executed in combinaiton with the SMCLK?

    Sure you have no other clock dividers set?

    Do you see a dfference when you use LPM3 instead of LPM4?

  • I have try use GPIO to interrupt, also can't receive for the 1st package in LPM3.

    LPM3 can receive all (no need GPIO interrupt) , but LPM4 can't
  • rewrite: "I have try use GPIO to interrupt, also can't receive for the 1st package in LPM4".
  • Hung,
    that's strange! So you say you wake up with GPIO interrupt going to Active Mode and then you start communication and do not receive bytes correclty.

    Again do you have the chance to trace the trigger GPIO, RX, SMCLK and maybe a GPIO triggered by your code to signalize the device is awake?
    This would help if the timing we assume should appear is true.
    If possible you also can post your code to get an idea what's wrong.
  • Hi Andre,

    Yes, If I send a seq. of bytes, it cannot catch until I send another package. (after GPIO interrupt , I will change to AM mode and wait for 3 sec. to sleep

    Secondly, I have check the GPIO can interrupt for every byte.

    Best regards,

    Hung

    uart_flow.txt
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    //------------------------------
    // Main loop:
    //------------------------------
    while(uc_wait_sleep_cnt==0)
    {
    //LPM3;
    chg_uartrx_to_io_pin();
    uc_action |=F_Action_Sleep;
    LPM4;
    asm("nop");
    uc_action &= ~F_Action_Sleep;
    uc_wait_sleep_cnt = C_Wait_Slp_Time; // go into the main loop
    }
    //------------------------------
    // UART
    //------------------------------
    void uart_init(void) {
    // Configuration for 115200 UART with SMCLK at 16384000
    // These values were generated using the online tool available at:
    // http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSP430BaudRateConverter/index.html
    EUSCI_A_UART_initParam uartConfig = {
    EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
    19, // BRDIV //25,
    14, // UCxBRF = 14
    34, // UCxBRS = 34
    EUSCI_A_UART_EVEN_PARITY, // 1 even Parity
    EUSCI_A_UART_LSB_FIRST, // MSB First
    EUSCI_A_UART_ONE_STOP_BIT, // One stop bit
    EUSCI_A_UART_MODE, // UART mode
    EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION // Oversampling Baudrate
    };
    /*
    EUSCI_A_UART_initParam uartConfig = {
    EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
    8, // BRDIV = 8
    14, // UCxBRF = 14
    34, // UCxBRS = 34
    EUSCI_A_UART_NO_PARITY, // No Parity
    EUSCI_A_UART_MSB_FIRST, // MSB First
    EUSCI_A_UART_ONE_STOP_BIT, // One stop bit
    EUSCI_A_UART_MODE, // UART mode
    EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION // Oversampling Baudrate
    };
    */
    //WDT_hold(WDT_BASE);
    // Setting the DCO to use the internal resistor. DCO will be at 16.384MHz
    // CS_setupDCO(CS_INTERNAL_RESISTOR);
    // SMCLK should be same speed as DCO. SMCLK = 16.384MHz
    //CS_initClockSignal(CS_SMCLK, CS_CLOCK_DIVIDER_1);
    // use when it is IO
    GPIO_setAsInputPin(PORT_UART, P_UART_RX_Pin);
    GPIO_selectInterruptEdge(PORT_UART, P_UART_RX_Pin, GPIO_HIGH_TO_LOW_TRANSITION);
    GPIO_clearInterrupt(PORT_UART, P_UART_RX_Pin);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Hung,

    thanks for the code! Can you please follow the recommended initialization in way to change the GPIO to UART function according the sequence below and try again?

  • Thanks Dietmar,

    it seem better now:

    void chg_io_to_uartrx_pin(void)
    {
    GPIO_disableInterrupt(PORT_UART, P_UART_RX_Pin);
    UCA0CTL1 |= UCSWRST; // Hold eUSCI in reset
    GPIO_setAsPeripheralModuleFunctionInputPin(PORT_UART,P_UART_TX_Pin | P_UART_RX_Pin,GPIO_PRIMARY_MODULE_FUNCTION);
    // Configure and enable the UART peripheral
    EUSCI_A_UART_init(EUSCI_A0_BASE, &uartConfig);
    EUSCI_A_UART_enable(EUSCI_A0_BASE);

    UCA0CTL1 &= ~UCSWRST; // Release from reset
    EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE,(EUSCI_A_UART_RECEIVE_INTERRUPT));

    }

    void chg_uartrx_to_io_pin(void)
    {
    UCA0CTL1 |= UCSWRST; // Hold eUSCI in reset
    P1SEL0 &= ~(P_UART_RX);
    P1SEL1 &= ~(P_UART_RX);
    UCA0CTL1 &= ~UCSWRST; // Release from reset
    GPIO_clearInterrupt(PORT_UART, P_UART_RX_Pin);
    GPIO_enableInterrupt(PORT_UART, P_UART_RX_Pin);
    }


    However , the starter byte something can work , something can't. For example, '0x00' is ok , but '0xC0' cannot

    Best regards,
    Hung
  • Hung,

    you mean that the 1st byte sometimes is received correct and sometimes not?
    Normally if you wake-up and start the receive in AM it should work. Again a scope shot of RXDATA and clock woudl help significantly here to see with which edge which bit is read.

    Best regards,
    Dietmar
  • Dietmar,

    I try to send a dummy data to my package. However, the dummy data need some requirement.
    When 00 is dummy, after 00 can be received.
    When use F0 is dummy, after F0 cannot be received. Why?

    Best regards,
    Hung
  • Hung,

    it is recommended to check the SMLK during RX pin operation to see that there are not clock related fails which might cause this.
    Hope you have a possibiliy to trace this.
    By the way what device you're using as a sender? Your also sure that sender and receiver have same baudrate and the accuracy requirements from both sites are met.

    Best regards,
    Dietmar
  • Hung,

    pls ensure you apply following procedure:

    1. Disable the UART function and then configure the i2020 UCA0RXD to Port Interrupt function before running into LPM4

    2. Trigger the i2020Port Interrupt by an Port Interrupt Event on UCA0RXD to wake up MCU

    3. In the Port ISR

    t1: Configure MCU to AM mode to make sure the clock is activated

    t2: Set MCU to run into LPM0 mode when exist the Port ISR, then enable the UART to change UCA0RXD function for the first effective byte

    Note: a. Make sure the UCA0RXD keeps the state between the Port Interrupt Event and ST of the First Effective Byte

             b. Make sure the Port ISR is complete before the ST(Start Flag) of the First Effective Byte

  • Is it possible keep the MCU run in LPM45 mode and receive successful the data package?

    Best regards,

    Hung

  • Hung,

    in LPM4.5 UART communication is not possible because the core domain is powered down. If you want to use LPM4.5 you need to wake-up over Port interrupt or RESET and consider the typical wake-up time of 0.45 ms before UART communication can start. Besides this you need to configure the device properly as described in users guide.

  • Dear Dietmar Walther,

    Thank your advice. It is very for useful for all your advice!

    Mr. Hung

**Attention** This is a public forum