Ryo Od
/
Nucleo_AnalogOut_SawWave
Saw Wave Generator
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 AnalogOut aout(A2); 00004 00005 const int maxAoutValue = 4096; 00006 const float samplingPeriod = 0.25f / maxAoutValue; 00007 00008 int cnt = 0; 00009 00010 void tick() 00011 { 00012 cnt++; 00013 if (cnt == maxAoutValue) { 00014 cnt = 0; 00015 } 00016 aout.write_u16(cnt << 4); 00017 } 00018 00019 int main() 00020 { 00021 Ticker t; 00022 t.attach(&tick, samplingPeriod); 00023 00024 for (;;) {} 00025 }
Generated on Sat Jul 16 2022 02:50:57 by 1.7.2