cancel
Showing results for 
Search instead for 
Did you mean: 

how can i implement UART wake up from halt mode ? please give me suggestion

DJosh.0
Associate II

I have development board of STM8L152R8. I want process like after uart interrupt comes controller should exit from halt mode . and after completing the routine it goes in halt mode again.

I didn't find example regarding this subject.

please help me to find the solution

thanks and regards

Deoyani

15 REPLIES 15
WilkoL
Senior

You cannot wake from HALT with the UART. See page 62 of the Datasheet. But you could try to use a GPIO in EXTI mode that is connected to the RXD of the UART.

DJosh.0
Associate II

I have tried GPIO In EXTI mode that is connected to the RXD of UART but it is not working .

can you give me suggestion how to demo code for Halt mode of STM8 I have seen the example code from peripheral library , but I am not understanding too much .

can you give me any document or link to implement Halt mode and wake up from halt mode ?

thanks and Regards

Deoyani

Here are some bits from an experiment I did with a STM8L151C8

part of main:

while (1)
	{
		PWR_UltraLowPowerCmd(ENABLE);  //disables the VREFINT in halt
		PWR_FastWakeUpCmd(ENABLE);  //starts without VREFINT stable
		CLK_HaltConfig(CLK_Halt_SlowWakeup, ENABLE);  //do not keep CLK running in halt
		
		GPIO_Init(GPIOA, GPIO_Pin_All, GPIO_Mode_In_PU_No_IT);  //all GPIO as input with pullup
		GPIO_Init(GPIOB, GPIO_Pin_All, GPIO_Mode_In_PU_No_IT);  //saves power
		GPIO_Init(GPIOC, GPIO_Pin_All, GPIO_Mode_In_PU_No_IT);
		GPIO_Init(GPIOD, GPIO_Pin_All, GPIO_Mode_In_PU_No_IT);
		GPIO_Init(GPIOE, GPIO_Pin_All, GPIO_Mode_In_PU_No_IT);
		GPIO_Init(GPIOF, GPIO_Pin_All, GPIO_Mode_In_PU_No_IT);
 
		EXTI_config();
		
		halt();  //halt, not active halt because 
		//  //there is no LSE running
		
		GPIO_Init(GPIOE, GPIO_Pin_7, GPIO_Mode_Out_PP_Low_Slow);  //pushpull
		GPIO_SetBits(GPIOE, GPIO_Pin_7);
		DELAY_ms(500);
		GPIO_ResetBits(GPIOE, GPIO_Pin_7);
 
	}

small snippet from the interrupts, it just clears the ITPendingBit, nothing else is done.

INTERRUPT_HANDLER(EXTI6_IRQHandler,14)
{
	if (EXTI_GetITStatus(EXTI_IT_Pin6) != RESET)
	{
		EXTI_ClearITPendingBit(EXTI_IT_Pin6);
	}
}

and the initialization if the EXTI itself

static void EXTI_config(void)
{
	GPIO_Init(GPIOE, GPIO_Pin_6, GPIO_Mode_In_FL_IT);  //floating
	
	disableInterrupts();  //no iterrupts
	EXTI_DeInit();
	EXTI_ClearITPendingBit(EXTI_IT_Pin6);
	EXTI_SetPinSensitivity(EXTI_Pin_6, EXTI_Trigger_Falling);
	enableInterrupts();
}

If I remember well there was a button connected to PE6, that wakes up the mcu, a LED on PE7 went on for 500ms and then the mcu went back to halt mode. It was to check the current consumption in halt mode. (< 1 uA)

DJosh.0
Associate II

Thank you for your answer, I will try it now .

I want to ask another question ,

I have configured two switches for external interrupt ,and i have to configure 3 rd switch to wake up the MCU ,

Can you give me any suggestion what should i do, should I wakeup MCU from external interrupt or I should use RTC wakeup ,method ?

thanks and regards

Deoyani

First, take care that you disable the external interrupts for those two switches if you do not want those to wakeup the mcu as well.

And second it doesn't matter what you use to wakeup the mcu, EXTI is fine, RTC is fine, AWU is fine.

But for RTC and AWU you cannot use HALT mode anymore, it will be ACTIVE HALT because there will be an oscillator running.

DJosh.0
Associate II

I have implemented what you have sent me now, LED is blinking continuously , Am I doing something wrong ?

And can you please explain me what the purpose of putting the Interrupt pin floating ?

thanks for your continuous support

thanks and regards

Deoyani

DJosh.0
Associate II

I have implemented what you have sent me now, LED is blinking continuously , Am I doing something wrong ?

And can you please explain me what the purpose of putting the Interrupt pin floating ?

thanks for your continuous support

thanks and regards

Deoyani

Blinking?

If you just copied that code it should be OFF until you pull PE6 low, then it will be ON for 500ms and go OFF again when the mcu returns to halt.

It could be that the "floating" is part of your problem here. I had a button with its own pullup resistor connected to PE6 and I wanted to measure only the mcu current in halt mode.

Make it to GPIO_Init(GPIOE, GPIO_Pin_6, GPIO_Mode_In_PU_IT) and try again.

DJosh.0
Associate II

void EXTI_setup(void)

{

   disableInterrupts();

   GPIO_Init(GPIOC, GPIO_Pin_0, GPIO_Mode_In_PU_IT);

   EXTI_DeInit();

   EXTI_ClearITPendingBit(EXTI_IT_Pin0);            //to be absolutely sure

   EXTI_SetPinSensitivity(EXTI_Pin_0, EXTI_Trigger_Rising_Falling);

   enableInterrupts();

}

/**

 * @brief external interrput handler .

        ResetRegistration Switch Interrupt handler   

 * @param None

 * @retval None

*/

 void ButtonIntHandler (void)

 {

      if (EXTI_GetITStatus(EXTI_IT_Pin0))

      {

       exti_signal = 1;

         ResetRegistration();

      }

      else if (EXTI_GetITStatus(EXTI_IT_Pin1))

      {

       //boollocklocked=IsLock();         

         

         //ui8PreviousState=ui8CurrentState;

         //ui8CurrentState=STATE_MOTOR_CONTROL;

      

      }

      EXTI_ClearITPendingBit(EXTI_IT_Pin0);

      EXTI_ClearITPendingBit(EXTI_IT_Pin1);

      

 }

Is this above code correct for 2 exti interrupt ,

With this code I am getting interrupt correctly for sometime , and for sometime , not getting interrupt .

Am I missed out something in configuring or clearing Interrupt ?

Please help me to resolve this problem.

Thanks and Regards

Deoyani