Generate a sawtooth wave with 8kHz frequency

limit = 8192, step = 486

Like I said

and limit is 4095. You read the datasheet, didn't you?

Yes, I read it several times. But you know I'm a neophyte and I didn't get the point immediately. U tell me to try those values and I wanted to show u the results. That's it

A value above 4095 is not accepted.

From the datasheet for MCP4821 - SPI interface with support for 20 MHz clock, fast setup time of 4.5 µs.
According to these data, even with a faster microcontroller you will hardly achieve 8 kHz at a full range of 4096 steps because the DAC itself is not fast enough.

1 Like

Hi guys,
After a few die and retry, I finished by got a pretty smooth saw tooth wave with those values:

void loop()
{
  // high-res triangular wave
  for (int i = 0; i < 512; i += 16)
  {
    // setOutput(0, GAIN_2, 1, i);
    setOutput(i);
  }
}

BUT ! I need to amplify the signal I think.

Thanks for all of ur responses.

Why didn't you just use discrete elements? Like transistors, timer 555 or Op Amp's.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.