ocrobot:alpha:d21g18a:tutorial03
差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
| ocrobot:alpha:d21g18a:tutorial03 [2019/07/16 05:02] – miaosheng | ocrobot:alpha:d21g18a:tutorial03 [2025/10/11 02:55] (当前版本) – 外部编辑 127.0.0.1 | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| + | ====== DAC使用 ====== | ||
| + | |||
| + | 测试波形如下: | ||
| + | {{: | ||
| + | <code cpp> | ||
| + | #include < | ||
| + | #include " | ||
| + | int sinv[200]; | ||
| + | const float pi=3.14; | ||
| + | // | ||
| + | Uart Serial2 (& | ||
| + | void SERCOM1_Handler() | ||
| + | { | ||
| + | Serial2.IrqHandler(); | ||
| + | } | ||
| + | | ||
| + | void setup() { | ||
| + | |||
| + | // pinMode(A0, OUTPUT); | ||
| + | analogWriteResolution(10); | ||
| + | analogWrite(A0, | ||
| + | | ||
| + | |||
| + | Serial2.begin(115200); | ||
| + | pinPeripheral(10, | ||
| + | pinPeripheral(11, | ||
| + | | ||
| + | | ||
| + | for (int i=0; | ||
| + | { | ||
| + | sinv[i]=(int)(512.0*sin(2*pi/ | ||
| + | delay(10); | ||
| + | | ||
| + | Serial2.println(i); | ||
| + | Serial2.println(sinv[i]); | ||
| + | } | ||
| + | | ||
| + | |||
| + | } | ||
| + | |||
| + | int i; | ||
| + | void loop() { | ||
| + | int output; | ||
| + | analogWrite(A0, | ||
| + | delayMicroseconds(1); | ||
| + | i++; | ||
| + | if(i> | ||
| + | i=0; | ||
| + | } | ||
| + | </ | ||
