PDA

View Full Version : Problems with instant interrupts from DT for pic18



dip1
- 31st October 2006, 18:23
Hello,Darrel,

I try Your example code for interrupt testing:

; Initialize your Hardware and LCD first
define osc 8


INCLUDE "DT_INTS-18.pbp" ; Base Interrupt System
INCLUDE "ReEnterPBP-18.pbp" ; Include if using PBP interrupts
'INCLUDE "Elapsed_INT-18.bas" ; Elapsed Timer Routines
LED1 VAR portd.6'pin29 PORTB.1
LED2 VAR portd.7'pin30 PORTB.2
trisd=0
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
; INT_Handler INT_INT, _ToggleLED1, PBP, yes
INT_Handler TMR0_INT, _ToggleLED2, PBP, yes
; INT_Handler TMR1_INT, _ClockCount, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM

T0CON = %10010010 ; T0 = 16-bit, Prescaler 8
'@ INT_ENABLE INT_INT ; enable external (INT) interrupts
@ INT_ENABLE TMR0_INT ; enable Timer 0 interrupts
'@ INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts

'GOSUB ResetTime ; Reset Time to 0d-00:00:00.00
'GOSUB StartTimer ; Start the Elapsed Timer

Main:
' IF SecondsChanged = 1 THEN
' SecondsChanged = 0
' LCDOUT $FE,$C0, DEC Days,"d-",DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds
' ENDIF
pause 2000'2 sec
toggle led1
GOTO Main

';---[INT - interrupt handler]---------------------------------------------------
'ToggleLED1:
' TOGGLE LED1
'@ INT_RETURN

;---[TMR0 - interrupt handler]-------------------------------(Blinky Light)------
ToggleLED2:
TOGGLE LED2
@ INT_RETURN

end

1. It is Your code with small corrections
When I used "pause 2000" and only one int (toggle led2) and try to toggle
led1 in main program for control main loop, led2 toggled ok (0,5 sec period), but led1 not toggled.
When I used pause 2(2 ms) result is : led1 not toggled in main loop.
I used pic18f4580 8 mHz and microcode studio2.3.00, pbp2.46

2.When I try to compile this code , I have error: "ReEnterPBP-18.pbp"
"Elapsed_INT-18.bas" not found. When I change BAS to PBP it is OK.
Why?
Please, help.

3.And when I disabled all interrupts and try only main loop - led1 in main loop is toggled OK!!!!
(2 sec period)
I think, this is the bug in soft, because pause 2000 - 2 sec pause is interrupted by
INT_Handler TMR0_INT and main loop not worked ok (return address not ok?).


dipdip
Thanks

Darrel Taylor
- 1st November 2006, 03:11
I compiled and ran your modification on an 18F452, and everything was fine.

Except that it was running at the wrong speed because the "osc" wasn't capitalized. changed it to...

DEFINE OSC 8


2.When I try to compile this code , I have error: "ReEnterPBP-18.pbp"
"Elapsed_INT-18.bas" not found. When I change BAS to PBP it is OK.
Why?
Please, help.


Browsers and webservers don't like files with a .bas extension, so on the website they are given a .txt extension to allow easy download. It's up to you to rename it to something usable such as .bas or .pbp. Then you have to use the same extention in your INCLUDE statements.