fungus:
scswift:
The board I'm using is one of my own design with a 1284p. The problem with updating the LEDs isn't one of the SPI port being too slow. It's that the DAC is on the same port. So I have to output all the LED data in between DAC updates. Which is impossible if I have too many LEDs attached. Hence the warbling that's been bugging me.
What are you doing with the audio when you update the LEDs? Do you skip an audio sample (or two) to compensate or just leave it running? Skipping samples might make it sound better.
I'm using a modified version of the WaveHC lib. I didn't really think about what it was doing if the interrupt didn't trigger when it was supposed to, but I don't think it's designed to skip samples if that happens. I'm also not sure exactly what it does when interrupts are re-enabled. It could play the pending sample immediately, and then wait 45us to play the next. Or it could play it immediately, then play the next anywhere from 0us to 45us later. I just don't know.
This is how it sets up the interrupt:
// Set up timer one
// Normal operation - no pwm not connected to pins
TCCR1A = 0;
// no prescaling, CTC mode
TCCR1B = _BV(WGM12) | _BV(CS10);
// Sample rate - play stereo interleaved
OCR1A = F_CPU / (dwSamplesPerSec*Channels); // 16mhz / (22050 hz * 1 channel) = 725 clocks between interrupts
// SD fill interrupt happens at TCNT1 == 1
OCR1B = 1;
// Enable timer interrupt for DAC ISR
TIMSK1 |= _BV(OCIE1A);
Anyway, I guess skipping the sample entirely might improve the audio quality. Not sure how to best implement that. Depends on what the timer interrupt is doing after interrupts are re-enabled I guess.
I could stop disabling interrupts and set a flag telling it not to send the sample to the dac and have the dac interrupt look for that. But not disabling the interrupts could make the LED update take even longer and miss more samples.
Or, I could try to figure out how many samples I'll miss and update the sample pointer, but that would make things complicated since the code for the double buffering doesn't expect the play position to be incremented by multiple samples and I don't know how it would behave if I did that.
Neither seems like a good option.
How many boards have you made? Is it not worth adding two patch wires to move the LEDs?
I've had 10 boards made so far, with an order for over 150 paid for and pending, but I don't have the money or time to change the PCB design, and get new PCBs and a new stencil made. This project has already run two months longer than I budgeted and it will be another couple weeks before I actually start shipping boards.
As for patch wires, my customers will be handling the boards to install them in replica props. Adding wires would look sloppy and they might end up breaking them off.
The issue with the sound isn't that big of a deal anyway. Almost all the people that pre-ordered these only need two LED modules, and I can run three using the latest code without any noticeable glitches. As for the remainder, they could use one board for sound and one for LEDs if they need more than 96 LEDs. The main reason I want to fix the issue is that these are supposed to be programmable prop controller boards, and the wider market may want to be able to drive more LEDs for more complex props. I'll just have to fix the issue down the road once I do a second run. 