Page 1 of 1

useing ardunio uno sketch in stm32f103

Posted: Fri Jan 28, 2022 1:31 am
by hamedmaleki
hi guys
I recently wanted to upgrade my myvproject hardware from ARDUNIO UNO to STM32F103C and after try upload sketch i have some error
any one cane help me for compacture my sketch for using in stm 32?

Code: Select all


In file included from D:\MY PROJECT\beta.ino:4:0:
C:\Users\hamed\Documents\Arduino\libraries\PinChangeInterrupt\src/PinChangeInterrupt.h:33:2: error: #error This library can only be used with AVR
 #error This library can only be used with AVR
  ^
In file included from C:\Users\hamed\Documents\Arduino\libraries\PinChangeInterrupt\src/PinChangeInterrupt.h:43:0,
                 from D:\MY PROJECT\beta.ino:4:
C:\Users\hamed\Documents\Arduino\libraries\PinChangeInterrupt\src/PinChangeInterruptBoards.h:117:2: error: #error PinChangeInterrupt library does not support this MCU.
 #error PinChangeInterrupt library does not support this MCU.
  ^
In file included from D:\MY PROJECT\beta.ino:4:0:
C:\Users\hamed\Documents\Arduino\libraries\PinChangeInterrupt\src/PinChangeInterrupt.h:47:2: error: #error Please enable at least one PCINT port!
 #error Please enable at least one PCINT port!
  ^
In file included from D:\MY PROJECT\beta.ino:4:0:
C:\Users\hamed\Documents\Arduino\libraries\PinChangeInterrupt\src/PinChangeInterrupt.h:86:2: error: #error MCU has no such a register
 #error MCU has no such a register
  ^
beta.ino:5:62: fatal error: avr/sleep.h: No such file or directory
 #include <avr/sleep.h>          // enables the sleep function
                                                              ^
compilation terminated.
exit status 1
avr/sleep.h: No such file or directory

Re: useing ardunio uno sketch in stm32f103

Posted: Fri Jan 28, 2022 9:03 am
by fpiSTM
Hi @hamedmaleki

Which core you used ? LibMaple (Roger's core) or STM32 core?

The PinChangeInterrupt library is done only for avr as stated in the library.properties:
https://github.com/NicoHood/PinChangeIn ... perties#L9

And the error is normal as the code check if you are using an avr:
https://github.com/NicoHood/PinChangeIn ... .h#L36-L38

So you can't use it with stm32. Simply use the standard attachInterrupt standard API:
https://www.arduino.cc/reference/en/lan ... interrupt/

About "avr/sleep.h" well STM32 core does not provide it as specific to avr. For STM32 core, you can try he STM32LowPower library:
https://github.com/stm32duino/STM32LowPower/