EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Interrupts

Started by nathan_b_a July 7, 2005
HI

I'm currently writing a program for the 68hc11 on my Thrism11
simulator. The program uses the irq interrupt.

What I don't understand is how you can edit the interrupt vector when
it is in the ROM? I thought ROM could only be configured in the
factory.
For example, here is my code for the first part of the program:

STACK EQU $00FF
PROGRAM EQU $FF00
IRQ EQU $FFF2
DDRC EQU $07
REGBAS EQU $1000
PORTC EQU $03
MEMORY EQU $04
PORTD EQU $08

*************************************************
* SETUP *
*************************************************

ORG IRQ
FDB IRQHERE

ORG PROGRAM
*MAIN PROGRAM
START SEI ;MASK IRQ
LDS #STACK ;SETUP STACK POINTER
LDX #REGBAS ;SET REGISTER BASE
LDAA #$03 ;LOAD A WITH 01 FOR PORT C SETUP

STAA DDRC,X ;SET PC0 AND PC1 AS OUTPUT AND PC2-
PC7 AS INPUTS
LDAA PORTC,X
ANDA #$80
STAA PORTC,X ;CLEAR PORT C
LDAA #$00 ;LOAD A WITH 00 TO RESET MEMORY
STAA MEMORY,X ;CLEAR MEMORY
CLI ;CLEAR INTERRUPT MASK

*************************************************
* MAIN PROGRAM *
*************************************************

LOOP BRA LOOP ;WAIT HERE FOR DEBOUNCED IRQ SIGNAL

**************************************************
* IRQ Request *
**************************************************

IRQHERE LDAA MEMORY,X ;LOAD ACCUMULATOR A WITH THE MEMORY D
Now, when I assemble this the irq address of $fff2 contains the hex
$ff16. This differs from the default which was $ffff.

The reason I ask this is because I want to transfer this program to a
real chip and run the program in EEPROM, but I'm not sure if the
interrupt vector will work.

In summary, can you change the contents of $fff2 in real life, or is
this only something you can do at the factory and in a simulator.

Any help appreciated.

Thank you

Nathan


I am not familiar with the Thrism11 simulator. Generally speaking, with a
real 68HC11, you can put the hc11 in expanded-multiplexed mode and then use
an external device like your eeprom for your interrupt vectors and program
memory. The exceptions to this are certain items on-chip which if enabled
would take precedent for the addresses they occupy i.e. registers, eeprom, ram.

At 06:05 AM 7/7/2005 +0000, you wrote:
>HI
>
>I'm currently writing a program for the 68hc11 on my Thrism11
>simulator. The program uses the irq interrupt.
>
>What I don't understand is how you can edit the interrupt vector when
>it is in the ROM? I thought ROM could only be configured in the
>factory. >
>For example, here is my code for the first part of the program:
>
>STACK EQU $00FF
>PROGRAM EQU $FF00
>IRQ EQU $FFF2
>DDRC EQU $07
>REGBAS EQU $1000
>PORTC EQU $03
>MEMORY EQU $04
>PORTD EQU $08
>
>*************************************************
>* SETUP *
>*************************************************
>
> ORG IRQ
> FDB IRQHERE
>
> ORG PROGRAM
>*MAIN PROGRAM
>START SEI ;MASK IRQ
> LDS #STACK ;SETUP STACK POINTER
> LDX #REGBAS ;SET REGISTER BASE
> LDAA #$03 ;LOAD A WITH 01 FOR PORT C SETUP
>
> STAA DDRC,X ;SET PC0 AND PC1 AS OUTPUT AND PC2-
>PC7 AS INPUTS
> LDAA PORTC,X
> ANDA #$80
> STAA PORTC,X ;CLEAR PORT C
> LDAA #$00 ;LOAD A WITH 00 TO RESET MEMORY
> STAA MEMORY,X ;CLEAR MEMORY
> CLI ;CLEAR INTERRUPT MASK
>
>*************************************************
>* MAIN PROGRAM *
>*************************************************
>
>LOOP BRA LOOP ;WAIT HERE FOR DEBOUNCED IRQ SIGNAL
>
>**************************************************
>* IRQ Request *
>**************************************************
>
>IRQHERE LDAA MEMORY,X ;LOAD ACCUMULATOR A WITH THE MEMORY D >
>Now, when I assemble this the irq address of $fff2 contains the hex
>$ff16. This differs from the default which was $ffff.
>
>The reason I ask this is because I want to transfer this program to a
>real chip and run the program in EEPROM, but I'm not sure if the
>interrupt vector will work.
>
>In summary, can you change the contents of $fff2 in real life, or is
>this only something you can do at the factory and in a simulator.
>
>Any help appreciated.
>
>Thank you
>
>Nathan >Yahoo! Groups Links >
>


