текст прошивки:
Спойлер
Код: Выделить всё
#include<stdlib.h>
#include <p18cxxx.h>
#include <stdio.h>
#include <math.h>
int y=220;
int imp;
float c=0.544;
void InterruptHandlerHigh (void);
char cifra[]={0x7E,0x0C,0xB6,0x9E,0xCC,0xDA,0xFB,0x0E,0xFE,0xDE};
char kol;
char pos_cifra=1;
#pragma config WDT = OFF
void main(void)
{
kol=(-c)*(ADRESH-y);
TRISC=0x01;
// PORTB=0xFF;
TRISB=0x00;
TRISA=0x01;
TRISAbits.TRISA3=1;
TRISD=0x00;
PORTD=0xFF;
TRISE=0x00;
PORTEbits.RE0=1;
T0CON = 0x86;
T0CONbits.T08BIT=0;
T2CON = 0x1D;
PIE1bits.TMR2IE=1;
IPR1bits.TMR2IP=1;
T3CON = 0x07;
INTCON = 0x20;
INTCONbits.RBIE=1;
INTCON2 = 0x84; //TMR0 high priority
RCONbits.IPEN = 1; //enable priority levels
INTCONbits.GIEH = 1;
//enable interrupts
// ADCON1=0x10;
ADCON0=0x01;
ADCON2=0x07;
PORTC = cifra[imp];
PORTD = cifra[kol];
while (1) {
{
kol=(-c)*(ADRESH-y);
}
}
}
#pragma code InterruptVectorHigh = 0x08
void
InterruptVectorHigh (void)
{
_asm
goto InterruptHandlerHigh //jump to interrupt routine
_endasm
}
#pragma code
#pragma interrupt InterruptHandlerHigh
void
InterruptHandlerHigh ()
{
if (INTCONbits.TMR0IF)
{
INTCONbits.TMR0IF=0;
T3CONbits.TMR3ON=0;
imp=TMR3L*60000/819/2;
TMR3L=0x00;
T3CONbits.TMR3ON=1;
ADCON0bits.DONE=1;
kol=(-c)*(ADRESH-y);
}
if (PIR1bits.TMR2IF)
{
PIR1bits.TMR2IF = 0;
pos_cifra = pos_cifra*2;
if ( pos_cifra == 16)
{
pos_cifra=1;
PORTB = pos_cifra;
PORTC = cifra[imp%10];
}
if (pos_cifra == 2)
{
PORTB = pos_cifra;
PORTC = cifra[(imp/10)%10];
PORTD = 0x71;
}
if (pos_cifra == 4)
{
PORTB = pos_cifra;
PORTC = cifra[(imp/100)%10];
PORTD = cifra[kol%10];
}
if (pos_cifra == 8)
{
PORTB = pos_cifra;
PORTC = cifra[(imp/1000)%10];
PORTD = cifra[(kol/10)%10];
}
}
}
посмотрите что и как... подскажите
вот ссылка на схему