dektronics / printalyzer-densitometer

Reflection and Transmission Densitometer for Photographic Darkroom Use
19 stars 4 forks source link

Ensure desired hardware behavior when firmware hasn't started #25

Closed dkonigsberg closed 2 years ago

dkonigsberg commented 2 years ago

When the microcontroller firmware has not started up, or has started using a system bootloader (e.g. USB DFU), most of its GPIO pins (except SWCLK and SWDIO) may be set to an analog input mode. In this mode, things connected to them without external pull-up/pull-down resistors may float and have undesired behavior.

To make sure all the corner cases are covered, this situation should be dealt with:

dkonigsberg commented 2 years ago

LED Driver Pins

It turns out that the real reason the LEDs were turning on at full power in system bootloader mode was not due to floating pins. Rather, it was due to the behavior of the STM bootloader as documented in AN2606. When the bootloader is running, USART1, USART2, and USB peripherals are all enabled. The pins used for TLED_EN and RLED_EN are the same pins respectively used for USART2_RX and USART2_TX. As such, they were being deliberately driven high.

Thus, there are two options:

  1. Ignore the problem, because the bootloader isn't triggered as part of normal operation
  2. Switch the LED driver EN pins to PB3 (TIM2_CH2) and PA15 (TIM2_CH1), and reroute accordingly.

Additionally, as the AP2502 LED driver won't turn on unless its EN pin is above 2V, adding pull-downs is probably unnecessary. However, adding 10k pulldowns anyways, simply as a matter of extra precaution, is likely a good idea.

OLED Display Reset Pin

I have not found any examples of boards using this kind of display with any sort of pull-down on the RESET pin. However, bench testing has shown that adding a 10k pulldown resistor to it is probably also a good idea. This is because:

  1. After disconnecting a wire from this pin, it can take a few moments for the display to turn off. Monitoring this case with an oscilloscope shows this signal meandering downwards, due to capacitance of the system.
  2. Adding a pull-down makes the trailing edge a lot sharper and cleaner, especially in various restart/unconfigured cases.