PDA

View Full Version : DT Instant Interrupt counting



jderson
- 9th March 2008, 04:49
I am trying to use 16f689 to count the number of events ocurring on RA2. Since I don't know when the "events" will occur, I need to use interrupts. I think Darrel Taylor's Instant Interrupts will be perfect for this. While trying to compile the code below, I get the following error message:

ERROR: Variable wsave3 position request 416 beyond RAM_END 367.


@ DEVICE pic16f689,wdt_off
TRISC = %00000000
TRISA = %000100
TRISB = %0000

Include "modedefs.bas"
INCLUDE "DT_INTS-14.bas" 'Darrel Taylor's instant interrupts
INCLUDE "ReEnterPBP.bas" 'Darrel Taylor's re-entry for PBP routines

GIE VAR INTCON.7 'GLOBAL INTERRUPTS ENABLE
PEIE VAR INTCON.6 'PERIPHERAL INTERRUPT ENABLE
INTE VAR INTCON.4 'RA2/INT EXTERNAL INTERRUPT ENANBLE
INTF VAR INTCON.1 'RA2INT FLAG BIT

B VAR PORTA.2

VALUE VAR WORD
VALUE=0

'***** SETUP INTERRUPTS *****
GIE=1 'ENABLE GLOBAL INTS
PEIE=1 'ENABLE PERIPHERAL INTS
INTE=1 'ENABLE RA2 EXTERNAL INTS

Define LCD_DREG PORTC 'Set LCD data port
DEFINE LCD_DBIT 0 'Set LCD starting data bit
DEFINE LCD_RSREG PORTC 'Set LCD register select port
DEFINE LCD_RSBIT 4 'Set LCD register select bit
DEFINE LCD_EREG PORTC 'Set LCD enable port
DEFINE LCD_EBIT 5 'Set LCD enable bit
DEFINE LCD_BITS 4 'Set LCD bus size
DEFINE LCD_LINES 2 'Set LCD number of lines

'**** INITIALISE INSTANT INTERRUPTS ***********
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _ROUTINE, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM

@ INT_ENABLE INT_INT ;Enable external interrupts

'****** MAIN PROGRAM ********************************************
'============== INTERRUPT ROUTINE ==============================
ROUTINE:

VALUE = VALUE+1
IF VALUE < 1000 THEN GOTO ROUTINE

GOSUB LCD

@ INT_RETURN
'================================================= =========================
LCD:
lcdout $FE,1,DEC VALUE 'SHOW VALUE ON DISPLAY
RETURN
'================================================= =========================

END

Can someone help, please? Thank you!

Archangel
- 9th March 2008, 05:00
ERROR: Variable wsave3 position request 416 beyond RAM_END 367.



Can someone help, please? Thank you!
I will try, not every chip has that address available. Open Darrels code and insert a semicolon just before the call to WSAVE3, he gives you instructions in the comments above that.

jderson
- 9th March 2008, 15:37
Thanks Joe. I commented out the offending line, and also the "T" line in the "Reenter" program. It now tries to assemble, but comes back saying "unknown processor 16f689". I removed the line at the top of my program about the WDT, but it still does the same thing. How does it know I'm using a 16f689?

Archangel
- 9th March 2008, 18:28
Thanks Joe. I commented out the offending line, and also the "T" line in the "Reenter" program. It now tries to assemble, but comes back saying "unknown processor 16f689". I removed the line at the top of my program about the WDT, but it still does the same thing. How does it know I'm using a 16f689?
Because you selected that processor in Microcode Studio, up at the top. When it compiles it includes the appropriate files for that processor. Oh and this too @ DEVICE pic16f689,wdt_off,
Note: you must use the MPASM assembler with Darrel's includes.

jderson
- 9th March 2008, 18:38
I removed the @DEVICE line, and I have MPASM enabled. It is MPASM that is generating the errors. I think the problem has to do with where all of the various components are located, relative to one another. (MPASM can't find the P16F689.INC file) I'm still reading.

Archangel
- 9th March 2008, 18:43
Try this for your config statement:
@__CONFIG _HS_OSC & _WDT_OFF & _PWRTE_ON & _LVP_OFF & _BODEN_OFF

jderson
- 9th March 2008, 19:00
Thanks for trying Joe, but that didn't do it. I think there's something fundamentally wrong, as the compiler doesn't know about 16f689.

Archangel
- 9th March 2008, 19:16
Thanks for trying Joe, but that didn't do it. I think there's something fundamentally wrong, as the compiler doesn't know about 16f689.I don.t know what version you are using, look into your PBP directory and see if you have a file16F689.inc, also see if the code compiles with a similar chip. OK here is the data sheet:http://ww1.microchip.com/downloads/en/DeviceDoc/41262B.pdf

jderson
- 9th March 2008, 20:42
Yes, the file is there. And I already have 2 copies of the data sheet, thank you!
Here are the first three error messages:

Error [132]c:\pbp\16f689.inc 20: Unknown processor (16f689)
Message [301] c:\progra~1\mecani~\mcs\p16f689.inc 32: MESSAGE: (Processor header file mismatch. Verify selected processor.)
Error [131]c:\pbp\16f689.inc 22: Processor type is undefined.

Many more errors.

skimask
- 9th March 2008, 22:29
PBP version?
MPLAB version?
MCS version?

Darrel Taylor
- 9th March 2008, 22:39
If you have installed the latest version of MPLAB,
the MPASM files should be located in the C:\program files\microchip\mpasm suite folder.

Sometimes the Find Automatically button doesn't find the correct folder.

In MCS, go to the View | Compile and Program Options | Assembler Tab

Click the Find Manually ... button and point it to
C:\program files\microchip\mpasm suite

Then check the Use MPASM checkbox.

jderson
- 9th March 2008, 22:39
PBP v 2.50A
MPASM v 02.15
MCS v 3.0.0.5

jderson
- 9th March 2008, 22:47
Darrel- Thank you, that fixed the compiling problem!