Controlling external DACs

xnooga
Posts: 1
Joined: Tue Jun 12, 2018 12:03 pm

Controlling external DACs

Postby xnooga » Tue Jun 12, 2018 1:55 pm

Hi! I'm experimenting with MCP4725 DACs over I2C. I want to use them to emit arbitrary waveforms synthesised in software.
My idea is to calculate and send the samples one by one over I2C to the DAC. I verified that the DAC is working and looks like it's playing well with https://github.com/Molorius/esp32-mcp4725.

I tried using timers (driver/timer.h) to get a stable sample frequency (like 22kHz) but whenever I call say mcp4725_set_voltage (which basically sends an I2C command) inside timer ISR the CPU resets.

What is the best way to achieve stable timing while still being able to use I2C etc. on ESP32?

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: Controlling external DACs

Postby ESP_Sprite » Thu Jun 14, 2018 2:08 am

There are very few functions you can use inside an ISR. Your best bet is to let the ISR set a semaphore (or equivalent inter-task communication mechanism) and let a task wait on that semaphore, then send the I2C command.

Who is online

Users browsing this forum: Bing [Bot], ESP_Roland and 107 guests