Skip to content

Commit

Permalink
fix: Correct the setFrequency command (#117)
Browse files Browse the repository at this point in the history
* fix: Correct the setFrequency command, mixed between clock frequency and period frequency

* perf: Slightly better accuracy.

---------

Co-authored-by: Jerzy Jamroz <[email protected]>
  • Loading branch information
agaget and jerzyjamroz authored Jan 12, 2024
1 parent 73aea17 commit 50dc177
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions evgMrmApp/src/evgMxc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ evgMxc::getPrescaler() const {

void
evgMxc::setFrequency(epicsFloat64 freq) {
epicsUInt32 clkSpeed = (epicsUInt32)(getFrequency() *
pow(10.0, 6));
epicsUInt32 preScaler = (epicsUInt32)((epicsFloat64)clkSpeed / freq);

epicsFloat64 clkSpeed = m_owner->getFrequency() * pow(10.0, 6);
epicsUInt32 preScaler = (epicsUInt32)lround(clkSpeed / freq);
setPrescaler(preScaler);
}

Expand Down Expand Up @@ -98,4 +96,3 @@ evgMxc::getTrigEvtMap(epicsUInt16 trigEvt) const {
epicsUInt32 mask = 1 << (trigEvt+MuxControl_TrigMap_SHIFT);
return READ32(m_pReg, MuxControl(m_id))&mask;
}

0 comments on commit 50dc177

Please sign in to comment.