PDA

View Full Version : DT Instant Interrupts - Clarification?



Aussie Barry
- 5th July 2011, 05:46
Hi All,

I am preparing to tackle my first project using interrupts and have been looking at Darrel's Instant Interrupts. The link I have is for DT_INST-18 Ver 3.3 but the web page says this is for use with PIC18F's. I intend to use a PIC12F683 or PIC12F1822 for my project. Am I correct in assuming that DT_INST-18 cannot be used on these devices? If so, is there another version which can be used?

Cheers
Barry

HenrikOlsson
- 5th July 2011, 06:13
That is correct, there are two versions - one (DT_INTS-18) for PIC18 and one (DT_INTS-14) for PIC12 and 16. See here (http://www.pbpgroup.com/modules/wfsection/article.php?articleid=19) for more details.

Aussie Barry
- 7th July 2011, 10:55
Hmmm.... it would appear that DT_INST-14 doesn't work with PIC12F683
I downloaded Ver 1.1 of the application and trialed the "Hello World" program from Darrel's website.
I made the necessary change from PORTB.1 to GPIO.1 for the LED1 variable but got a host of errors when compiling:

Error[101] DT_INTS-14 TEST.ASM 235 : ERROR: (wsave variable not found,)
Error[101] DT_INTS-14 TEST.ASM 201 : ERROR: (" Add:" wsave VAR BYTE $20 SYSTEM)
Error[101] DT_INTS-14 TEST.ASM 256 : ERROR: (Chip has RAM in BANK1, but wsave1 was not found.)
Error[101] DT_INTS-14 TEST.ASM 208 : ERROR: (" Add:" wsave1 VAR BYTE $A0 SYSTEM)


Should I be able to do this with a PIC12F683?
Can anyone provide some input to this problem?

I have attached a copy of the full code for review.

Cheers
Barry

mackrackit
- 7th July 2011, 11:15
The cool thing is the answer is in the error message.


Error[101] DT_INTS-14 TEST.ASM 235 : ERROR: (wsave variable not found,)
Error[101] DT_INTS-14 TEST.ASM 201 : ERROR: (" Add:" wsave VAR BYTE $20 SYSTEM)

So..
Put
wsave VAR BYTE $20 SYSTEM
in your code's variable section.

Aussie Barry
- 7th July 2011, 12:19
Thanks Dave.

I have added the two variables wsave and wsave1 as specified in DT_INST-14.bas
I now have more errors at compilation:

Executing: "C:\PBP\PBPMPLAB.BAT" -ampasmwin -k# -p12F683 "DT_INTS-14 Test.bas"
Executing: "C:\PBP\PBPW.EXE" -ampasmwin -k# -p12F683 "DT_INTS-14 Test.bas"
PICBASIC PRO(TM) Compiler 2.60C, (c) 1998, 2011 microEngineering Labs, Inc.
All Rights Reserved.
Executing: "C:\PBP\PBPMPLAB.BAT" -ampasmwin -k# -p12F683 "DT_INTS-14.bas"
Executing: "C:\PBP\PBPW.EXE" -ampasmwin -k# -p12F683 "DT_INTS-14.bas"
PICBASIC PRO(TM) Compiler 2.60C, (c) 1998, 2011 microEngineering Labs, Inc.
All Rights Reserved.
ERROR: Unable to execute mpasmwin.Error[113] C:\PBP\PBPPIC14.LIB 1165 : Symbol not previously defined (INT_ENTRY)
Error[101] C:\PBP\PROJECTS\DT_INTS-14 TEST\DT_INTS-14.ASM 187 : ERROR: (wsave variable not found,)
Error[101] C:\PBP\PROJECTS\DT_INTS-14 TEST\DT_INTS-14.ASM 153 : ERROR: (" Add:" wsave VAR BYTE $20 SYSTEM)
Error[101] C:\PBP\PROJECTS\DT_INTS-14 TEST\DT_INTS-14.ASM 208 : ERROR: (Chip has RAM in BANK1, but wsave1 was not found.)
Error[101] C:\PBP\PROJECTS\DT_INTS-14 TEST\DT_INTS-14.ASM 160 : ERROR: (" Add:" wsave1 VAR BYTE $A0 SYSTEM)
Halting build on first failure as requested.

Any clues here?

Again, I have attached a copy of my main code for review.

Cheers
Barry

Darrel Taylor
- 7th July 2011, 15:06
It's trying to compile both your source file and the include file separately.
Remove DT_INTS-14.bas from the "Source Files".

You should only have your main program in the source files list of MPLAB.

Aussie Barry
- 8th July 2011, 00:35
Thanks Darrel - that did the trick.

Now that I have the simple things sorted it is onwards and upwards to bigger and better phases of my project.

Cheers
Barry

Aussie Barry
- 8th July 2011, 02:49
OK, I have now tried to implement the DT_INST-14 routines into my main project code. The attached code file has sufficient comments to explain what it is doing.

I am getting the following errors when I try to compile the program:

Executing: "C:\PBP\PBPMPLAB.BAT" -ampasmwin -k- -p12F683 "PICSprayer.bas"
Executing: "C:\PBP\PBPW.EXE" -ampasmwin -k- -p12F683 "PICSprayer.bas"
PICBASIC PRO(TM) Compiler 2.60C, (c) 1998, 2011 microEngineering Labs, Inc.
All Rights Reserved.
ERROR: Unable to execute mpasmwin.Error[127] C:\PBP\PROJECTS\PIC SPRAYER\PICSPRAYER.ASM 912 : Too many arguments
Error[128] C:\PBP\PROJECTS\PIC SPRAYER\PICSPRAYER.ASM 473 : Missing argument(s)
Halting build on first failure as requested.
BUILD FAILED: Fri Jul 08 11:35:51 2011

My code compiles properly without the interrupt routine for the manual switch operation. Now I just don't know where to start looking to fix these errors.

Any help would be greatly appreciated.

Cheers
Barry
5752
5751

mackrackit
- 8th July 2011, 11:26
Please post your code using code tags.

Bruce
- 8th July 2011, 11:26
You don't need to place these in your code;


wsave VAR BYTE $20 SYSTEM
wsave1 VAR BYTE $A0 SYSTEM

Just uncomment them in your DT_INTS-14.bas file.

For assembly you need to use the ; for comments. INT_LIST macro should look like this;


INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _ManualSwitch, PBP, yes
endm
INT_CREATE ; Creates the Interrupt Processor
ENDASM
@ INT_ENABLE INT_INT ; Enable external (INT) interrupts

gadelhas
- 8th July 2011, 11:33
OK, I have now tried to implement the DT_INST-14 routines into my main project code. The attached code file has sufficient comments to explain what it is doing.

I am getting the following errors when I try to compile the program:

Executing: "C:\PBP\PBPMPLAB.BAT" -ampasmwin -k- -p12F683 "PICSprayer.bas"
Executing: "C:\PBP\PBPW.EXE" -ampasmwin -k- -p12F683 "PICSprayer.bas"
PICBASIC PRO(TM) Compiler 2.60C, (c) 1998, 2011 microEngineering Labs, Inc.
All Rights Reserved.
ERROR: Unable to execute mpasmwin.Error[127] C:\PBP\PROJECTS\PIC SPRAYER\PICSPRAYER.ASM 912 : Too many arguments
Error[128] C:\PBP\PROJECTS\PIC SPRAYER\PICSPRAYER.ASM 473 : Missing argument(s)
Halting build on first failure as requested.
BUILD FAILED: Fri Jul 08 11:35:51 2011

My code compiles properly without the interrupt routine for the manual switch operation. Now I just don't know where to start looking to fix these errors.

Any help would be greatly appreciated.

Cheers
Barry
5752
5751

Please replace your interrupt routine by code by this one, and post your results;



ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _ManualSwitch, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor

INT_ENABLE INT_INT ; Enable
ENDASM



EDIT: Bruce was faster than me...

Aussie Barry
- 8th July 2011, 12:34
Thanks Bruce and Gadelhas.
I have made the recommended changes and am pleased to advise that it now compiles correctly.
Now to fire it up on the breadboard to see if it works as expected.

Dave, I do no understand your comment regarding the use of code tags. Can you explain further or direct me to somewhere that will outline what I am not doing?

Cheers
Barry

Aussie Barry
- 8th July 2011, 13:51
Hi All,

I am pleased to announce that the external interrupt routine is now working properly. Thank you to all who have helped me resolve my problems - much appreciated :)

