PDA

View Full Version : Problem with PBP interrupt and Serin, please help



rgregor
- 22nd August 2006, 20:02
Hello,
seems I have a strange behaviour of the serin command, when I am using tmr interrupt. Please see my code:

' Set TMR0 to interrupt every 16.384 milliseconds
OPTION_REG = $d5 ' Set TMR0 configuration
INTCON = $a0 ' Enable TMR0 interrupts
On Interrupt Goto tickint

Loop:
'doing something here - it is executed
Serin SERIN_BIT,SERIN_MODE,100,Loop, SERIALBYTE
debug "rcv: ",#second, 10
If SERIALBYTE = "1" then
' doing something here
endif
GoTo Loop

' Interrupt routine to handle each timer tick
disable interrupt
tickint:
ticks = ticks + 1 ' Count pieces of seconds
If ticks < 1758 Then tiexit

' One second elasped - update time
ticks = 0
second = second + 1
If second >= 60 Then
second = 0
end if
tiexit:
Resume
enable interrupt

The problem is, that the program never receive any data from the serin, and it always jump over the serin to my debug "rcv: ",#second, 10
so the output is something like:
rcv: 0
rcv: 0
rcv: 1
rcv: 1
rcv: 2
rcv: 2
.
.
.

The debugs should normally not happen, because if nothing is sent to serin within 100 ms, the program should jump to Loop and should not execute the debug. Another thing is, that even, if I sent something to the serial port, it is not accepted and the SERIALBYTE is always 0. When I remove the interrupt, the program works well. It is receiving the bytes from the serial port and everything is fine.
What I am doing wrong? By my mind, the interrupt happen in the serin command and PBP then doesn't return to the serin but to the line after. How to do it correctly???

Thanks Robert