Understanding hardware timer
Posted: Wed Nov 18, 2015 7:45 am
Currently I am experimenting with driving nixie display (https://en.wikipedia.org/wiki/Nixie_tube) from ESP-12.
There is not enough GPIO pins on module itself, so I am using PCF8574 expanders.
I need four lines to drive 74141 hardware driver (it activates one of ten high voltage, open collector outputs, depending on BCD value on 4-bit parallel input), and another 7 to drive multiplexing optocouplers.
There is a need to switch those outputs quite fast.
I looks like this:
1. I need to turn off current display and wait approximately 0.5ms. Otherwise "shadow" of previous digit will be visible (ghosting effect).
2. After that time, I need to load a new value to four lines, connected to 4-bit input on 74141, to connect proper cathode to GND. Then I light display again, by powering on next anode. After few ms point 1. is executed again.
It is happening so fast, that for a human eye all displays are powered on, displaying proper digits.
Currently I use software timer to do pin toggling, but time of execution of timer callback function is nowhere guaranteed. It differs slightly every time, so jitter effect is visible on the oscilloscope - every pulse differs in length. This may not be a problem, but I am looking for better solution.
On small, 8bit MCU hardware timer is perfect for that. I already implemented multiplexed displays, using Atmega microcontrollers.
Can anyone explain to me how to set up hardware timer, to be executed after passing given amount of time, ranging from few hundreds of microseconds, to few milliseconds?
I am also not quite sure about callback function - writing new value to PCF8575 require I2C_master library, which uses a lot of delays and consume some time. Should I only post request to main task in callback function, and perform all further operations there? But will it be any different from using software timer? Will jitter effect be reduced?
There is not enough GPIO pins on module itself, so I am using PCF8574 expanders.
I need four lines to drive 74141 hardware driver (it activates one of ten high voltage, open collector outputs, depending on BCD value on 4-bit parallel input), and another 7 to drive multiplexing optocouplers.
There is a need to switch those outputs quite fast.
I looks like this:
1. I need to turn off current display and wait approximately 0.5ms. Otherwise "shadow" of previous digit will be visible (ghosting effect).
2. After that time, I need to load a new value to four lines, connected to 4-bit input on 74141, to connect proper cathode to GND. Then I light display again, by powering on next anode. After few ms point 1. is executed again.
It is happening so fast, that for a human eye all displays are powered on, displaying proper digits.
Currently I use software timer to do pin toggling, but time of execution of timer callback function is nowhere guaranteed. It differs slightly every time, so jitter effect is visible on the oscilloscope - every pulse differs in length. This may not be a problem, but I am looking for better solution.
On small, 8bit MCU hardware timer is perfect for that. I already implemented multiplexed displays, using Atmega microcontrollers.
Can anyone explain to me how to set up hardware timer, to be executed after passing given amount of time, ranging from few hundreds of microseconds, to few milliseconds?
I am also not quite sure about callback function - writing new value to PCF8575 require I2C_master library, which uses a lot of delays and consume some time. Should I only post request to main task in callback function, and perform all further operations there? But will it be any different from using software timer? Will jitter effect be reduced?