Skip to content

Commit

Permalink
Fixed multiplexer. Closes #370.
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliomoro committed Mar 15, 2018
1 parent c15331b commit 0a4bcfe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/PRU.cpp
Expand Up @@ -878,7 +878,7 @@ void PRU::loop(void *userData, void(*render)(BelaContext*, void*), bool highPerf


// Value from the PRU is ahead by 1 + (frame size % 8); correct that when unrolling here.
int multiplexerChannelLastFrame = (pruMuxReference - 1 - (context->analogFrames % 8) + context->multiplexerChannels)
int multiplexerChannelLastFrame = (pruMuxReference - 1 - (hardware_analog_frames % 8) + context->multiplexerChannels)
% context->multiplexerChannels;

// Add 1, wrapping around, to get the starting channel
Expand All @@ -889,10 +889,12 @@ void PRU::loop(void *userData, void(*render)(BelaContext*, void*), bool highPerf
unsigned int muxChannelCount = 0;
int multiplexerChannel = multiplexerChannelLastFrame;

for(int n = context->analogFrames - 1; n >= 0; n--) {
for(int n = hardware_analog_frames - 1; n >= 0; n--) {
for(unsigned int ch = 0; ch < context->analogInChannels; ch++) {
// rather than supporting all possible combinations of (non-)interleavead/(non-)uniform,
// we go back to the raw samples and convert them again.
context->multiplexerAnalogIn[multiplexerChannel * context->analogInChannels + ch] =
context->analogIn[n * context->analogInChannels + ch];
analogInRaw[n * context->analogInChannels + ch] / 65536.f;
}

multiplexerChannel--;
Expand Down

0 comments on commit 0a4bcfe

Please sign in to comment.