Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UIT2_MovingAverage UIT2_AllpassReverb UIT2_CombReverb UIT2_FIR_LPF_Symmetry ... more
Diff: DAC_MCP4922.cpp
- Revision:
- 14:6c60601c1834
- Parent:
- 11:a764fe59d343
- Child:
- 16:0001d3e93bee
--- a/DAC_MCP4922.cpp Fri Dec 19 06:01:15 2014 +0000
+++ b/DAC_MCP4922.cpp Sun Dec 21 08:07:09 2014 +0000
@@ -1,7 +1,7 @@
//------------------------------------------------------
// Class for single DAC in MCP4922
//
-// 2014/11/27, Copyright (c) 2014 MIKAMI, Naoki
+// 2014/12/21, Copyright (c) 2014 MIKAMI, Naoki
//------------------------------------------------------
#include "DAC_MCP4922.hpp"
@@ -56,14 +56,27 @@
mySpi_->DR = value | wcr_;
}
- void DAC_MCP4922::ScfClockTim3(uint32_t clock)
+ void DAC_MCP4922::ScfClockTim3(uint32_t clock, PinName pin)
{
- PwmOut clockSCF_(D9);
+ if ( (pin != PA_6) && (pin != PB_4) && (pin != PB_5) &&
+ (pin != PC_6) && (pin != PC_7) && (pin != PC_8) && (pin != PC_9) )
+ {
+ fprintf(stderr, "\r\nIllegal pin name in DAC_MCP4922::ScfClockTim3()\r\n");
+ while (true) {}
+ }
+
+ PwmOut clockSCF(pin);
TIM3->ARR = SystemCoreClock/clock - 1;
TIM3->PSC = 0;
// Set capture/compare register 2
- TIM3->CCR2 = (TIM3->ARR + 1)/2;
+ if ( (pin == PA_6) || (pin == PB_4) || (pin == PC_6) )
+ TIM3->CCR1 = (TIM3->ARR + 1)/2;
+ if ( (pin == PB_5) || (pin == PC_7) )
+ TIM3->CCR2 = (TIM3->ARR + 1)/2;
+ if (pin == PC_8)
+ TIM3->CCR3 = (TIM3->ARR + 1)/2;
+ if (pin == PC_9)
+ TIM3->CCR4 = (TIM3->ARR + 1)/2;
}
}
-