Skip to content

Implementation Notes

Patrick Dowling edited this page Apr 26, 2016 · 5 revisions

Extended Firmware Implementation Notes

  • There's a minimal "app" infrastructure that provides hooks to common events (see APPS.ino)
  • Some things still have to be done manually and it's by no means comprehensive

ISR

Instead of multiple timer ISRs, I implemented a CORE_isr running at 16.666kHz

  • services the DAC (all four channels at once)
  • Updates the OLED (in 1/8 screen chunks)
  • Scans the ADC (see below)
  • Triggers encoder updates via flags

The ISR completes in the 60us provided (~10 - 50us), and it is possible to hook this ISR from an app (see the POLYLFO.ino).

ADC

Using an extended ADC wrapper which seems to be part of the standard libs, the ADC is scanned in the core ISR. The read for a channel is started in one pass, and the value read in the next, which starts the next read, etc. This means the raw scan rate is ISR rate / 4 since there are four 4 CV channels. Additionally, the values are smoothed internally to further remove some jitters, so the final rate is

  • ~1kHZ at 16.6kHz ISR/60us (now the default)

Graphics

u8glib was originally used, but since the DAC/OLED share the SPI port, it was introducing a lot of latency. Some screen redraws were taken on the order of 6ms. Using a hacked u8glib to render to an in-memory framebuffer wasn't much better. Instead I wrote a small graphics lib (weegfx) to render to a buffer which is then sent to the OLED in the background. The "slowest" menu is now ~200uS for Automatonnetz, with the others between 100-150us and there's still a few possible optimizations.

  • Updates are double-buffered so paging should be minimal(ish)
  • The OLED has vertical pixels which makes drawing fun
  • The weegfx::Graphics interface is a bit minimal, but it draws basically the same menus as before
  • Additional fonts are probably a good next step.
  • The 128 bytes of page data are transferred using DMA so the mcu is free for other fun

The OLED commands are pretty-much hardcoded, but we really only need "init" and "here's a page of data" :)

Clone this wiki locally