On Thu, 2005-07-07 at 06:05 +0000, nathan_b_a wrote:
> What I don't understand is how you can edit the interrupt vector when
> it is in the ROM? I thought ROM could only be configured in the
> factory.

The answer to this is perhaps circuitous - the interrupt vector is
actually part of the program itself. If you have a ROM-based MCU, then
not only is the IRQ vector in ROM, but so is the program itself! They
are inseparable.

So - where is your program? If it is in RAM, then the *same*
mechanism which you use to place and start the program, is used to set
the IRQ vector. You see the *START* (reset) vector is adjacent to the
IRQ vector, so both are defined in the same manner.

If you are running a bootstrap or "monitor" - which is in ROM, then it
generally pre-sets the IRQ vector to jump to a RAM location which it
initialises to a default, but which you can re-allocate in the same
action as you load program code to be executed.

So, if you understand what your system is doing in general, the answer
will follow.

--
Cheers,
Paul B.


Dear Paul

Thank you for taking the time to reply.

I am trying to write a program that will keep track of external signals. The signals come from a microswitch in a clock tower once every hour. The applied signals will be recorded/analysed/reset in memory then transferred to portc.

So my problem is that I have just developed and tested a program that works in my simulator (THRISM11), but am wondering if it will actually work in the physical chip when I download it.

The reason for my concern is that the simulator uses ROM, and I belive that ROM is only programmable in the factory, and that I need to use EEPROM.

So this is why I was asking about Interrupts. The IRQ interrupt vector is located in $FFF2, so when you make the IRQ line low, the data contained in this address is inserted into the program counter and is used as the address for the next instruction. So if the data located at $FFF2 is in ROM, then how do you change it?

Thanks again for taking the time to reply

Kind Regards

Nathan (Electronics Student)
"Paul B. Webster VK2BZC" <paulb@paul...> wrote:
On Thu, 2005-07-07 at 06:05 +0000, nathan_b_a wrote:
> What I don't understand is how you can edit the interrupt vector when
> it is in the ROM? I thought ROM could only be configured in the
> factory.

The answer to this is perhaps circuitous - the interrupt vector is
actually part of the program itself. If you have a ROM-based MCU, then
not only is the IRQ vector in ROM, but so is the program itself! They
are inseparable.

So - where is your program? If it is in RAM, then the *same*
mechanism which you use to place and start the program, is used to set
the IRQ vector. You see the *START* (reset) vector is adjacent to the
IRQ vector, so both are defined in the same manner.

If you are running a bootstrap or "monitor" - which is in ROM, then it
generally pre-sets the IRQ vector to jump to a RAM location which it
initialises to a default, but which you can re-allocate in the same
action as you load program code to be executed.

So, if you understand what your system is doing in general, the answer
will follow.

--
Cheers,
Paul B.
---------------------------------
YAHOO! GROUPS LINKS --------------------------------- ---------------------------------
Sell on Yahoo! Auctions - No fees. Bid on great items.



Dear Steve

Thank you for taking the time to reply.

I am trying to write a program that will keep track of external signals. The signals come from a microswitch in a clock tower once every hour. The applied signals will be recorded/analysed/reset in memory then transferred to portc.

So my problem is that I have just developed and tested a program that works in my simulator (THRISM11), but am wondering if it will actually work in the physical chip when I download it.

The reason for my concern is that the simulator uses ROM, and I belive that ROM is only programmable in the factory, and that I need to use EEPROM.

So this is why I was asking about Interrupts. The IRQ interrupt vector is located in $FFF2, so when you make the IRQ line low, the data contained in this address is inserted into the program counter and is used as the address for the next instruction. So if the data located at $FFF2 is in ROM, then how do you change it?

Thanks again for taking the time to reply

Kind Regards

Nathan (Electronics Student) Steve Tabler <stevetabler@stev...> wrote:I am not familiar with the Thrism11 simulator. Generally speaking, with a
real 68HC11, you can put the hc11 in expanded-multiplexed mode and then use
an external device like your eeprom for your interrupt vectors and program
memory. The exceptions to this are certain items on-chip which if enabled
would take precedent for the addresses they occupy i.e. registers, eeprom, ram.

