PDA

View Full Version : Instant Interrupts and STRINGS-16.PBP in the same program



ronjodu
- 5th January 2007, 23:38
Hello all! Hope everyone had a good Holiday. My question is, can I use Instant Interrupts DT_INTS-18, ReEnterPBP-18 and STRINGS-16 in the same program. I've tried a few times and get several errors.

symbol not previously defined.(INT_ENTRY_H)
Found call to Macro in column 1.(GetAddress)
Duplicate Macro name. (GetAddress)
1003:symbol not previously defined.(Label)
1004:symbol not previously defined.(Wout)
1005:symbol not previously defined.(Label)
1006:symbol not previously defined.(Wout)
1007:unmatched ENDM

Instant Interrupts works great on it's own (blinks an LED) and STRINGS works great on it's own (Hello World and It's Me!) on an LCD, however combined I can't get it to compile without errors.

MCSP 2.3, PBP 2.45A, MPASM, and Microcode Loader with an 18F2525 @ 20 MHZ

As always thanks for any help in my up-hill battle thru this learning curve.

Darrel Taylor
- 6th January 2007, 00:33
As far as I know, they should work together.

Those don't look like MPASM error messages, are you sure you have MPASM selected as the assembler?
<br>

ronjodu
- 6th January 2007, 00:49
Yes, under "VIEW", Compile and Program Options, Assembler, a check mark in the Use MPASM box. As I said Darryl they work great on their own just not together. Probably operator error somewhere, I'm just not sure where.

Thanks for your help.

Darrel Taylor
- 6th January 2007, 00:58
Can you post the code?

I'll take a look and see what's up.
<br>

ronjodu
- 6th January 2007, 01:04
<code>
'************************************************* ***************
DEFINE LOADER_USED 1 ' If using bootloader
DEFINE OSC 20
DEFINE HSER_RCSTA 90h 'setup receive register
DEFINE HSER_TXSTA 20h 'setup transmit register
DEFINE HSER_BAUD 38400 'setup baud rate

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

Addr var word
Char var byte

Clear

goto StartLoop ' Required

String1:
@ da "This is a string",0

AnotherString:
@ da "Here is another string",0

'------------GetAddress Macro - Location insensitive -------------------------
ASM
GetAddress macro Label, Wout ; Returns the Address of a Label as a Word
CHK?RP Wout
movlw low Label
movwf Wout
movlw High Label
movwf Wout + 1
endm
ENDASM


StartLoop ' This loop repeats continuously just as a test.
@ GetAddress _String1, _Addr ' Get address of String
gosub StringOut ' Send the String
hserout [13,10] ' New Line

@ GetAddress _AnotherString, _Addr ' Get address of String
gosub StringOut ' Send the String
hserout [13,10] ' New Line
pause 500
goto StartLoop ' Repeat


StringOut: ' Send the string out via Hserout
Readcode Addr, Char ' Get a character
if Char = 0 then StringDone ' Look for Null char, Stop if found
hserout [Char] ' Send char
Addr = Addr + 1 ' Point to next character
goto StringOut ' Continue with rest of the string
StringDone:
return


end
</code>

Here it is. Out for dinner for an hour or so. I'll check back later. Thanks again.

Darrel Taylor
- 6th January 2007, 01:23
Ah, that helps.

You haven't defined the Interrupts yet.

There needs to be a section that looks something like this...
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _ToggleLED1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM

@ INT_ENABLE INT_INT ; enable external (INT0) interrupts

That section should be at the top of the program (but after the INCLUDE files), and don't jump over it. It needs to actually execute.

Then there also needs to be a handler routine...
'---[INT - interrupt handler]---------------------------------------------------
ToggleLED1:
TOGGLE LED1
@ INT_RETURN

HTH,

ronjodu
- 6th January 2007, 01:28
Here's the right one.
<code>
'************************************************* ***************
DEFINE LOADER_USED 1 ' If using bootloader
DEFINE OSC 20
DEFINE HSER_RCSTA 90h 'setup receive register
DEFINE HSER_TXSTA 20h 'setup transmit register
DEFINE HSER_BAUD 38400 'setup baud rate

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

Addr var word
Char var byte
led1 var PORTC.0 'heartbeat LED
Clear

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



goto StartLoop ' Required

String1:
@ da "This is a string",0

AnotherString:
@ da "Here is another string",0

'------------GetAddress Macro - Location insensitive -------------------------
ASM
GetAddress macro Label, Wout ; Returns the Address of a Label as a Word
CHK?RP Wout
movlw low Label
movwf Wout
movlw High Label
movwf Wout + 1
endm
ENDASM


StartLoop ' This loop repeats continuously just as a test.
@ GetAddress _String1, _Addr ' Get address of String
gosub StringOut ' Send the String
hserout [13,10] ' New Line

@ GetAddress _AnotherString, _Addr ' Get address of String
gosub StringOut ' Send the String
hserout [13,10] ' New Line
pause 500
goto StartLoop ' Repeat


StringOut: ' Send the string out via Hserout
Readcode Addr, Char ' Get a character
if Char = 0 then StringDone ' Look for Null char, Stop if found
hserout [Char] ' Send char
Addr = Addr + 1 ' Point to next character
goto StringOut ' Continue with rest of the string
StringDone:
return

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

@ INT_RETURN


end
</code>

Darrel Taylor
- 6th January 2007, 01:57
Oh, that helps even more. :)

There is a conflict between the two programs.
DT_INTS also has a GetAddress macro.

So you can just delete the GetAddress macro in the main program.

Don't forget to un-comment the include files.
<br>

ronjodu
- 6th January 2007, 04:37
As always Darryl, you are "THE MAN".

Thanks alot...

ronjodu
- 6th January 2007, 04:43
As always Darryl, you are "THE MAN".

Thanks alot...

Darrel Taylor
- 6th January 2007, 09:05
As always Darryl, you are "THE MAN".

See, now why can't "SHE" ever grasp that concept. :o
But that's another story.

Great! Hope the rest of the program works out too.
<br>
L8R,