2017-12-19 01:47:37 -05:00
|
|
|
//
|
|
|
|
// FILE: DAC8551_powerdown.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: demo DAC8551 library Arduino
|
2021-01-29 06:31:58 -05:00
|
|
|
// VERSION: 0.2.0
|
2020-11-27 05:10:47 -05:00
|
|
|
// URL: https://github.com/RobTillaart/DAC8551
|
2017-12-19 01:47:37 -05:00
|
|
|
//
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2017-12-19 01:47:37 -05:00
|
|
|
#include "DAC8551.h"
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
// HW SPI uses slave spin since 0.2.0
|
|
|
|
DAC8551 mydac(10);
|
|
|
|
|
2017-12-19 01:47:37 -05:00
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
|
|
|
Serial.println(DAC8551_LIB_VERSION);
|
2021-01-29 06:31:58 -05:00
|
|
|
mydac.begin();
|
2017-12-19 01:47:37 -05:00
|
|
|
}
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2017-12-19 01:47:37 -05:00
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
Serial.println("Start sawtooth");
|
|
|
|
for (uint16_t i = 0; i < 32000; i+= 100)
|
|
|
|
{
|
2021-01-29 06:31:58 -05:00
|
|
|
mydac.setValue(i);
|
2017-12-19 01:47:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Serial.println("Stop DAC for 5 seconds");
|
2021-01-29 06:31:58 -05:00
|
|
|
mydac.setPowerDown(DAC8551_POWERDOWN_HIGH_IMP);
|
2017-12-19 01:47:37 -05:00
|
|
|
uint32_t start = millis();
|
|
|
|
while (millis() - start < 5000);
|
2021-01-29 06:31:58 -05:00
|
|
|
mydac.setPowerDown(DAC8551_POWERDOWN_NORMAL);
|
2017-12-19 01:47:37 -05:00
|
|
|
|
|
|
|
Serial.println("Continue sawtooth");
|
|
|
|
for (uint16_t i = 32000; i < 64000; i+= 100)
|
|
|
|
{
|
2021-01-29 06:31:58 -05:00
|
|
|
mydac.setValue(i);
|
2017-12-19 01:47:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Serial.println("Stop DAC for 5 seconds");
|
2021-01-29 06:31:58 -05:00
|
|
|
mydac.setPowerDown(DAC8551_POWERDOWN_HIGH_IMP);
|
2017-12-19 01:47:37 -05:00
|
|
|
start = millis();
|
|
|
|
while (millis() - start < 5000);
|
2021-01-29 06:31:58 -05:00
|
|
|
mydac.setPowerDown(DAC8551_POWERDOWN_NORMAL);
|
2017-12-19 01:47:37 -05:00
|
|
|
}
|
|
|
|
|
2021-12-15 06:34:24 -05:00
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
// -- END OF FILE --
|
2021-12-15 06:34:24 -05:00
|
|
|
|