At 06:05 AM 7/7/2005 +0000, you wrote:
>HI
>
>I'm currently writing a program for the 68hc11 on my Thrism11
>simulator. The program uses the irq interrupt.
>
>What I don't understand is how you can edit the interrupt vector when
>it is in the ROM? I thought ROM could only be configured in the
>factory. >
>For example, here is my code for the first part of the program:
>
>STACK EQU $00FF
>PROGRAM EQU $FF00
>IRQ EQU $FFF2
>DDRC EQU $07
>REGBAS EQU $1000
>PORTC EQU $03
>MEMORY EQU $04
>PORTD EQU $08
>
>*************************************************
>* SETUP *
>*************************************************
>
> ORG IRQ
> FDB IRQHERE
>
> ORG PROGRAM
>*MAIN PROGRAM
>START SEI ;MASK IRQ
> LDS #STACK ;SETUP STACK POINTER
> LDX #REGBAS ;SET REGISTER BASE
> LDAA #$03 ;LOAD A WITH 01 FOR PORT C SETUP
>
> STAA DDRC,X ;SET PC0 AND PC1 AS OUTPUT AND PC2-
>PC7 AS INPUTS
> LDAA PORTC,X
> ANDA #$80
> STAA PORTC,X ;CLEAR PORT C
> LDAA #$00 ;LOAD A WITH 00 TO RESET MEMORY
> STAA MEMORY,X ;CLEAR MEMORY
> CLI ;CLEAR INTERRUPT MASK
>
>*************************************************
>* MAIN PROGRAM *
>*************************************************
>
>LOOP BRA LOOP ;WAIT HERE FOR DEBOUNCED IRQ SIGNAL
>
>**************************************************
>* IRQ Request *
>**************************************************
>
>IRQHERE LDAA MEMORY,X ;LOAD ACCUMULATOR A WITH THE MEMORY D >
>Now, when I assemble this the irq address of $fff2 contains the hex
>$ff16. This differs from the default which was $ffff.
>
>The reason I ask this is because I want to transfer this program to a
>real chip and run the program in EEPROM, but I'm not sure if the
>interrupt vector will work.
>
>In summary, can you change the contents of $fff2 in real life, or is
>this only something you can do at the factory and in a simulator.
>
>Any help appreciated.
>
>Thank you
>
>Nathan >Yahoo! Groups Links >
>

---------------------------------
YAHOO! GROUPS LINKS --------------------------------- ---------------------------------
Sell on Yahoo! Auctions - No fees. Bid on great items.



It's nice to see some activity on this group for a change.

nathan_b_a wrote:

>HI
>
>I'm currently writing a program for the 68hc11 on my Thrism11
>simulator. The program uses the irq interrupt.
>
>What I don't understand is how you can edit the interrupt vector when
>it is in the ROM? I thought ROM could only be configured in the
>factory.
[snip]

There are several answers to your question, some of which have already
been given.

I know nothing about your simulator, however supposing it to be
a program running on some other computer (like a PC), then there
is no actual ROM in the simulator connected with the simulated
MC68HC11.

OTOH, it is important to remember that a simulator is, after all, a
simulator. It is not actually the hardware you will run with. The
simulator may actually only use a small ROM located where you
can't see it, and run all your programs out of RAM, including your
interrupt vectors. This can be done, even if the actual processor
is an MC68HC11, by relocating the address range of the RAM
dynamically. When you first boot, the ROM is in the address
space, and it is used to download your program into RAM, which
has been decoded to different addresses. When you tell it to GO,
then the RAM is relocated to its run address, and a different kind
of reset is done.

Another answer is that when you develop a new program, and
send it to Motorola, they make a special version of the MC68HC11
for you, with your program in the ROM.

Another answer is that you blow an EPROM or EEPROM, and
boot in an expanded mode, so that the internal ROM is not part
of the address map. >
>
>For example, here is my code for the first part of the program:
>
>STACK EQU $00FF
>PROGRAM EQU $FF00
>IRQ EQU $FFF2
>DDRC EQU $07
>REGBAS EQU $1000
>PORTC EQU $03
>MEMORY EQU $04
>PORTD EQU $08
>
>*************************************************
>* SETUP *
>*************************************************
>
> ORG IRQ
> FDB IRQHERE
>
> ORG PROGRAM
>*MAIN PROGRAM
[snip]

>IRQHERE LDAA MEMORY,X ;LOAD ACCUMULATOR A WITH THE MEMORY D >
>Now, when I assemble this the irq address of $fff2 contains the hex
>$ff16. This differs from the default which was $ffff.
It contains the value of IRQHERE. In other words, the vector address $FFF2
"points" to your routine IRQHERE, which is at address $FF16.

