[sdiy] Organisation of tasks in synth's main uP
Tom Wiltshire
tom at electricdruid.net
Mon Nov 22 17:29:27 CET 2010
Hi all,
Having got started with C, I'm thinking about what I'm trying to do with it - Write code for the main uP in my synth.
This uP has to accomplish the following tasks, which are common to many synths:
* Scan the keyboard and calculate velocity, note on, etc.
* Update the LCD screens
* Update panel LEDs
* Scan panel buttons and controls
* Read several ADC channels
* Process incoming MIDI
* Send outgoing MIDI
* Deal with voice assignment
* Send instructions to the voices over a serial comms link
Most of these things I've done at one time or another, so I'm not too worried about the nuts and bolts of each part. What I haven't done before is deal with a system that does so many different things at once. It needs to do each in a timely manner.
Some of these tasks are quite slow and will delay other things appreciably if not handled correctly. One example is the LCD. LCDs are dog slow to respond, so sending a screenful of information to one will hang up my uP for a considerable time. To prevent this should I buffer outgoing bytes to the LCD? I could then throw LCD data into a buffer and then feed bytes from there to the LCD at a slower rate.
Other tasks are slow, but require fairly swift attention. For example, I could buffer MIDI information coming in, and then deal with it in quite large chunks (say 16 or 32 bytes), but this would entail a considerable MIDI lag, which I'd like to avoid. Instead, I'd thought of calling the MIDI parser each time a status byte arrives. This would mean that the previous message was now complete and could be processed, or that a system realtime message had just arrived, in which case it could be processed.
I can see that interrupts are going to be crucial, but the question is where to focus scarce resources? I know some people here have broken the job down by having a separate uP doing control panel scanning. Whilst that has some benefits, it also implies another set of inter-uP comms which has costs.
Your thoughts please?
Thanks,
Tom
More information about the Synth-diy
mailing list