winter-special-projects / micropython

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
https://micropython.org
Other
0 stars 0 forks source link

Check DAC works #4

Open graeme-winter opened 1 year ago

graeme-winter commented 1 year ago

Verify that the µPython DAC control code works correctly with the assigned pins

Hint: it does not work correctly

graeme-winter commented 1 year ago

OK, looks like this is misconfigured (i.e. there is a real bug fix needed here)

>>> from machine import DAC
>>> d0 = DAC(0)
>>> d0.write(0)
>>> d0.write(4095)
>>> d0.write(0)
>>> d1 = DAC(1)
>>> d1.write(0)
>>> d1.write(4095)
>>> d0.write(4095)
>>> d0.write(0)
>>> d0.write(0)
>>> d1.write(0)

before d1 is configured d0 works correctly, but after d1 is configured d0 is "unplugged"

graeme-winter commented 1 year ago

Also

d2 = DAC(2)

should throw an error; it does not 🤔

graeme-winter commented 1 year ago

OK, DAC creation writes to SWRST -> softwre reset which resets all registers.

That is probably not what we want... I don't know how to avoid that though, without some nasty global "DAC reset" flag

Would also explain the drift on the other DAC when you configure one

graeme-winter commented 1 year ago

Fixed in 9ac42c7d28dd074fb1914f8d89723ba3610a602f

image