8000 STM32: Deinitialize DACs on soft-reboot. by iabdalkader · Pull Request #8168 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

STM32: Deinitialize DACs on soft-reboot. #8168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

iabdalkader
Copy link
Contributor
@iabdalkader iabdalkader commented Jan 12, 2022
  • Output a waveform on DAC, example:
import math
from pyb import DAC

# create a buffer containing a sine-wave
buf = bytearray(100)
for i in range(len(buf)):
    buf[i] = 128 + int(127 * math.sin(2 * math.pi * i / len(buf)))

# output the sine-wave at 400Hz
dac = DAC(1)
dac.write_timed(buf, 400 * len(buf), mode=DAC.CIRCULAR)
  • Ctrl-D for a soft-reboot.

  • DAC is still running (using collected/free'd memory).

  • NOTE: Should probably stop TIM6 too.

@iabdalkader
Copy link
Contributor Author

I see there's a machine_dac.c in ESP32 port, but machine module is not documented to have a DAC class.. Should there be a machine.DAC for stm32 following the ESP32 port ?

@robert-hh
Copy link
Contributor

There is also a machine.DAC class, and it is enabled. DAC outputs are GPIO25 and GPIO26.

@dpgeorge
Copy link
Member

Should there be a machine.DAC for stm32 following the ESP32 port ?

esp32 is the only port with machine.DAC, and it only has a .write() method, which takes a value 0-255. So the first thing to do would be specify the machine.DAC API, see eg #4254.

@iabdalkader
Copy link
Contributor Author

esp32 is the only port with machine.DAC, and it only has a .write()

A machine.DAC with just a write() method is a good start.

* DAC timed functions continue to run after a soft reboot
cycle, using collected memory in the case of write_timed.
@iabdalkader
Copy link
Contributor Author

Fixed.

@dpgeorge
Copy link
Member

Rebased and merged in a00e1e5

@dpgeorge dpgeorge closed this Jan 27, 2022
@iabdalkader iabdalkader deleted the dac_fixes branch January 27, 2022 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0