2021-04-16 06:17 AM
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
2021-04-20 08:01 AM
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.
2021-04-21 01:21 AM
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
2021-04-21 02:18 AM
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)
2021-04-21 03:13 AM
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
2021-04-21 03:34 AM
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.
2021-04-21 03:47 AM
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
2021-04-21 03:47 AM
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
2021-04-21 04:03 AM
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.
2021-04-21 05:39 AM
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