-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is attachinterrupt supported? #92
Comments
Seems not. If you need interrupts use the STM8 lib functions which can be directly called. For example PortC Pin4 INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5) { in Winterrupts.c <- somwhere in the arduino path Works for me. |
Thanks for this, @Pog3k ! Your post helped point me in the right direction. For future visitors: I was seeing very erratic behavior and huge amounts of spurious interrupts, no matter what EXTI_SENSITIVITY mode i used. Also, you don't need to modify Winterrupts.c. You can use attachInterrupt(INT_PORTA & 0xFF,ISR,0); together with GPIO_Init and EXTI_SetExtIntSensitivity. Here's my code for an interrupt on D2, meaning PA3, Port A Bit 3:
|
Thank you for your experiments! attachInterrupt() is now fully supported: https://tenbaht.github.io/sduino/usage/interrupts/
|
I am getting bellow error while compiling example code at this link https://tenbaht.github.io/sduino/usage/interrupts/ for STM8S103F3, kindly check. C:\Users\Education\AppData\Local\Arduino15\packages\sduino\tools\sdcc\build.11242/bin/sdcc sketch\sketch_nov08c.ino.cpp preproc\ctags_target_for_gcc_minus_e.cpp re12 -c -Ddouble=float -DUSE_STDINT -D__PROG_TYPES_COMPAT__ -E -MC -mstm8 -DSTM8S103 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_STM8S_BLUE -DARDUINO_ARCH_STM8 -IC:\Users\Education\AppData\Local\Arduino15\packages\sduino\hardware\stm8\0.5.0\cores\sduino -IC:\Users\Education\AppData\Local\Arduino15\packages\sduino\hardware\stm8\0.5.0\variants\standard -IC:\Users\Education\AppData\Local\Arduino15\packages\sduino\hardware\stm8\0.5.0/STM8S_StdPeriph_Driver/inc -IC:\Users\Education\AppData\Local\Arduino15\packages\sduino\tools\sdcc\build.11242/include -DARDUINO_LIB_DISCOVERY_PHASE |
I am getting also compilation errors, so I checked the files that were changed with this issue and observed it is Arduino.h and Winterrupts.c I compared content of Winterrupts.c with my 0.5.0 installation and I think they are not part of the current sduino 0.5.0 released version, so I installed them manually in my Arduino IDE (1.8.13) Then I still got compilation errors on the line I looked in the Winterrupts.c source and saw that it is working with digitalPinToPort(pin) so when I changed to: It works! |
Hello, Does anyone know where this INT_PORTA reference is declared? How can I declare interrupt for I2C? I noticed that the I2C library doesn't make use of interrupts, and even the register pulling mode doesn't actually make use of control registers, I left this issue open: #143 I was able to make write in I2C following the example code that ST provided, but the part of reading I2C I couldn't implement. I'd like to try the I2C implementation with interrupt, but I'm finding examples only for the Cosmic compiler, which unfortunately is a barrier for enforcing licensing via email. How can I make the attachInterrupt function direct I2C interrupts to the handler? P.S.: I found it, thank you (line 304): https://github.com/tenbaht/sduino/blob/development/sduino/stm8/cores/sduino/Arduino.h |
When I try to implement this example-sketch:
I'm getting this error:
When I change
Did I miss something here? Do I have to modify |
Modifying arduino.h and Winterrupts.c is what I did. Please note that the modifiications have never been committed to a new release. They were done after the last released version. So you will have to download those files from this repository separately and overwrite your current ones. |
I would like to add that the code generated in the SDCC compiler is smaller, and for small UCs the Arduino can be a waste of program memory. It is possible to compile using Eclipse IDE, example: https://github.com/rtek1000/W1209-firmware-modified/tree/master/W1209/W1209-firmware-Eclipse |
I've done many, many STM8 projects since I last commented - all on the STM8S003F3P6, the one with 8 kilobytes flash and 1 kilobyte RAM. I've actually stopped using sduino because there was just no way to fit everything in the small memory space. I now use ST Visual Develop with the Cosmic C compiler. It's certainly a lot trickier, and it's straight C instead of C++, but my projects now fit in memory. I2C Slave and Serial debug output together? No problem, fits in 4 kilobytes now. :) |
The ST Develop program takes up more space than the program compiled with SDCC as well. See more details here: |
Thanks for the quick replys. I copied the whole files from your suggested commit in the |
Hi, for STM8, I suggest using SDCC instead of the Arduino IDE, or Cosmic, or Platformio. STM8 is very basic, and this link has lots of tips on how to get to know STM8 and an example of a project with the Eclipse IDE: |
okay, I'll check if I get it working on PlatformIO, as this is my favorite IDE for Arduino/STM32/ESP32 projects :) |
Thank you for the hints, I got it working on PIO, but I don't know if I'm using the interrupts right... see this thread. Can someone help me with this and see if there is any big mistake I make? |
Just new to sduino and would like to know if attachinterrupt is supported?
The text was updated successfully, but these errors were encountered: