Ответ: Я переделал код, теперь цифры рисуются в таймерном прерывании каждые 8 мсек. Проблема в том, что пропадает сегмент "B" на втором индикаторе :(
/* Port interfaced to display unit */
#define DISPLAY_PORT PORTC
/* Segments definition */
#define SEG_A 0x01
#define SEG_B 0x02
#define SEG_C 0x04
#define SEG_D 0x08
#define SEG_E 0x10
#define SEG_F 0x20
#define SEG_G 0x40
#define SEG_CD 0x80
/* Display units definition */
#define SEG_D1 PINB3
#define SEG_D2 PINB2
#define SEG_D3 PINB1
#define SEG_D4 PINB0
#define SEG_CD PINA7
SIGNAL(SIG_OUTPUT_COMPARE0)
{
// unit=0 SEG_D2
// unit=1 SEG_D4
if (unit == 0) {
/* shut off digit */
PORTB = _BV(SEG_D2);
DISPLAY_PORT = DigitTable[17];
/* display next unit */
PORTB = _BV(SEG_D4);
DISPLAY_PORT = DigitTable[1];
}
else if (unit == 1) {
/* shut off digit */
PORTB = _BV(SEG_D4);
DISPLAY_PORT = DigitTable[17];
/* display next unit */
PORTB = _BV(SEG_D2);
DISPLAY_PORT = DigitTable[2];
}
unit++;
if (unit > 1) unit = 0;
}
int main(void)
{
TCCR0 = 0x00;
TCNT0 = 0x00;
TCCR0 = _BV(CS02) | _BV(WGM01);
OCR0 = (unsigned int)(delay0 * Fck0);
TIMSK = _BV(OCIE0);
//Timer1_Init();
sei();
DDRB = (_BV(SEG_D2) | _BV(SEG_D4));
/* Set all PORTC pins as outputs */
DDRC = 0xFF;
// endless loop
while (1)
{
}
return 1;
}
-
- Так может он просто сгорел? - Сергей Борщ(28.12.2004 20:15)