PDA

View Full Version : Help Needed with DT Instant Interrupts



keithdoxey
- 18th May 2016, 23:47
Hi All.

Between 2001 and 2009 I did an awful lot of PBP programming and wrote many programs however one thing I didnt use was DT Instant Interrupts.

I returned to Pic Basic programming in late 2014. At that time I upgraded to PBP3 as I needed support for newer more powerful processors. The other day I tried to add Instant Interrupts to a fairly complex program I am working on and it just likked it dead. I decided to go for the basic principles first and have tried to do the Hello World, Blinky and Elapsed Timer demos to no avail.

I have tried using DT-INTS-18 with an 18F452 and DT-INTS-14 with a 16F877.

With the 18F452 I can get the program below to compile and my LED2 in the main loop will toggle every second (just as a heartbeat so that I know the program is running) but ONLY if I comment out the line @ INT_ENABLE TMR1_INT. If that line is uncommented it just seems to crash, I dont get my LED2 flashing once a second and the LED1 that is supposed to be toggled by the timer interrupt does nothing either.




'************************************************* ***************
'* Name : Instant Interrupts Test.BAS *
'* Author : Keith Doxey *
'* Notice : Copyright (c) 2016 Indigo Electronics *
'* : All Rights Reserved *
'* Date : 05/05/2016 *
'* Version : 1.0 18F452 *
'* : *
'************************************************* ***************


;----[18F452 Hardware Configuration]--------------------------------------------
#IF __PROCESSOR__ = "18F452"
#DEFINE MCU_FOUND 1
#CONFIG
CONFIG OSC = HS ; HS oscillator
CONFIG OSCS = OFF ; Oscillator system clock switch option is disabled (main oscillator is source)
CONFIG PWRT = OFF ; PWRT disabled
CONFIG BOR = ON ; Brown-out Reset enabled
CONFIG BORV = 20 ; VBOR set to 2.0V
CONFIG WDT = ON ; WDT enabled
CONFIG WDTPS = 128 ; 1:128
CONFIG CCP2MUX = ON ; CCP2 input/output is multiplexed with RC1
CONFIG STVR = ON ; Stack Full/Underflow will cause RESET
CONFIG LVP = OFF ; Low Voltage ICSP disabled
CONFIG DEBUG = OFF ; Background Debugger disabled. RB6 and RB7 configured as general purpose I/O pins.
CONFIG CP0 = OFF ; Block 0 (000200-001FFFh) not code protected
CONFIG CP1 = OFF ; Block 1 (002000-003FFFh) not code protected
CONFIG CP2 = OFF ; Block 2 (004000-005FFFh) not code protected
CONFIG CP3 = OFF ; Block 3 (006000-007FFFh) not code protected
CONFIG CPB = OFF ; Boot Block (000000-0001FFh) not code protected
CONFIG CPD = OFF ; Data EEPROM not code protected
CONFIG WRT0 = OFF ; Block 0 (000200-001FFFh) not write protected
CONFIG WRT1 = OFF ; Block 1 (002000-003FFFh) not write protected
CONFIG WRT2 = OFF ; Block 2 (004000-005FFFh) not write protected
CONFIG WRT3 = OFF ; Block 3 (006000-007FFFh) not write protected
CONFIG WRTC = OFF ; Configuration registers (300000-3000FFh) not write protected
CONFIG WRTB = OFF ; Boot Block (000000-0001FFh) not write protected
CONFIG WRTD = OFF ; Data EEPROM not write protected
CONFIG EBTR0 = OFF ; Block 0 (000200-001FFFh) not protected from Table Reads executed in other blocks
CONFIG EBTR1 = OFF ; Block 1 (002000-003FFFh) not protected from Table Reads executed in other blocks
CONFIG EBTR2 = OFF ; Block 2 (004000-005FFFh) not protected from Table Reads executed in other blocks
CONFIG EBTR3 = OFF ; Block 3 (006000-007FFFh) not protected from Table Reads executed in other blocks
CONFIG EBTRB = OFF ; Boot Block (000000-0001FFh) not protected from Table Reads executed in other blocks
#ENDCONFIG

#ENDIF

;----[Verify Configs have been specified for Selected Processor]----------------
; Note: Only include this routine once, after all #CONFIG blocks
#IFNDEF MCU_FOUND
#ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
#ENDIF



