PDA

View Full Version : Can´t get DT´s interrupts working



Mugelpower
- 25th April 2010, 10:15
Hy guys.

I´m trying to build a little counter to count pulses of varying speed from nil to 120Hz.

YEEES it will be a tripmaster speedo someday.

Tried that with "count" and it works so far, but looses pulses of course and I need every, at least 99,9% of these.

So I tried to get into DTs interrupts and I´m falling on my face (hurts of course)

because I dunno where to start. Tried "Hello World", "Blinky Light", wont do.

So I thought its because of the missing definitions and tried some....wont do

all I get after compiling is the error:
ERROR: Variable wsave3 position request 416 beyond RAM_END 335.

I got Microcode studio 3.0.0.5, picbasic pro 2.50 C

heres my code (stolen from DT of course)


'************************************************* ***************
'* Name : ElapsedtimerDT1 *
'* Author : Darrel Taylor *
'* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 25.04.2010 *
'* Version : 1.0 *
'* Notes : 16F628A, 4mhz , don´t care about correct timing *
'* : *
'************************************************* ***************
'* Date : Jan 10, 2006 *
'* Notes : This is a simplistic demo of the Elapsed Timer *
'************************************************* **************
define LOADER_USED 1
define OSC 4

' Define LCD connections
DEFINE LCD_DREG PORTA ' LCD Data Port
DEFINE LCD_DBIT 0 ' Starting Data Bit
DEFINE LCD_RSREG PORTA ' Register Select Port
DEFINE LCD_RSBIT 4 ' Register Select Bit
DEFINE LCD_EREG PORTA ' Enable Port
DEFINE LCD_EBIT 5 ' Enable Bit
DEFINE LCD_BITS 4 ' Data Bus Size
DEFINE LCD_LINES 2 ' Number of Lines on LCD
ADCON1 = 7 ' Set portA outputs to Digital / No ADC
'CMCON = 7
LCDOUT $FE,1 ' Initialize LCD
PAUSE 200

include "DT_INTS-14.bas"
INCLUDE "ReEnterPBP.bas"
INCLUDE "Elapsed_INT.bas"

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

INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts
ENDASM

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
GOTO Main



maybe its about compiler version or something.

any suggestions beyond cry me a river?

regards Mugelpower

Acetronics2
- 25th April 2010, 10:59
Hi, MugelPower



ERROR: Variable wsave3 position request 416 beyond RAM_END 335.


the truth is here :



'************************************************* **************************
'* Name : DT_INTS-14.bas *
'* Author : Darrel Taylor *
'* Version : 1.00 BETA *
'* Date : OCT 13, 2009 *
'************************************************* **************************
'* REV 1.00 Completely re-written, with optimization and F1 chips in mind *
'* REV 0.93 Fixed CMIF and EEIF problem with older PIC's *
'* that have the Flags in PIR1 instead of PIR2 *
'* Rev 0.92 solves a "Missed Interrupt" and *
'* banking switching problem *
'************************************************* **************************
DEFINE DT_INTS_VERSION 100
DEFINE INTHAND INT_ENTRY

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 out wsave1-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


so, just comment this line out in your DT_ints.bas file ...



wsave3 VAR BYTE $1A0 SYSTEM ' location for W if in bank3


End of trouble ...

Alain

Mugelpower
- 25th April 2010, 11:43
I changed to 16F88 because of the 16bit timer i need later (or now)


now I get those errors:
Error C: \pbp\pbppic14.lib 1160 : [225]undefined symbol 'INT_ENTRY'
Error C: \pbp\pbppic14.lib 1162 : [225]undefined symbol 'INT_ENTRY'
Error : [212] extra tokens on end of line

Mugelpower
- 25th April 2010, 11:46
Man where do I get the newest version:

DT_INTS-14.bas version 1.0

????

regards

Mugelpower

ScaleRobotics
- 25th April 2010, 11:58
Man where do I get the newest version: DT_INTS-14.bas version 1.0


Here at bottom of page: http://darreltaylor.com/DT_INTS-14/intro2.html

ScaleRobotics
- 25th April 2010, 12:01
now I get those errors:
Error C: \pbp\pbppic14.lib 1160 : [225]undefined symbol 'INT_ENTRY'
Error C: \pbp\pbppic14.lib 1162 : [225]undefined symbol 'INT_ENTRY'
Error : [212] extra tokens on end of line

I get your errors if I do this:


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

INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts
ENDASM

Mugelpower
- 25th April 2010, 14:03
Hi Guys & Dolls,

got the DT program running but needed to implement a stupid LCD comment first!

otherwise the lcd shows only rubbish


'************************************************* *************** *
'* Notes : To use this example with MicroCode Studio, you *
'* : should: *
'* : PIC 16F88 4 MHZ crystal *
'* WORKS! ´ *
'************************************************* ***************





CMCON = 7 ' Disable analog comparator
ANSEL = %00000000 ' set all to digital

Include "modedefs.bas"


define OSC 4 ' this example uses a 4MHz clock

CMCON = 7 ' RA0-RA3 are digital I/O
TRISA = 0 ' PORT A is output
TRISB = 3 ' RB0 is Input count RB1 Input reset others output


Minute var byte ' Define minute variable
Second var byte ' Define second variable
Ticks var byte ' Define pieces of seconds variable
DoUpdate var byte ' Define variable to indicate update

clear ' clear all RAM (sets all VAR declarations to zero)
DoUpdate = 1 ' Force first display

OPTION_REG = %00000101 ' Set TMR0 configuration
INTCON = $A0 ' Enable TMR0 interrupts
On Interrupt Goto TickInterrupt

PAUSE 100
LCDOUT $FE,1,"Guten"
pause 2000
LCDOUT $FE,1,"Tag"
pause 2000

' Main program loop
MainLoop:
if DoUpdate then
LCDOUT $FE,1
LCDOUT $FE,1,DEC2 Minute, ":",DEC2 Second
DoUpdate = 0
endif
Goto MainLoop

' Interrupt routine to handle each timer tick
' Disable interrupts during interrupt handler
disable
TickInterrupt:
Ticks = Ticks + 1 ' Count pieces of seconds
If Ticks < 61 Then ExitInterrupt ' 61 ticks per second

' One second elasped - update time
Ticks = 0
Second = Second + 1
If Second >= 60 Then
Second = 0
Minute = Minute + 1
If Minute >= 60 Then
Minute = 0
endif
Endif
DoUpdate = 1 ' Set update

ExitInterrupt:
INTCON.2 = 0 ' Reset timer interrupt flag
Resume
end


this is a far cry from my goal but at least a big jump for me, an unbelievable small step for mankind, maybe a step back.....

ScaleRobotics
- 25th April 2010, 14:11
Hey Mulgepower, glad to hear it.

Remember to put your code in brackets like this but without the extra spaces...

[ code]
code goes here
[ /code]

so it is easier to read?

Thanks,

Walter