Hi,
A bit newbee with micropython. I was seeking for a small ST micropython compatible MCU to write a piece of software in a simple way (i was a fan of the excellent Chibios but ...). I download a fresh repo and libraries, and compile and test today with genuine STM 32 evboards timer callback and RTC, with exactly the same behaviour (i paste the second set of test).
>>> from pyb import LED
>>> led=LED(1)
>>> led.toggle()
>>> from pyb import Timer
>>> tim = Timer(1, freq=1000)
>>> tim.freq(0.5)
>>> tim.callback( lambda t: pyb.LED(1).toggle())
>>> uncaught exception in Timer(1) interrupt handler
NameError:
>>>
PYB: soft reboot
MicroPython v1.10 on 2019-01-26; NUCLEO-L432KC with STM32L432KC
Type "help()" for more information.
>>> from pyb import RTC
>>> rtc = RTC()
>>> rtc.datetime((2019, 1, 26, 6, 11, 5, 0, 0))
>>> rtc.datetime()
(2000, 1, 1, 1, 0, 0, 0, 0)
>>>
Same test on PYBV11 405RG compilation is of course fine and successfully did theses tests.
What's the trick ?
Tests on ST evkits F091RC and L432KC
Re: Tests on ST evkits F091RC and L432KC
After searching a bit, i found that i've got an old compiler :
arm-none-eabi-gcc --version
arm-none-eabi-gcc (15:4.9.3+svn231177-1) 4.9.3 20150529 (prerelease)
So i upgrade it to :
arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]
But unlikely the issue persist :
>>> from pyb import RTC
>>> rtc=RTC()
>>> rtc.datetime((2019, 1, 26, 6, 15, 44, 0, 0))
>>> rtc.datetime()
(2000, 1, 1, 1, 0, 0, 0, 0)
>>>
PYB: soft reboot
MicroPython v1.10 on 2019-01-26; NUCLEO-L432KC with STM32L432KC
Type "help()" for more information.
>>> from pyb import LED
>>> led=LED(1)
>>> led.toggle()
>>> from pyb import Timer
>>> tim = Timer(1, freq=1000)
>>> tim.freq(0.5)
>>> tim.callback( lambda t: pub.LED(1).toggle())
>>> uncaught exception in Timer(1) interrupt handler
NameError:
Is anybody have being is the same situation ?
arm-none-eabi-gcc --version
arm-none-eabi-gcc (15:4.9.3+svn231177-1) 4.9.3 20150529 (prerelease)
So i upgrade it to :
arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]
But unlikely the issue persist :
>>> from pyb import RTC
>>> rtc=RTC()
>>> rtc.datetime((2019, 1, 26, 6, 15, 44, 0, 0))
>>> rtc.datetime()
(2000, 1, 1, 1, 0, 0, 0, 0)
>>>
PYB: soft reboot
MicroPython v1.10 on 2019-01-26; NUCLEO-L432KC with STM32L432KC
Type "help()" for more information.
>>> from pyb import LED
>>> led=LED(1)
>>> led.toggle()
>>> from pyb import Timer
>>> tim = Timer(1, freq=1000)
>>> tim.freq(0.5)
>>> tim.callback( lambda t: pub.LED(1).toggle())
>>> uncaught exception in Timer(1) interrupt handler
NameError:
Is anybody have being is the same situation ?
-
- Posts: 363
- Joined: Sun Apr 17, 2016 1:55 pm
Re: Tests on ST evkits F091RC and L432KC
You have not import pyb, you may try as below:
Code: Select all
import pyb
from pyb import Timer
tim = Timer(1, freq=1000)
tim.freq(0.5)
tim.callback( lambda t: pyb.LED(1).toggle())
Re: Tests on ST evkits F091RC and L432KC
Your're right. I feel a bit silly. Timer callback issue closed. Thanks.
For the RTC, is my syntax OK ? Does anybody can reproduce or not.
Thanks in advance.
For the RTC, is my syntax OK ? Does anybody can reproduce or not.
Thanks in advance.
Re: Tests on ST evkits F091RC and L432KC
Solved. I missed an rtc.init(), useless on PYBV11 but mandatory for these platforms.
Thanks again shaoziyang.
Thanks again shaoziyang.