DEFINE OSC 40 ' 40MHZ crystal (10MHz + 4*PLL)

LED1 VAR PORTB.1
LED2 var PORTD.0

INCLUDE "DT_INTS-18.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP-18.bas" ' Include if using PBP interrupts

ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR1_INT, _ToggleLED1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM

T1CON = $31 ; Prescaler = 8, TMR1ON
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts

Main:
PAUSE 1000
toggle LED2
GOTO Main

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


I dont know if its because I havent set some things up first or if I have things in the wrong order but I am starting to tear my hair out.

The DT-INTS-14 version with the 16F877 wont even compile. I get the following errors....

ASM Error - Symbol not previously defined (wsave)
ASM Error - Symbol not previously defined (INT_ENTRY)
followed by a whole load more.

I have searched this forum and read many threads and also googled but still cant get it to work

What are the latest version of the DT INT files as all the ones I have found predate the launch of PBP. The 14 files are from a zip file V1.1 and the 18 files I have V3.3 and 3.4 both of which I have tried with the same unsuccessful results.

Sadly Darrel is no longer with us for me to pick his brains so I would be extremely grateful if someone could point me in the correct direction so that I can get everything working. The more I read about Instant Interrupts the more I want to use them.

Thanks in advance

richard
- 19th May 2016, 00:24
CONFIG OSC = HS ; HS oscillator ??? CONFIG OSC = HSPLL
DEFINE OSC 40 ' 40MHZ crystal (10MHz + 4*PLL)




ToggleLED1:
TOGGLE LED1
@ INT_RETURN

if you did manage to get a @ 40mHz lock then that's a 20 Hz flash rate , bit hard to see by eye

other than that it should be ok except for possible rmw issues

to eliminate the possibility of rmw




led1 var latb.1
trisb.1=0
'''''''''''''''''''''''''''''''

ToggleLED1:
LED1 = ! LED1
@ INT_RETURN

Acetronics2
- 19th May 2016, 08:31
Hi, Keith

looks your DT Ints files are not correctly installed in the folder where the .bas programs are...

the errors reported show the compiler/assembler didn't find them ...

the listing you provided compiles fine with MCSPX IDE ... so, the problem is in your PC.

Alain

Acetronics2
- 19th May 2016, 09:36
EDIT ...
DT Ints here in V3.4 ...

30 mins to edit posts is a pain !!!

Alain

keithdoxey
- 19th May 2016, 23:47
Thanks for the help guys.

I have sussed out the two issues that I had.

For the INTS-14 version on the 16F877 that wouldnt compile, the problem was highlighted in DT_INTS-14 itself. I should have read through the comments rather than just blindly following the examples on the web. I missed this very important bit of information......



;-- Place a copy of these variables in your Main program -------------------
;-- The compiler will tell you which lines to un-comment --
;-- Do Not un-comment these lines --
;---------------------------------------------------------------------------
;wsave VAR BYTE $20 SYSTEM ' location for W if in bank0
wsave VAR BYTE $70 SYSTEM ' alternate save location for W
' if using $70, comment wsave1-3

' --- IF any of these three lines cause an error ?? ------------------------
' Comment them out to fix the problem ----
' -- Which variables are needed, depends on the Chip you are using --
;wsave1 VAR BYTE $A0 SYSTEM ' location for W if in bank1
;wsave2 VAR BYTE $120 SYSTEM ' location for W if in bank2
;wsave3 VAR BYTE $1A0 SYSTEM ' location for W if in bank3
' --------------------------------------------------------------------------


The problem with the DT_INTS-18 version was also self inflicted. When I first tried to use them I got a compiler error saying that INTHAND wasnt defined.

I looked at the include file and saw the following.....



DEFINE INTHAND INT_ENTRY_H ' Context saving for High Priority Ints
DEFINE INTLHAND INT_ENTRY_L ' Context saving for Low Priority Ints


I saw that one was for low priority and one for high priority and assumed the first one should be INTHHAND so I edited the file. I didnt get the error anymore but it also crashed the whole program !!!

Anyway, putting that behind me, thanks to you guys for pointing me in the right direction. If I ever stop looking at these pretty toggling LEDs I will be attempting amazing feats with interrupts to make my programs run faster and smoother. :)