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.
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?
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
//------------------------------ // 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); GPIO_disableInterrupt(PORT_UART, P_UART_RX_Pin); CS_initClockSignal(CS_SMCLK, CS_CLOCK_DIVIDER_2); // Settings P1.2 and P1.3 as UART pins. 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); EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE, (EUSCI_A_UART_RECEIVE_INTERRUPT)); // uc_RxBufoffset = 0; } void chg_io_to_uartrx_pin(void) { GPIO_disableInterrupt(PORT_UART, P_UART_RX_Pin); //uart_init(); P1SEL0 |= P_UART_RX; // P1.2/3 eUSCI_A Function P1SEL1 &= ~(P_UART_RX); //UCA0CTL1 |= UCSWRST; // Hold eUSCI in reset //UCA0CTL1 &= ~UCSWRST; // Release from reset } void chg_uartrx_to_io_pin(void) { P1SEL0 &= ~(P_UART_RX); P1SEL1 &= ~(P_UART_RX); GPIO_clearInterrupt(PORT_UART, P_UART_RX_Pin); GPIO_enableInterrupt(PORT_UART, P_UART_RX_Pin); } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=PORT1_VECTOR __interrupt #elif defined(__GNUC__) __attribute__((interrupt(PORT1_VECTOR))) #endif void PORT1_ISR(void) { if(uc_action & F_Action_Sleep) { LPM4_EXIT; chg_io_to_uartrx_pin(); uc_action &= ~F_Action_Sleep; } } void change_uart_to_io(void) { GPIO_setAsOutputPin(GPIO_PORT_P1,(P_UART_TX | P_UART_RX)); } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=USCI_A0_VECTOR __interrupt #elif defined(__GNUC__) __attribute__((interrupt(USCI_A0_VECTOR))) #endif void USCI_A0_ISR(void) { uchr uc_status, uc_data; if(uc_action & F_Action_Sleep) { LPM4_EXIT; chg_io_to_uartrx_pin(); uc_action &= ~F_Action_Sleep; } switch(__even_in_range(UCA0IV, 18)) // switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG)) { case USCI_UART_UCRXIFG: if ((uc_uartflag & F_uart_RxSuccess)==0) { if((uc_uartflag & F_UARTRxStart)==0) { uc_uartflag |= F_UARTRxStart; uc_RxBufoffset = 0; } //if(gu8v_UartRxBuf[C_byte1] != 0x55) //{ // uc_RxBufoffset = 0; //} uc_status = OFS_UCAxSTATW; uc_data = EUSCI_A_UART_receiveData(EUSCI_A0_BASE); if((uc_status & (UCOE|UCPE|UCFE|UCRXERR))== 0) { gu8v_UartRxBuf[uc_RxBufoffset] = uc_data; uc_RxBufoffset++; uc_UART_RxLength = C_UART_TEST_LENGTH; if (uc_RxBufoffset >= uc_UART_RxLength) { uc_uartflag |= F_uart_RxSuccess; //uc_wait_sleep_cnt = C_Wait_Slp_Time; } } } uc_UART_RxTimoutCnt = 0; uc_wait_sleep_cnt = C_Wait_Slp_Time; break; case USCI_UART_UCTXCPTIFG: break; default: //case USCI_UART_UCTXIFG: //case USCI_NONE: //case USCI_UART_UCSTTIFG: break; } }
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