函数中断名如何编写?
#include"C:\mcc18\h\p18f4520.h"#include"user.h"
#pragma udata access access_section
volatile near unsigned char RCBUFFER;
near volatilestruct {
unsigned RCF:1;
unsigned TXF:1;
unsigned :6;
} FLAGbits;
near unsigned char tempreg;
#pragma udata section
unsigned char tempreg2;
#pragma udata
const rom far char dismessage[]={"Hello word."};
//const rom char table[]={"good ok"};
void TMR1(void);
void INT_Lowisr(void);
void initial_PORT(void);
void initial_TMR1(void);
void initial_TMR3(void);
void initial_USART(void);
void INT_TMR1(void);
#pragma code Hight_vector=0x0008
void High_vector(void)
{
_asm
goto INT_TMR1
_endasm
}
#pragma code
#pragma code Low_vector=0x18
void Low_vector(void)
{
_asm
goto INT_Lowisr
_endasm
}
#pragma code
void main(void)
{
initial_PORT();
initial_TMR1();
initial_USART();
while(1)
{
while(FLAGbits.RCF==1)
{
FLAGbits.RCF=0;
Senddata_USART(dismessage);
}
}
}
void initial_PORT(void)
{
ADCON1=0X0F;
PORTB=0x00;
LATB=0x00;
TRISB=0x00;
PORTD=0X00;
LATD=0X00;
TRISD=0X00;
}
void initial_TMR1(void)
{
RCON=0X80;
T1CON=0X38;
PIE1bits.TMR1IE=0X01;
TMR1H=0Xbc;
TMR1L=0X7f;
IPR1bits.TMR1IP=0X01;
T1CONbits.TMR1ON=0X01;
INTCONbits.GIE=0X01;
INTCON=0X80;
}
void initial_USART(void)
{
LATC=0;
PORTC=0;
TRISCbits.TRISC7=1;
TRISCbits.TRISC6=0;
INTCONbits.GIE=1;
INTCONbits.PEIE=1;
PIE1bits.RCIE=1;
IPR1bits.RCIP=0;
BAUDCON=0x00;
TXSTA=0X20;
RCSTA=0X90;
SPBRG=25; // 4Mhz
}
#pragma interrupt INT_TMR1
void INT_TMR1(void)
{
PIR1bits.TMR1IF=0X00;
PORTDbits.RD0=!PORTDbits.RD0;
//FLAGbits.RCF=1;
TMR1H=TMR1H+0xbc;
TMR1L=TMR1L+0X7f;
}
#pragma interruptlow INT_Lowisr
void INT_Lowisr(void)
{
RCBUFFER=RCREG;
//PORTD=RCBUFFER;
FLAGbits.RCF=1;
}
页:
[1]