PDA

View Full Version : Interrupt problems!



amindzo
- 2nd November 2006, 18:58
Hi,
i found that interrupt in pic basic works in small programs but in big programs it doesn't work especially in programs that use alot of if sentences.for example , scanning keyboard with polling method(using if sentences) interrupt doesn't work. i wanted to scan keyboard and when serial data is coming the program goes to taking serial information and then goes back to scanning keyboard but it didn't work.but when i use this interrupt with other programs (in programs that we don't have scanning keyboard) it works. so i want to know that do you agree with me or my idea is wrong?

mister_e
- 3rd November 2006, 04:19
Wrong if your program take care a little bit and don't have too much PAUSE or else command that need time to execute.

There's no real problem with IF, FOR, WHile, etc

There's some problem with LCDOUT,PAUSE, PAUSEUS, ADCIN, COUNT, PWM, etc etc

Melanie
- 3rd November 2006, 09:26
There is no problem with PBP Interrupts in any program be it small or large.

You will have remembered (if you read the PBP documentation) that in PICBasic a jump to interrupt (ON INTERRUPT command) is only executed AFTER the current PICBASIC command has completed. So, for example, if an interrupt occurs at the start of say a PAUSE 5000 command, the jump to interrupt will not occur for almost FIVE SECONDS!! Some PBP instructions take a long time to complete, and those should be avoided if you are waiting for an interrupt which needs to be serviced quickly.

amindzo
- 3rd November 2006, 10:42
Hi,
i know about pause so when i wanted to make a 5sec delay i use this method:
for i=1 to 5000
pause 1
next i

but about lcdout, my program had alot of lcdout and also it had adcon too.maby this is the problem.

mister_e
- 3rd November 2006, 14:55
Pause 1 is still fair but i would use a loop of PAUSEUS 10 OR use an internal Timer and a loop... but it's just me :D

LCDOUT could slow down a little bit, it will depend how much data you send. But it certainely don't need seconds to finish. Personnally i use internal, external eeprom to store the texts string, so i send i character at the time. Still faster and may avoid some interrupt latency.

OR you may decide to use a variant of 'Embedded string in your codespace'

There's some days like that where asm interrupt or instants interrupts are handy.

Without your whole code it's hard to spot the problem(s)