Agreer -
You said that you're using the serial monitor for debugging and it seems that you're not having any luck getting any interrupt service routines to run.
You said in one post that you were placing the timer interrupt at $FFF2. However, the serial monitor uses the hardware based vector relocation feature of the GB60. The vector relocation addresses are at $FBCC–$FBFD rather than from $FFCC–$FFFD. So the correct vector location for the timer interrupt would be $FBF2.
For a more complete discussion of this, you might check out AN2140 at: http://www.freescale.com/files/microcontrollers/doc/app_note/AN2140.pdf
Agreer,
I don't think you are understanding this fully.
I didn't before today as I have a USB Multilink. So today I slummed it with the serial monitor to understand how this works.
The hardware redirection simply means that when an interrupt occurs it goes looking for its vector in a new place (just below the protected block with the same negative offset as from FFFF. It doesn't somehow move the actual vector addresses down!
You can't write to the standard vector area anyway (its protected!)
So you can either put the vector yourself in the new place or, in Codewarrior turn on vector mirroring and it will do it for you magically.
But the important thing is that before you run, the interrupt routines' address must be in the new location, so if it doesn't work look in the memory window to see if its there (at FBF2 in this case).
BR
Peg
Message Edited by agreer on 02-15-200602:05 PM
Hi there,
interrupt vectors relocation (done by PC) works for AN2295 HC(S)08 Serial Bootloader, *not* for S08 Serial Monitor (desribed in AN2140). Please, do not mix these two.
AN2295 Bootloader has been started years ago and was made to program Flash over the serial line (no interrupt vectors mangling needed for the final code, etc.).
While Serial monitor was made for S08 only and to allow debugging over Serial line. AN2140 requires the vectors to be redirected (in the user code).
Regarding the code itself, I was able to replicate it here, the last version as it is worked OK assuming that counter variable was placed in Zero page. INC instruction does not work with extended addressing.
Although the code works with real hardware, I was not able to make it 'running' in the P&E simulator though.
Regards, Pavel Lajsner, Freescale Roznov
P.S. One little hint:
; clear the channel flag
lda TPM1C1SC ; read flag CH1F in TPM1C1SC
bclr CH1F, TPM1C1SC ; to clear flag, write zero to CH1F
maybe simplified to:
; clear the channel flag
bclr CH1F, TPM1C1SC ; to clear flag, write zero to CH1F
since BCLR/BSET instructions are read-modify-write thus read-before-clear condition is met using just BCLR. P.
Message Edited by ok2ucx on 02-17-200602:13 PM
Agreer:
agreer wrote:
. . . As far as I can tell, the ISR is never entered. . .
Hi agreer,
Below is your last version of code that I have added to in order to get it to work
on an Axiom M68DEMO908GB60 board.
I had to add the following that you either didn't have or didn't tell us about.
(1) disable COP
(2) enable ints
(3) set CLKSA rather than CLKSB as I am running in SCM mode and XCLK is disabled in this mode
(4) a reset vector
So let us know what you were doing wrong
Peg
.NOLIST
#include "9S08GB60v1rdp.inc"
.LIST
ORG RamStart
RTIDelayL equ 33
RTIDelayH equ 44
counter rmb 1
ORG RomStart
lda #(mCOPT+mSTOPE+mBKGDPE)
sta SOPT ;disable COP (1)
CLI ;enable ints (2)
mov #0,counter
mov #%00001111,PTFD
mov #%00001111,PTFDD
jsr RTI_init
bra *
RTI_init:
;; setup timer 1 module
mov #(mCLKSA+mPS2+mPS1+mPS0),TPM1SC ;(3)
mov #(mMS1A+mCH1IE),TPM1C1SC
; reset the channel compare value
mov #RTIDelayL,TPM1C1VL
mov #RTIDelayH,TPM1C1VH
sthx TPM1CNTH ; write to counter to clear it
; clear the channel flag
lda TPM1C1SC ; read flag CH1F in TPM1C1SC
bclr CH1F,TPM1C1SC ; to clear flag, write zero to CH1F
rts
RTI_Handler:
; do something here...
inc counter
lda counter
coma
sta PTFD
; reset the channel compare value
; calculate the current compare value + delay value
lda #RTIDelayL
add TPM1C1VL ; a = RTIDelayL + TPM1C1VL
sta TPM1C1VL
lda #RTIDelayH
adc TPM1C1VH ; a = RTIDelayH + TPM1C1VH + c
sta TPM1C1VH
; clear the channel flag
lda TPM1C1SC ; read flag CH1F in TPM1C1SC
bclr CH1F,TPM1C1SC ; to clear flag, write zero to CH1F
rti
ORG $FFF2
DC.W RTI_Handler ; TPMCH1
ORG $FFFE
DC.W ROMStart ;(4)
Hi agreer,
The code I posted is the *entire code*
just assemble it and download it.
I am looking at the flashing LED's as I write this.
I have not configured any ICG regs.
I am relying on power up defaults for everything you don't see explicitly set here.
I used PE assembler CASMHC08_Pro.
Codewarrior is probably _helping_ you by initialising stuff that you don't know about.
The code I have supplied is the absolute bare minimum required to get this done, you need everything that is there. It is intended to show you what you *have* to do not neccessarily what you should do.
If you don't touch any clock regs you will get Self Clocked Mode at untrimmed 4MHz. This will do for LED flashing. The XCLK signal is disabled in this mode and so you can't use it as a source for the timer.
Regards
Peg
Hi agreer,
I can see anything wrong either. (except for the int vector perhaps)
A few other pointers:
it looks like you may be using old 05 code (or you may be an old 05 coder)
you can replace:
lda #(mCLKSB|mPS2|mPS1|mPS0)
sta TPM1SC
with:
mov #(mCLKSB|mPS2|mPS1|mPS0),TPM1SC
and:
lda #RTIDelayL
add TPM1CNTL ; a = RTIDelayL + TPM1CNTL
tax ; x = a
lda #RTIDelayH
adc TPM1CNTH ; a = RTIDelayH + TPM1CNTH + c
psha
pulh ; h = a
store ix in channel value reg (TPM1C1VH:TPM1C1VL)
sthx TPM1C1VH
with
lda #RTIDelayL
add TPM1CNTL ; a = RTIDelayL + TPM1CNTL
sta TPM1C1VL
lda #RTIDelayH
adc TPM1CNTH ; a = RTIDelayH + TPM1CNTH + c
sta TPM1C1VH
the latches will handle the two 8 bit writes to the 16 bit register.
You should also change to adding to the previous compare like rocco suggested!
In the int handler you can do something similar and throw out the sei cli and the push/pull of h as you won't affect it.
All of the above won't make it work but it will look nicer doing nothing :smileyhappy:
Have you run your code in a simulator and set a breakpoint in the int handler???
BR
Peg