Skip to content

Commit

Permalink
Fix bug in mux function
Browse files Browse the repository at this point in the history
  • Loading branch information
MCUdude committed Mar 15, 2024
1 parent 33ed92f commit df18caf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/SigmaDSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,18 @@ void SigmaDSP::mux(uint16_t startMemoryAddress, uint8_t index, uint8_t numberOfI
if(numberOfIndexes == 0)
safeload_write(startMemoryAddress, index);
else
demux(startMemoryAddress, index, numberOfIndexes);
{
uint8_t i = 0;
// Load leading zeros
for(; i < index; i++)
safeload_writeRegister(startMemoryAddress++, 0x00, false);
// Load index
i++;
safeload_writeRegister(startMemoryAddress++, 0x00800000, (i == numberOfIndexes ? true : false));
// Load tailing zeros
for(; i < numberOfIndexes; i++)
safeload_writeRegister(startMemoryAddress++, 0x00, (i == numberOfIndexes-1 ? true : false));
}
}


Expand Down

0 comments on commit df18caf

Please sign in to comment.