I was wondering is there any test example describing how to use Timer in Compare, capture mode. i have tried myself, but I don't understand whats happening ?
Reffered this doc : http://docs.micropython.org/en/v1.9.3/p ... Timer.html
I have created a timer object with freq 1. It will toggle on board LED 4 once every sec using callback. Than created a channel on timer(13), and set its mode to Timer.OC_ACTIVE.
And passed the value to be compared in timer.compare(value). So shouldn't it generate an interrupt on comparison ?
Or is my code wrong ? Or anyone have idea about using Timer in different mode please comment.
Code: Select all
#Include Timer and LED modules from pyb import Timer, LED, Pin #PA0 is pin associated with PA1 x = Pin('PA0') #Creating a tTimer object on Timer 2 tim = Timer(13) tim.init(freq = 1) tim.callback(lambda t: LED(4).toggle()) #Channel 1 of Timer 13 a = tim.channel(1, tim.OC_ACTIVE) tim.counter(0) a.compare(5798) print(tim.OC_ACTIVE)