英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流

标题: c编译器的问题! [打印本页]

作者: winnie    时间: 2009-4-18 14:33
标题: c编译器的问题!
我用的是mplab ide 6.60+HT-PIC v8.01PL3 我编了个简单的time0定时中断程序,但是中断服务程序怎么无法进行编译,就是中断服务程序无法生成汇编代码。我用HT-PIC v8.01PL3 自带的timer0.c例子也不行。

#include <pic.h>

/*
* Example code for using timer0 on a 17C756
* Just sets up a 1 second interrupt and increments a variable
*/

/*
* Calculate preload value for one second timer
*/

#define PERIOD 1000000  // period in uS - one second here
#define XTAL 4000000  // crystal frequency - 4MHz
#define ICLK (XTAL/4) // crystal is divided by four
#define SCALE 16  // prescale by 16 - check for overflow!

#define PRELOAD PERIOD*ICLK/SCALE/1000000

unsigned long seconds; // second count

/* service routine for timer 0 interrupt */

void interrupt
timer0_isr(void) @ 0x10
{
seconds++;
TMR0 += -PRELOAD; // re-load timer

// no need to clear T0IF - the hardware did it
}

main()
{
// initialize timer 0;

T0STA = 0b01000;  // prescale by 16
T0CS = 1;   // select internal clock
TMR0 = -PRELOAD; // preload timer
T0IE = 1;   // enable timer interrupt
GLINTD = 0;   // enable global interrupts

for(;;)
  continue;  // let interrupt do its job
}
作者: winnie    时间: 2009-4-18 14:33
可以
config ---〉select device 17c756

或 #include"pic177xx.h"




欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://enroobbs.com/) Powered by Discuz! X3.2