To aid in my PCB layout I would like to move my ADC channels to AN1 and AN2. This will mean that I need to alter the type of interrupt from an external interrupt on GP2 to a Change on Interrupt on GP4. To do this I have changed the Interrupt Handler in DT_INST-14 from INT_INT to GPC_INT, Enable GPC_INT and enabled bit 4 of the Interrupt-On-Change GPIO Register (ie IOC.4=1). My interrupt switch is set up with a 10k pull-up resistor from GP4 to +5V and a momentary action switch from GP4 to 0V. The code compiles without error but the change on interrupt function does not work in "the real world".

I would have thought this was a pretty straight forward change but I am obviously missing something important. Would someone please direct me to where I have gone wrong?

Cheers
Barry

HenrikOlsson
- 8th July 2011, 16:16
Hi Barry,
In your latest attached code you have the line

ANSEL = %01011010 ' Set Fosc/16
Which sets GPIO.4/AN3 to analog mode. Try changing it to digital if you haven't already done that.

Aussie Barry
- 8th July 2011, 23:30
Hi Henrik,

Yes, I had already changed the ANSEL register
I had changed the TRISIO register too.
Attached is my full code listing for reference.

Now what? I am sure it is only something simple but I just can't figure it out...5753

Cheers
Barry

mackrackit
- 9th July 2011, 00:12
[ code] remove the spaces in the brackets [ /code]

