help Guest
|
my interrupts on change cant work... |
Posted: Fri Aug 08, 2008 7:02 pm |
|
|
hi, my interrupts on change cant work, temp is always is zero...
input for
#define X_IN input(pin_b5)
#define Y_IN input(pin_b6)
is PWM, how to get it work?
compiler=v3.249
Code: | #include <16F917.h>
#device adc=8
#FUSES NOWDT //Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPUT //No Power Up Timer
#FUSES PROTECT //Code protected from reads
#FUSES MCLR //Master Clear pin enabled
#FUSES NOCPD //No EE protection
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NODEBUG //No Debug mode for ICD
#use delay(clock=4000000)
#use fast_io (B)
#define LCD_ON
#define X_IN input(pin_b5)
#define Y_IN input(pin_b6)
#define OUT_LED PIN_B3
#ZERO_RAM
INT1 start=0;
int8 cnt=0;
int16 temp=0,X_VAR=0,Y_VAR=0;
#int_RB
RB_isr()
{
temp=get_timer1(); clear_interrupt(int_RB);
}
#include "LCD1.c"
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_lcd(LCD_DISABLED);
setup_timer_0(RTCC_INTERNAL);//setup_wdt(WDT_DIV_512);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
set_tris_b (0b11110111);
enable_interrupts(GLOBAL);enable_interrupts(INT_RB);
setup_oscillator(OSC_4MHZ);
set_tris_a (0xff);
output_high(OUT_LED);
delay_ms(100);
output_low(OUT_LED);
lcd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"A sensor ");
while(1)
{
restart_wdt();
cnt++;
lcd_gotoxy(1,1);
Printf(lcd_putc,"GX=%lu T=%lu ",X_VAR,temp);
lcd_gotoxy(1,2);
printf(lcd_putc,"GY=%lu C=%u ",Y_VAR,cnt);
}//while
}//main |
|
|