PDA

View Full Version : Instant Interupts with a 12f675



wlundonly
- 23rd January 2008, 09:47
Hi all, I've been trying to get Darrel Taylor's Instant interrupts to work with a 12f675 with no luck. Will they work with a 12f675?

I just get the following error message when I try to compile it:

ERROR: Variable wsave3 position request 416 beyond RAM_END 95.
ERROR: Variable wsave2 position request 288 beyond RAM_END 95.
ERROR: Variable wsave1 position request 160 beyond RAM_END 95.
ERROR: Unable to fit variable RS2_Save



Here is the code I am using:


LED1 VAR GPIO.1

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

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

INT_ENABLE INT_INT ; enable external (INT) interrupts
ENDASM

Main:
PAUSE 1
GOTO Main

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

Thanks for any help.

Bill

Acetronics2
- 23rd January 2008, 13:48
Hi,

Instant interrupts need some ( let's say ...much ) room.

So, If It's possible ( the resume line MUST be known ...) try this :




'INTTEST

DEFINE INTHAND _ToggleLED1
DEFINE OSCCAL_1K 1

LED1 VAR GPIO.1

ADCON0 = 0
ANSEL = 0
CMCON = 7
VRCON = 0

T1CON = %00110001
INTCON = %11000000
PIE1 = %00000001
TRISIO = %000000
GPIO = 0



Main:
While 1
WEND

END

'---[INT - interrupt handler]---------------------------------------------------
ToggleLED1:

TOGGLE LED1
PIR1.0 = 0
RESUME Main




A bit " off the Manual " ... but doesn't need room ... nor assembler !!!

And it is even faster than " Instant " interrupts ... ( assembler speed !!! no more ...)

Alain

Darrel Taylor
- 23rd January 2008, 21:43
Alain,

That's a dangerous way to do things.

It might blink an LED. But don't try to do anything else with it.
With the 12F675 being a 1K device, PBP doesn't even put the Context Stub in there.
Not that it would matter, because RESUME wouldn't restore it anyway.
WREG, STATUS, PCLATH all get lost. And any statement that gets interrupted, will stop doing whatever it was doing in mid-stream, it never returns to the original interrupt point.

If you really don't want Instant Interrupts, use ON INTERRUPT, or ASM interrupts.
Definitely DO NOT RESUME from an ASM type interrupt.<hr>

Hi all, I've been trying to get Darrel Taylor's Instant interrupts to work with a 12f675 with no luck. Will they work with a 12f675?
Hi Bill,

How's the Asparagus treating you?

Yes they will work, but depending on what you need to do, they may not be the optimal solution on such a small chip.

To use Basic Language interrupts with ReEnterPBP, it doesn't leave much RAM for the main program. It has to save EVERY PBP system variable, so it uses double the normal amount that PBP would use. PBP uses about 26 bytes, so ReEnterPBP needs another 26, plus a place to put the WREG, STATUS, PCLATH and any Temp(T?) vars that PBP creates for complex formulas. With only 64bytes of RAM, at best you will only be left with about 8 bytes for the main program to use.

DT_INTS-14 will work fine with Assembly language interrupts on a 675 because it only needs about 8 bytes, so there's no problem when it comes to ASM interrupts.

To get Instant interrupts with Basic Language working on a 12F675 ...

Open the DT_INTS-14.bas file and comment out the wsave lines. The 675 doesn't have any usable RAM in banks 1,2 or 3
' --- IF any of these three lines cause an error ?? ----------------------------
' Comment them out to fix the problem ----
' -- It depends on which Chip you are using, as to which variables are needed --
;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
' ------------------------------------------------------------------------------


Then in the ReEnterPBP.bas file comment the T?_save variables.
; T1_Save VAR WORD
; T2_Save VAR WORD
; T3_Save VAR WORD
; T4_Save VAR WORD


Just remember that if you use Instant Interrupts on a different chip later, you will need to un-comment those lines.

HTH,

Darrel Taylor
- 24th January 2008, 00:59
Bill,

I should also add, that there are many things you can do at the ASM level, that still use Basic Language statements. The only difference being, you can only use statements that don't use PBP system variables.

For instance, the original program will work perfect on a 12F675 if you remove the ReEnterPBP.bas include file, and change the interrupt "Type" to ASM. (comment wsave's too) Then there will be plenty of RAM left for the main program
LED1 VAR GPIO.1

INCLUDE "DT_INTS-14.bas" ' Base Interrupt System

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

INT_ENABLE INT_INT ; enable external (INT) interrupts
ENDASM

Main:
PAUSE 1
GOTO Main

'---[INT - interrupt handler]---------------------------------------------------
ToggleLED1:
TOGGLE LED1
@ INT_RETURN
It works because the TOGGLE statement doesn't use any PBP system variables.

You can toggle or set the state of any pins ...
Assign values to variables A = B, as long as they're not array's.
Add or subtract variables. But not mult/divide, and no complex formulas.

You can use IF = THEN's, as long as you don't use AND/OR with multiple conditions.

Some day I'll make a full list, but if there's something specific you need to do, I'll help weed out the things that won't work.

I'm positive DT_INTS can do what you're looking for.
<br>

wlundonly
- 24th January 2008, 01:25
Thanks Ace, for the quick reply.

Darrel...LOL... To see movies of the harvester running visit www.asparagusharvester.com or search on you-tube for wlundonly. That sucker has something like 40 pic chips in it! Mostly 12F675's and a 18F4550 I think. Worked great....and I was out in the field programming them with my laptop. Was great fun.

So now I've got this new project that I am trying to figure out...I'm in the early stages. I need to make a programmable alarm clock...that is actually a controller for a pump. So it sounds to me like I need a bigger chip...much bigger.

I think I'll look for one that has enough I/O pins to drive an LCD display since I'll need one of those.

Thanks for the help...don't worry...I'll be needing more. I managed to struggle through the harvester pic programming and a few other projects, but now that I have overcome my fear of posting maybe I'll be looking for help more often.

Bill

Darrel Taylor
- 24th January 2008, 01:44
To see movies of the harvester running visit www.asparagusharvester.com or search on you-tube for wlundonly.

Oh look at that, working flawlessly I see, picken the ripe one's and leaving the rest.
Very nice!


So now I've got this new project that I am trying to figure out...I'm in the early stages. I need to make a programmable alarm clock...that is actually a controller for a pump. So it sounds to me like I need a bigger chip...much bigger.

I think I'll look for one that has enough I/O pins to drive an LCD display since I'll need one of those.
Oh, I don't know about that.
The 675 has enough stuff on it to do all that.
Done it with a 629 actually.

Sure, there's a lack of pins for the LCD, but I got a fix for that too.

But with that said. It really would be easier on a bigger chip. :)


Thanks for the help...don't worry...I'll be needing more. ...
We'll be here.

CYA,

Acetronics2
- 24th January 2008, 09:34
Alain,

That's a dangerous way to do things.



Hi, Darrel

Not Dangerous ... those are interrupts of the third type : When the input turns previous things obsolete !!!
It's not forbidden to keep an eye on the MPLABs Program window to look at what is really supposed to happen ... ( ! )

That's why you have to specify WHERE to resume ( a pbp interrupts option ...) and update ( left aside ) calculations.

----- ---------------------------


[/code]

Then in the ReEnterPBP.bas file comment the T?_save variables.
; T1_Save VAR WORD
; T2_Save VAR WORD
; T3_Save VAR WORD
; T4_Save VAR WORD


Just remember that if you use Instant Interrupts on a different chip later, you will need to un-comment those lines.



I do not remember having read something ( T_Save values ... ) could be commented in the ReEnterPBP.bas files ...
Did I miss something from your memories ???

Alain

Darrel Taylor
- 24th January 2008, 21:56
Not Dangerous ... those are interrupts of the third type : When the input turns previous things obsolete !!!
The Dangerous part is showing people how to do it, without a full explanation of what's going on.
The possibilities of disaster are endless for the typical newb around here.

Maybe with a "Code Examples" post giving details of what can go wrong, and how to avoid them ... But just "Here, try this", is going to give people some major heartburn and hair loss.


I do not remember having read something ( T_Save values ... ) could be commented in the ReEnterPBP.bas files ...
Did I miss something from your memories ???

I've mentioned it before for a 12F629.
23773

It removes the ability to use complex formulas in the ISR.
But typically, the ISR doesn't need them anyhow.

And it's the only way to fit it all in the 629/675.

The 12F683 is really a better choice, with 128 bytes RAM, there's No Problem.
<br>

wlundonly
- 25th January 2008, 01:27
So Darrel,

I'm trying to decide what chip to use and thought maybe you could suggest a chip....there are so many....

Every time I use a new PIC chip I fall in love all over again....

I'm looking for a low-cost, easy to obtain in quantity, chip to use in my timer/controller.

I want the controller to send out a signal containing two 8-bit bytes to an RF transmitter.

The controller could be programed to send the signal out at pre-programed times, say a maximum of 12 times in 24 hours.

The chip would need to comunicate to the user via an LCD.

The chip would also be hooked to an RF receiver and receive a couple of bites from the controlled device, which it would then display on the LCD.

I want it to be easy to program, so I was thinking if I should have a few pins dedicated to the clock and alarm/setting functions.

I haven't really looked into displays yet so I'm not sure how many pins one needs for that. I'm thinking if I used a 14 pin chip I should have plenty of input/output pins.

It is going to be battery powered.

Any suggestions?

Thanks,
Bill

Darrel Taylor
- 25th January 2008, 02:11
<Pre>LCD 6<br>TX/RX radio 2<br>Buttons 3-8 (depending)<br>Crystal 2 (serial comms)<br> ---<br> 13-18 pins</pre>

14-pin devices can only have 12 I/O's at best.

And being battery operated, it might be better to use an LF device.
I think the smallest of those is 18-pin, like the 16LF628A. Works down to 2 volts @ 4mhz.
But they cost a little more.

Like you say, there's a lot to choose from. And it's better to have a few extra pins for whatever comes up, instead of changing to a bigger PIC later.

wlundonly
- 25th January 2008, 02:44
Darrel,

I can't find that part...are you sure about the part number?

Thanks,

Bill

Darrel Taylor
- 25th January 2008, 03:43
It's strange that a search doesn't pull up anything on the microchip site, but it doesn't.

The info for the LF version is in the same datasheet as the F version.

From Digikey ...
http://search.digikey.com/scripts/DkSearch/dksus.dll?lang=en&site=US&keywords=16LF628A
<br>

wlundonly
- 26th January 2008, 01:52
Thanks Darrel.

I'm going to use the 16LF628A.

Let's see how far I get before I get stumped. LOL