};

struct TIMER_STRUCT

{

unsigned int Interval;

unsigned char Enable;

};

struct TIMER_STRUCT Timer1S;

struct CAPTURE_STRUCT

{

unsigned char Flag;

unsigned char Pointer;

unsigned int LowData;

unsigned char HighData;

};

struct CAPTURE_STRUCT MyTMR1;

unsigned char High_TMR1;

struct LED_STRUCT

{

unsigned char DotPointer;

unsigned char ScanPointer;

unsigned char Buffer[8];

};

struct LED_STRUCT NumberLED;

void PIC18F_High_isr (void);

void PIC18F_Low_isr (void);

#pragma code high_vector_section=0x8

void high_vector (void)

{

_asm goto PIC18F_High_isr _endasm

}

#pragma code low_vector_section=0x18

void low_vector (void)

{

_asm goto PIC18F_Low_isr _endasm

}

#pragma code

//---中断高优先级---//

#pragma interrupt PIC18F_High_isr

void PIC18F_High_isr (void)

{

if(TRUE==PIR1bits.TMR1IF)

{

PIR1bits.TMR1IF=FALSE;

High_TMR1++;

}

if(TRUE==PIR1bits.CCP1IF)

{

PIR1bits.CCP1IF=FALSE;

if(FALSE==MyTMR1.Flag)

{

if(0==MyTMR1.Pointer)

{

MyTMR1.Pointer++;

TMR1L=0;

TMR1H=0;

High_TMR1=0;

T1CONbits.TMR1ON=TRUE;

}

else

{

MyTMR1.Pointer=0;

T1CONbits.TMR1ON=FALSE;

MyTMR1.LowData=CCPR1H;

MyTMR1.LowData《《=8;

MyTMR1.LowData|=CCPR1L;

MyTMR1.HighData=High_TMR1;

MyTMR1.Flag=TRUE;

}

}

}

}

//---中断低优先级---//

#pragma interruptlow PIC18F_Low_isr

void PIC18F_Low_isr (void)

{

if(TRUE==PIR2bits.TMR3IF)

{

PIR2bits.TMR3IF=FALSE;

TMR3H=(65536-11962)/256;

TMR3L=(65536-11962)%256;

if(FALSE==Timer1S.Enable)

{

Timer1S.Interval++;

if(250==Timer1S.Interval)

{

Timer1S.Interval=0;

Timer1S.Enable=TRUE;

}

}

if(LOW==LATAbits.LATA0)LATAbits.LATA0=HIGH;

else LATAbits.LATA0=LOW;

LATD=LEDDATA[NumberLED.Buffer[NumberLED.ScanPointer]];

if(NumberLED.ScanPointer==NumberLED.DotPointer)LATD|=0x80;

LATE=NumberLED.ScanPointer;

NumberLED.ScanPointer++;

if(NumberLED.ScanPointer==sizeof(NumberLED.Buffer))

NumberLED.ScanPointer=0;

}

}

void main(void)

{

unsigned char i;

unsigned long temp;

float calctemp;

for(i=0;i NumberLED.ScanPointer=0;

NumberLED.DotPointer=0;

MyTMR1.Pointer=0;

MyTMR1.Flag=FALSE;

MyTMR1.HighData=0;

MyTMR1.LowData=0;

High_TMR1=0;

Timer1S.Interval=0;

Timer1S.Enable=FALSE;

TRISAbits.TRISA0=0;

LATAbits.LATA0=0;

TRISD=0;

LATD=0;

TRISE=0;

LATE=0;

TRISCbits.TRISC0=0;

LATCbits.LATC0=1;

  • UC3846控制芯片工作原理控制图 逆变焊机原理与用途
  • 数字万用表电阻档测试二极管正反向没有阻值(使用万用表测量二极管的正向电阻,为什么各档)
  • 学单片机需要学数电模电吗(学单片机要先学数电模电吗)
  • 电工怎么选择适合自己用的万用表(电工初学者买什么样的万用表好)
  • 单片机需要同时运行多个任务怎么办(单片机怎么同时执行多个任务)
  • 电机保护的方案取决于负载的机械特性
  • 绝缘电阻表正负搭接不复零位是怎么回事
  • 短路怎么用万用表查