You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new to Sduino and Stm8s. Have some prior experience working with Arduino, AVRs & STM32. I chose STM8s due to its lower price for a project. After developing the project, I need to reduce the current usage as much as possible to make the system Standby Mode. I have tried and failed while using Interrupt with a button.
For the sake of clear understanding, I want to develop a project that can control LED using a Push Button. I want the system to be in sleep mode for the rest of the time.
The sduino repo contains an example code for interrupt, that is:
#define BUTTON PA2
volatile uint8_t flag = 0;
void on_button_pressed(void)
{
flag = 1;
}
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, 1); // turn off the LED
pinMode(BUTTON, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(BUTTON), on_button_pressed, FALLING);
}
void loop()
{
if (flag) {
digitalWrite(LED_BUILTIN, 0);
delay(300);
digitalWrite(LED_BUILTIN, 1);
flag = 0;
}
}
The code does not get compiled in Arduino. On searching the internet for a bit, I found changing digitalPinToInterrupt(pin); to digitalPinToPort(pin); may work. The code gets compiled now but the result remains unexpected.
After digging some more into the problem, I found one more possible solution:
I tried this as well in my code. But still unable to make it work.
My requirement is to attachInterrupt on pin PA2 & use it to wake from sleep. Similar issues have been raised multiple times but not resolved completely.
Kindly provide some input on this problem.
The text was updated successfully, but these errors were encountered:
@MR-IC How do I do that? I am new to development on STM8 and can't find any function in the whole sduino library relating to this. It would help greatly if you can attach a simple code to go to sleep and then wake from button using EXTI.
Hi community,
I am new to Sduino and Stm8s. Have some prior experience working with Arduino, AVRs & STM32. I chose STM8s due to its lower price for a project. After developing the project, I need to reduce the current usage as much as possible to make the system Standby Mode. I have tried and failed while using Interrupt with a button.
For the sake of clear understanding, I want to develop a project that can control LED using a Push Button. I want the system to be in sleep mode for the rest of the time.
The sduino repo contains an example code for interrupt, that is:
The code does not get compiled in Arduino. On searching the internet for a bit, I found changing digitalPinToInterrupt(pin); to digitalPinToPort(pin); may work. The code gets compiled now but the result remains unexpected.
After digging some more into the problem, I found one more possible solution:
Source: #92
I tried this as well in my code. But still unable to make it work.
My requirement is to attachInterrupt on pin PA2 & use it to wake from sleep. Similar issues have been raised multiple times but not resolved completely.
Kindly provide some input on this problem.
The text was updated successfully, but these errors were encountered: