Foldesa
Junior Member level 1
18f452 resets touch
Hello !
I have a 18F452 on 4 mhz.
It uses 2 interrupts: timer and RB0 (external interrupt).
The code works until I start sending the impulses to RB0.
Then it resets. Otherwise not.
Here is the most simple test program I could wrote, but it still
has an error.
Can someone help ?
Here goes:
It's in pascal, but I hope someone finds a bug in it...
Thanx
András
Hello !
I have a 18F452 on 4 mhz.
It uses 2 interrupts: timer and RB0 (external interrupt).
The code works until I start sending the impulses to RB0.
Then it resets. Otherwise not.
Here is the most simple test program I could wrote, but it still
has an error.
Can someone help ?
Here goes:
Code:
program Teszt_int;
var
T1Count:byte;
procedure Interrupt;
begin
if testbit(PIR1,TMR1IE)=1 then
begin
T1Count:=T1Count+1;
if T1Count = 2 then
begin
T1Count := 0;
TMR1H := 23;
TMR1L := 184;
//1 second interrupt has occured
end;
end;
if testbit(intcon,int0If)=1 then
begin
//RB0 Int
end;
ClearBit(PIR1,TMR1IE);
clearbit(intcon,int0If);
end;
procedure init;
begin
intcon:=$00;
SetBit(intcon2, INTEDG0);
SetBit(intcon2, INTEDG1);
SetBit(intcon2, INTEDG2);
adcon1 := 255;
PORTA := 255;
TRISA := 255;
PORTB :=0;
TrisB :=0;
T1Count:=0;
ClearBit(PIE1, RCIE);
ClearBit(PIE1, TXIE);
SetBit(PIE1, TMR1IE);
setbit(intcon, gieh);
TMR1H := 23;
TMR1L := 184;
T1CON := $F9;
INTCON := $C0;
LCD_Init(PORTD);
lcd_cmd(LCD_CURSOR_OFF);
LCD_Out(1,1,'Start or Reset');
delay_ms(3000);
lcd_cmd(LCD_CLEAR);
end;
begin
init;
repeat
begin
LCD_Out(1,1,'Ok');
end;
until (0=1);
end.
It's in pascal, but I hope someone finds a bug in it...
Thanx
András