remove the spaces in the brackets
It will save folks from having to download your code to look at it.

cncmachineguy
- 9th July 2011, 00:26
Unless I am not following your changes right, It seems in your ISR you are still waiting while gpio.2 is high. since that is now an analog input (I think) it might just be zooming right through the ISR making it look as though it was never called.

Aussie Barry
- 9th July 2011, 01:34
Yes, it was the GPOI.2 statement in the ISR that was causing the problem. :o
All fixed now :)



This is a Code Space Test


Hey, I even got the code space thing happening - I'm on fire!!!

Thanks for all your help guys - really appreciate it.
I will post details of the final project once it is all up and running - code, circuit diagram, PCB and some pretty pictures of the finished product.

Cheers
Barry

retepsnikrep
- 11th July 2011, 02:33
Just continuing on from this thread i have my own question about DT Interrupts for the 12F683.

Having looked at the example given by darrell for the generic timer the code below seems unecessary if we know what the values are for the prescaler etc?



;---[TMR1 reload - interrupt handler]-----------------------------------------
ASM ; Calculate Timer Reload Constant
ReloadInst = 8; # of Intructions used to reload timer
if ((Prescaler == 1)||(Prescaler == 2)||(Prescaler == 4)||(Prescaler == 8))
MaxCount = 65536 + (ReloadInst / Prescaler)
TimerReload = MaxCount - (OSC*1000000/4/Prescaler/Freq)
if ((TimerReload < 0) || (TimerReload > (65535-ReloadInst)))
error Invalid Timer Values - check "OSC", "Freq" and "Prescaler"
endif
else
error Invalid Prescaler
endif
ENDASM


Do we need this error checking if we know and are happy with osc/prescaler/freq etc or am i missing something else. It looks like it might take a fair bit of code space?

mister_e
- 11th July 2011, 03:25
That snip perform calculations at compilation time and doesn't take ANY codespace. 'course you can remove it. It's there for convenience and ease of use.

longpole001
- 26th July 2012, 05:24
Hi guys ,

although this thread is old , it has been helpful in me understanding some of the setup and use of DT instant interrupts , as well as using IOC setting in the 12F683

I do have a question on using IOC and DT_interupt,bas

If the pin for the interrupt is used both as input as well as output , do i need to change anything in setting on the IOC pin (IOC.4=1 - set interupt on change from high on gp4 ) or within DT interrupt.bas when the GPIO its set to output

do i need to turn off or to stop the interrupt routine being called incorrectly if pin is then set to output

Or is the IOC and DT interrupt routines only applicable when its GPIO is an input

regards

Sheldon

DavidK
- 26th December 2013, 11:24
It has been awhile since I used "instant interrupts." All my projects are working fine. Last summer I upgraded to PBP 3.0. When I went to load "Instant Interrupts" today the text file says install in the directory where "PBPW.exe" exists; it is not there anymore. I see "PBPX.exe" under C:\PB3 directory; is that the replacement for PBPW.exe ??

I did search of the forum but could not find anything on the subject. Sorry, for asking a dumb question but I am a little rusty these days!

Ioannis
- 26th December 2013, 12:45
PBPX is the new executable. It runs in normal mode or with the switch -n in LONG (variable) mode.

Ioannis