I found the bug in the TCD1304 driver firmware, or maybe I should rather say that I publicly exposed a flaw in my personality. I’m too impatient.
In the previous firmware the integration time was set to 1 s by default. Because I couldn’t always wait 1 s from I reset the nucleo board before pressing ‘record’ I got the aforementioned unpredictable behaviour.
I’ve long ago realised that it’s much easier to change my surroundings than my personality, and so I’ve changed the new default integration time is 20 µs. This gives the nucleo time to catch it’s breath before I try and interact with it after a reset.
This small but significant change ensures consistently good behaviour. And here is what may well be the last revision of the firmware for STM32F401RE in a long time:
You may also find it on hackaday.io. There’s also a short one-page-write-up of how to get everything up and running, in case you don’t feel like reading through every other post I’ve made on this blog.