Hello, a little refresher chop but maybe someone will be able to give advice, I built my own version of the display, in part based on this topic (I heartily greet the author)
I have a problem with the code, namely I can not understand why (I bet any hardware delays) when I try to display something, my display shows what I want, but not in certain degrees (positions) only further
In the whilu I am trying to light just 2 columns, from position 1 to 9 and second from 42 (I have tested 2 columns for testing this time, later I will try to write fonts when I already have generic display items)
in the column's realism, much more goes on (items 1-9 correspond to "12-13 hours (the infrared diode is at 12), and in fact the column is somehow at 16 o'clock." Where does it move?
[syntax=c]
#include
#include
#include
#define TIMER0_ON (TIMSK | = _BV (TOIE0))
#define TIMER1_ON (TIMSK | = _BV (TOIE1))
#define TIMER0_OFF (TIMSK & = ~ _BV (TOIE0))
#define TIMER1_OFF (TIMSK & = ~ _BV (TOIE1))
int volatile position = 0;
int volatile flag = 0;
int volatile gClicksPerStep; //
ISR (INT0_vect) {// will execute in INT0, save the current value of timer1 to global, initiate timer 0, reset timer 1, reset position
gClicksPerStep = TCNT1 / 180;
TCNT0 = 255 - gClicksPerStep;
TCNT1 = 0;
TIMER0_ON;
position = 0;
}
ISR (TIMER0_OVF_vect)
{
(SEI);
TCNT0 = 255- gClicksPerStep;
++ position;
if (position == 180)
{
TIMER0_OFF;
}
}
int main () {
// initialization of 0 and 1 timers
TCCR1A = 0;
TCCR1B | = (1