Dear all,
I'm having some trouble getting to the right buildup of my code.
Project: arduino as external WAV player (10kHz, mono, 8bit) and display driver (nokia 5110), controlled through SPI
Reason: offload primary processor (arduino as well :P)
I have some elements working:
- Arduino running as SPI slave on hardware SPI pins: done
- Reading SD card using software SPI, driving external speaker (PWM): done
- Getting images to Nokia 5110 display using software SPI: done
Since the sound is 10kHz, I have 100 us to do whatever I do to get my music playing, because after 100 us I'm up to do it again to get the 10 kHz frequency. Now reading a byte from a file and driving the speaker takes a bit under 50 us, and I'm driving that down. So this leaves another 50 us to send data to my display.
I'd like to do this as easy as possible, if possible without chopping up the nokia 5110 library. So I thought up this plan:
Hook up an interrupt to timer 1 @ 10kHz, have this interrupt read a byte from the sd card and drive the speaker, use 4 software SPI pins to do this.
Then in my main loop I use four different software SPI pins to talk to my display. This might mean that somewhere while instructing my display the processor jumps to the interrupt, plays a byte, and returns to the main loop where my display is being instructed.
The question: will this work?
Cheers,
Jack