⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kesme.c

📁 reading gps data from serial
💻 C
字号:
#include <p18f452.h> /* for the special function register declarations */
#include <portb.h> /* for the RB0/INT0 interrupt */
#include <timers.h>
/* Set configuration bits for use with ICD2 / PICDEM2 PLUS Demo Board:
* - set HS oscillator
* - disable watchdog timer
* - disable low voltage programming
* - enable background debugging
*/
#pragma romdata CONFIG
_CONFIG_DECL(_CONFIG1H_DEFAULT & _OSC_HS_1H,
_CONFIG2L_DEFAULT,
_CONFIG2H_DEFAULT & _WDT_OFF_2H,
_CONFIG3H_DEFAULT,
_CONFIG4L_DEFAULT & _LVP_OFF_4L,
_CONFIG5L_DEFAULT,
_CONFIG5H_DEFAULT,
_CONFIG6L_DEFAULT,
_CONFIG6H_DEFAULT,
_CONFIG7L_DEFAULT,
_CONFIG7H_DEFAULT);
#pragma romdata
void toggle_buzzer (void);
void  low_isr (void); /* prototype needed for 'goto' below */

/*
* For high interrupts, control is transferred to address 0x8.
*/

#pragma code low_vector_section=0x08
void high_ISR2 (void)
{
_asm
goto  low_isr
_endasm
}
#pragma code /* allow the linker to locate the remaining code */
/*
* If the buzzer is on, turn it off. If it is off, turn it on.
*/
#pragma interrupt low_isr
void  low_isr (void)
{
//INTCONbits.TMR0IE = 0;
PORTD=0X01;
INTCONbits.INT0IF=0;

//INTCONbits.TMR0IE = 1;
}


#pragma code HIGH_INTERRUPT_VECTOR = 0x18
void high_ISR (void)
{
_asm
goto toggle_buzzer
_endasm
}
#pragma code 


#pragma interrupt toggle_buzzer
void toggle_buzzer (void)
{
PORTD=0X02;


INTCON3bits.INT1IF = 0; /* clear flag to avoid another interrupt */
//INTCONbits.TMR0IF = 0;
}











void main (void)
{
TRISD=0x00;
PORTD=0xff;


RCONbits.IPEN = 1; /* enable interrupt priority levels */
INTCONbits.GIEH = 1; /* enable all high priority interrupts */
INTCONbits.GIEL = 1; /* enable all high priority interrupts */
INTCON3bits.INT1IP=0;

OpenRB1INT (PORTB_CHANGE_INT_ON & /* enable the RB0/INT0 interrupt */
PORTB_PULLUPS_ON & /* configure the RB0 pin for input */
FALLING_EDGE_INT); /* trigger interrupt upon S3 button depression */

OpenRB0INT (PORTB_CHANGE_INT_ON & /* enable the RB0/INT0 interrupt */
PORTB_PULLUPS_ON & /* configure the RB0 pin for input */
FALLING_EDGE_INT); /* trigger interrupt upon ENCODER depression */

//OpenTimer0 (TIMER_INT_ON & T0_SOURCE_INT & T0_16BIT);
//INTCONbits.GIE = 1;*/
while(1);

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -