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.
Revision 6:85236b955cf6, committed 2014-12-28
- Comitter:
- frankvnk
- Date:
- Sun Dec 28 18:01:50 2014 +0000
- Parent:
- 5:408b68033540
- Commit message:
- Dmax : Rescale level when DMAX changes.; only stop/start PulseWidth when running.
Changed in this revision
SoftPdmOut.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 408b68033540 -r 85236b955cf6 SoftPdmOut.cpp --- a/SoftPdmOut.cpp Sun Dec 28 15:57:53 2014 +0000 +++ b/SoftPdmOut.cpp Sun Dec 28 18:01:50 2014 +0000 @@ -41,7 +41,14 @@ void SoftPdmOut::PulseWidth(uint32_t level) { - _PulseWidth = level; + if(!_running) // When pdm is inactive, only change the pulse width and don't start the pdm + _PulseWidth = level; + else + { + stop(); + _PulseWidth = level; + start(); + } } uint32_t SoftPdmOut::getPulseWidth(void) @@ -51,8 +58,9 @@ void SoftPdmOut::Dmax(uint32_t level) { + _Level = (uint32_t)((float)_Level * ((float)level / (float)_Dmax)); // Rescale level : level = level * (new level / current DMAX) _Dmax = level; - _accumulator = 0; // zero out the error accumulator + _accumulator = 0; // zero out the error accumulator } uint32_t SoftPdmOut::getDmax(void)