Controlling external DACs

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

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?

Posts: 2152
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.

Return to “ESP32 IDF”

Who is online

Users browsing this forum: No registered users and 17 guests