#include #include #include #include #include "yaMBSiavr.h" uint8_t font[] = { 0xEE, 0x82, 0xDC, 0xD6, 0xB2, 0x76, 0x7E, 0xC2, 0xFE, 0xF6, }; uint16_t bcd; uint8_t display[4]; volatile uint16_t holdingRegisters[4]; volatile uint8_t outstate = 0; void timer0_init() { TCCR0 = (1<250kHz:250-=>1kHz) TIMSK |= 1<250kHz:250-=>1kHz) //TIMSK |= 1<> 4]; display[2] = font[(bcd&0x0f00) >> 8]; display[3] = bcd&0xF000 ? font[(bcd&0xf000) >> 12] : 0; modbusGet(); } } ISR(TIMER0_COMP_vect) { if(outstate & 0x01){ if(PORTB & 0x01){ PORTB = (PORTB & 0xF0) | 1<<1 | 1<<3; PORTD = display[3] & 0xFC; PORTA = (PORTA & 0xCF) | (display[3] & 0x03) << 4; PORTC = display[1]; } else{ PORTB = (PORTB & 0xF0) | 1<<0 | 1<<2; PORTD = display[2] & 0xFC; PORTA = (PORTA & 0xCF) | (display[2] & 0x03) << 4; PORTC = display[0]; } } else{ PORTB &= ~0x0F; } } ISR(TIMER2_OVF_vect) { //this ISR is called 9765.625 times per second modbusTickTimer(); }