'Timer' has no attribute 'PERIODIC'



  • Hi everyone,
    I'm just getting started with timers and irq and I was trying the example code.
    However I have an issue with the initialisation of the timer.
    Here is my code:

    tim1 = Timer(1, mode=Timer.PERIODIC)
    tim1_ch = tim1.channel(Timer.A, freq=100)
    tim1_ch.irq(priority=7, trigger=Timer.TIMEOUT, handler=acquireData_cb)
    

    And the return

    PYB: soft reboot
    Traceback (most recent call last):
      File "main.py", line 42, in <module>
    AttributeError: type object 'Timer' has no attribute 'PERIODIC'
    MicroPython v1.8.6-607-g9c8a0e9e on 2017-05-01; WiPy with ESP32
    Type "help()" for more information.
    

    I was basically running with a custom firmware so I reflashed the last one but still gets the error

    >>> import os
    >>> os.uname()
    (sysname='WiPy', nodename='WiPy', release='1.6.13.b1', version='v1.8.6-607-g9c8a0e9e on 2017-05-01', machine='WiPy with ESP32')
    

    I already had a similar issue on pyBoard with the time module where ticks_ms was not available.

    Did someone already had the same problem?



  • Hi @bucknall, I finally found this library for using queues on micropython.

    However, this library need collections.deque and uasynio.core.

    1 from collections.deque import deque
    2 from uasyncio.core import sleep
    

    I went to the github repository, I downloaded collection.deque but I couldn't find uasynio.core anywhere.

    I think I'm not importing libraries correctly because I need to modify the line from collections.deque import deque to from collections import deque

    So now I would like to find the uasyncio.core module to be able to use the queue library ^^

    I hope I do not need to open a new thread for this question.
    If so, I'm sorry ;)



  • @bucknall

    As there is not so much documentation about multithreading and interrupts, how could two threads communicate?
    I'm looking for a queue-like mecanism but I can't find anything about it neither in Threading or Timers.

    Thanks



  • Hi @bucknall,

    I was using this documentation : https://docs.pycom.io/wipy/library/machine.Timer.html

    I had not realized yet that wipy documentation and wipy 2.0 was not the same...

    Thank you very much, everything is working fine now.



  • Hi @Arkaik,

    Where are you getting your example code from? Please see https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/timers.html for our example code within our documentation.

    It's important to note that our timers do not work the same as on the Pyboard.

    Thanks!

    Alex



Pycom on Twitter