Ryo Od
/
Nucleo-F767_DCO_Test01
Nucleo-F767 DCO Test 01
Diff: main.cpp
- Revision:
- 3:19bb7c30c354
- Parent:
- 2:4834d4483ea6
- Child:
- 4:b242f4206894
--- a/main.cpp Mon Jul 23 17:34:47 2018 +0000 +++ b/main.cpp Mon Jul 23 17:47:22 2018 +0000 @@ -22,7 +22,7 @@ #endif // Parameter -double drate = 1000.0; // initial output rate (Hz) +double drate = 440.0; // initial output rate (Hz) const double refclk = 200000; // Hz // Interruput @@ -37,13 +37,21 @@ // // param +// channel: 1 or 2 // val: 0 .. 4095 -void InternalDacWrite(uint16_t val) +void InternalDacWrite(int ch, uint16_t val) { // avoid distortion of built-in DAC uint16_t v = ((val + 1024) << 3); - Dac2.write_u16(v); + switch(ch) { + case 1: + Dac1.write_u16(v); + break; + case 2: + Dac2.write_u16(v); + break; + } } void update() @@ -55,7 +63,8 @@ phaccu = phaccu + tword_m; uint16_t idx = phaccu >> 17; // use upper 15 bits - InternalDacWrite(sin_12bit_32k[idx]); + InternalDacWrite(1, sin_12bit_32k[idx]); + InternalDacWrite(2, sin_12bit_32k[idx]); #if (PIN_CHECK) CheckPin.write(0);