>The reason I ask this is because I want to transfer this program to a
>real chip and run the program in EEPROM, but I'm not sure if the
>interrupt vector will work.
It sure will, if you decode your EEPROM to start at $FF00.

>In summary, can you change the contents of $fff2 in real life, or is
>this only something you can do at the factory and in a simulator.
If you run in an expanded multiplex mode, and decode your EEPROM correctly,
when you reset your program will execute as written. (NOT necessarily
correctly, however :-)

You will need, however to pay close attention to the differences between the
addresses IN THE ROM versus addresses CALCULATED BY THE
PROCESSOR.

For example, suppose you use an 8K EEPROM, say a 2864. You decode
it so it covers the address range $C000-$FFFF. Fine, this looks good.
But you need to realize that the addresses the ROM sees are only the
low order bits, the high order bits are used to create chip select. So the
EEPROM sees addresses $0000-$1FFF. Your EEPROM programmer
must be properly instructed concerning how to do the programming to
account for this. I have found that this is sometimes a point of confusion
for beginners.

Mike

--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!


Normally, you would have a changeable vector in RAM and the $FFF2 vector
would point to a routine in 'ROM' such as:

IRQV:
ldx ramvector
jsr 0,x ;or jmp 0,x if the rti is in the routine
rti ----- Original Message -----
From: "nathan apps" <nathan_b_a@nath...>
To: <m68HC11@m68H...>
Sent: Thursday, July 07, 2005 6:41 AM
Subject: Re: [m68HC11] Interrupts > Dear Steve
>
> Thank you for taking the time to reply.
>
> I am trying to write a program that will keep track of external signals.
> The signals come from a microswitch in a clock tower once every hour. The
> applied signals will be recorded/analysed/reset in memory then transferred
> to portc.
>
> So my problem is that I have just developed and tested a program that
> works in my simulator (THRISM11), but am wondering if it will actually
> work in the physical chip when I download it.
>
> The reason for my concern is that the simulator uses ROM, and I belive
> that ROM is only programmable in the factory, and that I need to use
> EEPROM.
>
> So this is why I was asking about Interrupts. The IRQ interrupt vector is
> located in $FFF2, so when you make the IRQ line low, the data contained in
> this address is inserted into the program counter and is used as the
> address for the next instruction. So if the data located at $FFF2 is in
> ROM, then how do you change it?
>
> Thanks again for taking the time to reply
>
> Kind Regards
>
> Nathan (Electronics Student) > Steve Tabler <stevetabler@stev...> wrote:I am not familiar with the
> Thrism11 simulator. Generally speaking, with a
> real 68HC11, you can put the hc11 in expanded-multiplexed mode and then
> use
> an external device like your eeprom for your interrupt vectors and program
> memory. The exceptions to this are certain items on-chip which if enabled
> would take precedent for the addresses they occupy i.e. registers, eeprom,
> ram.
>
> At 06:05 AM 7/7/2005 +0000, you wrote:
>>HI
>>
>>I'm currently writing a program for the 68hc11 on my Thrism11
>>simulator. The program uses the irq interrupt.
>>
>>What I don't understand is how you can edit the interrupt vector when
>>it is in the ROM? I thought ROM could only be configured in the
>>factory.
>>
>>
>>
>>For example, here is my code for the first part of the program:
>>
>>STACK EQU $00FF
>>PROGRAM EQU $FF00
>>IRQ EQU $FFF2
>>DDRC EQU $07
>>REGBAS EQU $1000
>>PORTC EQU $03
>>MEMORY EQU $04
>>PORTD EQU $08
>>
>>*************************************************
>>* SETUP *
>>*************************************************
>>
>> ORG IRQ
>> FDB IRQHERE
>>
>> ORG PROGRAM
>>*MAIN PROGRAM
>>START SEI ;MASK IRQ
>> LDS #STACK ;SETUP STACK POINTER
>> LDX #REGBAS ;SET REGISTER BASE
>> LDAA #$03 ;LOAD A WITH 01 FOR PORT C SETUP
>>
>> STAA DDRC,X ;SET PC0 AND PC1 AS OUTPUT AND PC2-
>>PC7 AS INPUTS
>> LDAA PORTC,X
>> ANDA #$80
>> STAA PORTC,X ;CLEAR PORT C
>> LDAA #$00 ;LOAD A WITH 00 TO RESET MEMORY
>> STAA MEMORY,X ;CLEAR MEMORY
>> CLI ;CLEAR INTERRUPT MASK
>>
>>*************************************************
>>* MAIN PROGRAM *
>>*************************************************
>>
>>LOOP BRA LOOP ;WAIT HERE FOR DEBOUNCED IRQ SIGNAL
>>
>>**************************************************
>>* IRQ Request *
>>**************************************************
>>
>>IRQHERE LDAA MEMORY,X ;LOAD ACCUMULATOR A WITH THE MEMORY D
>>
>>
>>
>>Now, when I assemble this the irq address of $fff2 contains the hex
>>$ff16. This differs from the default which was $ffff.
>>
>>The reason I ask this is because I want to transfer this program to a
>>real chip and run the program in EEPROM, but I'm not sure if the
>>interrupt vector will work.
>>
>>In summary, can you change the contents of $fff2 in real life, or is
>>this only something you can do at the factory and in a simulator.
>>
>>Any help appreciated.
>>
>>Thank you
>>
>>Nathan
>>
>>
>>
>>
>>
>>
>>
>>
>>Yahoo! Groups Links
>>
>>
>>
> >
>
> ---------------------------------
> YAHOO! GROUPS LINKS > --------------------------------- > ---------------------------------
> Sell on Yahoo! Auctions - No fees. Bid on great items. >
> Yahoo! Groups Links >
>


