M68HC12B32EVB Interrupt Vector Table

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

M68HC12B32EVB Interrupt Vector Table

9,792 Views
cjw
Contributor I
Hi!
 
I am trying to use the real-time interrupt on this board, but the interrupt vector table is in a read-only section of the board. The EVB manual tells me to place the origin of the interrupts code at $F7F0 to use real time interrupts, but I cannot do it simply with the command:
 
ORG $F7F0
DC.W NAME_OF_LABEL
 
This gives me a "cannot write to memory" error when uploading the code. How can I set interrupts on this evaluation board. Neither the MCU's manual or EVB manual help in this regard. The board is running D-BUG 12 V2.0.1
 
Thanks for all and any help.
 
Christian
Labels (1)
0 Kudos
8 Replies

1,054 Views
cjw
Contributor I
As mentioned earlier, here is a link to the finished code, which should give people an example of how to use real time interrupts on the M68H912B32EVB. This evaluation board comes with a M68HC912B32 processor (as the name indicates, haha!).

The attached program does the following (in a nutshell).

It sets the RTI control register (RTICTL) to enable real-time interrupts. The interrupt divider chain is set up in such a way that interrupts occur every 32.768 ms. When the interrupt occurs, I count up the variable TIMECOUNT. When this variable reaches $727 (hex), approximately 1 minute has passed. I then update the variable MINUTE using the CLK_UPDATE label. Once MINUTE reaches 10, I re-initialize it to 0 using the CLK_RESET label.

In the main program, I check if MINUTE is 2, to toggle PORT A on. I am having 1 LED on PORT A to check this, but a voltmeter works as well. I then keep checking MINUTE until it is equal to 6, and I once again toggle PORT A -- this time off. This is always done using the lable TOGGLE.

You can modify this code to suit your RTI needs. I am using this setup, because I simulate the passing of a whole day over 10 minutes. After 2 minutes I start a process, while after 6 I quit the process. Once MINUTE is reset to 0, this restarts.

As far as accuracy is concerned, I did calculations on it and the clock loses about 14 minutes and 20 seconds every year. This accuracy is more than enough for me, but if you need a super accurate clock, you must compensate for this loss (perhaps every day).

Anyway, the code should be well commented, but let me know if you have questions.

The code can be found at:

http://home.comcast.net/~cwinter/RTI_Test.asm
0 Kudos

1,054 Views
imajeff
Contributor III
Thanks for pointing out that DBug12 resident routine for setting the user interrupt vector. I would have never found it because nothing documented it except mingled with the primitive "libc" routines which I didn't need.
0 Kudos

1,054 Views
cjw
Contributor I


imajeff wrote:
Thanks for pointing out that DBug12 resident routine for setting the user interrupt vector. I would have never found it because nothing documented it except mingled with the primitive "libc" routines which I didn't need.




You're welcome. As I said myself, I could find only bits and pieces of this on the web, never a whole example. Also, the code itself is flawed, because it does not actually toggle Port A. I will have a fixed version up tonight. This one keeps toggling the port at all times, because I used an old routine from a scenario where I did not call the toggle routine at all times.
0 Kudos

1,054 Views
cjw
Contributor I
I figured it out now, I was able to set the interrupt. However, once the interrupt is called for the first time, I get kicked out of the program with an "RTI Exception". I know for sure that the interrupt was called once, because I initalize Register Y to 0, and increment it only in the RTI_ROUTINE function, which the real-time interrupt vector points to. When the "RTI Exception" occures, Y has been incremented to 1. Hence, I get kicked out when RTI is called for the first time, which should send the program back to the label MAIN, which is an infinite loop. I am not sure what is causing this and any help is appreciated.

Here is my code:

http://home.comcast.net/~cwinter/RTI_Test.asm

(I decided to post it on my website, because the code is virtually unreadable if posted to the forum, since all tabs are lost.)

Again, thanks for all and any help.

Message Edited by cjw on 03-20-200609:20 PM

Message Edited by cjw on 03-20-200609:21 PM

0 Kudos

1,054 Views
imajeff
Contributor III


cjw wrote:
I figured it out now, I was able to set the interrupt. However, once the interrupt is called for the first time, I get kicked out of the program with an "RTI Exception".




I was not certain what's wrong by looking at the code, but I could not see where you were inserting the vector pointing to RTI_ROUTINE (you said you figured out).

So I asked myself, what does "RTI Exception" mean? I think it means you are not overriding the default DBug12 vector for RTI, which by default displays that message. That brings me to the question, are you really writing the vector to the right table? You are loading this into RAM (0x800). That means likely Flash is being used by the D-Bug12 monitor. That means you cannot use interrupts unless you edit DBug12 to jump to a certain RAM location for that vector.

I love the MC9S12 because in it DBug12 actually supports a RAM pseudo vector table.
0 Kudos

1,054 Views
cjw
Contributor I
Thanks for your reply, I did figure the whole thing out now. Because the vector table is write protected, a the D-BUG12 subroutine setuservector() must be used to set interrupt vectors. I have it working now and will post the complete code, in case it is of help to anyone else with this problem in the future.

It's one of those "Once you get it, you get it" things.
0 Kudos

1,054 Views
imajeff
Contributor III
Interresting, I didn't see that feature a couple of years ago when I was learning D-Bug12 for HC12.

What version is it?
0 Kudos

1,054 Views
cjw
Contributor I


imajeff wrote:
Interresting, I didn't see that feature a couple of years ago when I was learning D-Bug12 for HC12.

What version is it?




It's D-BUG12 Version 2.0.2.
0 Kudos