Please don't use HTML.
Please don't use long lines.
Please don't top-post.
Please don't quote the entire message you reply
to, unless it is necessary.
OK?

Thanks.

nathan apps wrote:

[snip]

>
>I am trying to write a program that will keep track of external signals. The signals come from a microswitch in a clock tower once every hour. The applied signals will be recorded/analysed/reset in memory then transferred to portc. >
How can an applied signal be reset in memory?

[snip]

>
>So this is why I was asking about Interrupts. The IRQ interrupt vector is located in $FFF2, so when you make the IRQ line low, the data contained in this address is inserted into the program counter and is used as the address for the next instruction. So if the data located at $FFF2 is in ROM, then how do you change it?
I'm not sure I understand your question properly. Are you attempting
to save the data you get from PORTC to ROM? That is not possible,
in general. With EEPROM, you can do it, but your program cannot
be running out of the same EEPROM you are programming.

I don't think that is what you mean, however. I think you are wondering
how on Earth you will ever get to your program out of RESET.

The answer is the infamous ROMON bit in the CONFIG register.

If ROMON is a 1, then when the processor boots in any normal mode,
the reset vector comes from the internal ROM. But if ROMON is 0, then
in expanded multiplexed mode the reset vector and all other vectors
come from external memory, not the internal ROM. If your circuit
is designed and constructed properly, this external memory is you
EEPROM.

The way the EEPROM gets changed is that you program it before you
put it into the circuit.

[snip]

Mike

--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!


nathan apps wrote:

[snip]

>
>The reason for my concern is that the simulator uses ROM, and I belive that ROM is only programmable in the factory, and that I need to use EEPROM.
>
>So this is why I was asking about Interrupts. The IRQ interrupt vector is located in $FFF2, so when you make the IRQ line low, the data contained in this address is inserted into the program counter and is used as the address for the next instruction. So if the data located at $FFF2 is in ROM, then how do you change it?
I realized just now that there is another way to understand your question.
Are you trying to run out of the EEPROM on the MC68HC11, the 1/2K
located at $B600?

If so, then the answer is No, this will not work as you have written it.

There are several techniques for execting from the EEPROM on the
chip, if that is what you want to do. Two of them are simple, others
get more complicated.

Mike

--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!


Please don't top-post.
Please don't quote the entire message you reply to.
Please don't use HTML.

Michael Huslig wrote:

>Normally, you would have a changeable vector in RAM and the $FFF2 vector
>would point to a routine in 'ROM' such as:
>
>IRQV:
> ldx ramvector
> jsr 0,x ;or jmp 0,x if the rti is in the routine
> rti
I haven't seen this. What I have seen is that the vector in ROM points to
a location in RAM containing a jump, like this:

InitCode:
ldaa #$7E
staa RAM_VECT_1
ldx #DEFAULT_ROM_HANDLER_1
stx RAM_VECT_1 + 1
staa RAM_VECT_2
ldx #DEFAULT_ROM_HANDLER_2
stx RAM_VECT_2 + 1
etc.

One just overwrites the destination address. So after init,
we have

RAM_VECT_1:
jmp DEFAULT_ROM_HANDLER_1

When the user's code gets in control, it does this:

UserCode:
ldd #USER_HANDLER_1
std RAM_VECT_1 + 1

Then we have in RAM

RAM_VECT_1:
jmp USER_HANDLER_1

Mike

--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!



Memfault Beyond the Launch