using external memory in interrupt routines with char pointer

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

using external memory in interrupt routines with char pointer

Jump to solution
2,074 Views
jkampmann
Contributor I
I have some problems using external memory (0x200000'G-0x27FFFF'G, 16 Bit) within my interrupt routine.
It is not possible to write with a char pointer to the external memory. Only every second byte (odd addresses) ist written. Writing to external memory using an int pointer works fine.
Character pointers outside from the interrupt routine are working fine, too..
Is there an easy way to use character pointers within a interrupt routine ?



Message Edited by jkampmann on 2008-03-17 01:43 PM

Message Edited by jkampmann on 2008-03-17 01:43 PM
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
819 Views
CompilerGuru
NXP Employee
NXP Employee


jkampmann wrote:
Yes, that's right. I'm using far pointer.
Using "-CpGPAGE=0x10" Doesn't seem to have any effects.
I was using "#pragma TRAP_PROC SAVE_ALL_REGS" instead.
But all this has no effect on this behaviour. Only every second byte is written. When i'm using the debugger i can clearly see that the external ram was accessed, but only every second byte.
Can you show this code? Does the compiler do 16 bit access for every 2 byte address update?
Is this issue about the external RAM being accessed with a 16 bit bus with only 8 bit connected?

I think outside the interrupt routine the compiler is saving the lower/higher byte while accessing the 16 bit RAM 8-Bit byte-wise...
I don't think the compiler does this intentionally. The use pattern of the code may  be different for the two uses and that may cause the different code seen.

btw can somebody explain to me what "_STORE_FAR_8" in datapage.c is doing ? Has this to do with this ?

Hmmm. This question is a bit unexpected. Basically the _STORE_FAR_8 routine is not used when generating code for the S12X, only when generating code for the S12. Does your code use _STORE_FAR_8?
While S12 code can run on a S12X, this wont take advantage of many of the S12X added features,
and also the _STORE_FAR_8 is not adapted to the S12X.



Daniel

View solution in original post

0 Kudos
Reply
3 Replies
819 Views
CrasyCat
Specialist III
Hello
 
I assume you are using far pointers in your interrupts. Am i right?
 
There is one thing you need to know when it goes around using far pointers within interrupt functions.
 
The GPAGE register is not saved per default in the interrupt function entry code and restored in the exit code.
In order to tell the compiler it should save/restore the GPAGE register in interrupt entry/exit code you need to build with option -CpGPAGE=0x10.
 
Note:
  If you are using __rptr you need to build with -CpRPAGE=0x16
  If you are using __eptr you need to build with -CpEPAGE=0x36
 
I hope that helps.
 
CrasyCat
0 Kudos
Reply
819 Views
jkampmann
Contributor I
Yes, that's right. I'm using far pointer.
Using "-CpGPAGE=0x10" Doesn't seem to have any effects.
I was using "#pragma TRAP_PROC SAVE_ALL_REGS" instead.
But all this has no effect on this behaviour. Only every second byte is written. When i'm using the debugger i can clearly see that the external ram was accessed, but only every second byte.

I think outside the interrupt routine the compiler is saving the lower/higher byte while accessing the 16 bit RAM 8-Bit byte-wise...

btw can somebody explain to me what "_STORE_FAR_8" in datapage.c is doing ? Has this to do with this ?
0 Kudos
Reply
820 Views
CompilerGuru
NXP Employee
NXP Employee


jkampmann wrote:
Yes, that's right. I'm using far pointer.
Using "-CpGPAGE=0x10" Doesn't seem to have any effects.
I was using "#pragma TRAP_PROC SAVE_ALL_REGS" instead.
But all this has no effect on this behaviour. Only every second byte is written. When i'm using the debugger i can clearly see that the external ram was accessed, but only every second byte.
Can you show this code? Does the compiler do 16 bit access for every 2 byte address update?
Is this issue about the external RAM being accessed with a 16 bit bus with only 8 bit connected?

I think outside the interrupt routine the compiler is saving the lower/higher byte while accessing the 16 bit RAM 8-Bit byte-wise...
I don't think the compiler does this intentionally. The use pattern of the code may  be different for the two uses and that may cause the different code seen.

btw can somebody explain to me what "_STORE_FAR_8" in datapage.c is doing ? Has this to do with this ?

Hmmm. This question is a bit unexpected. Basically the _STORE_FAR_8 routine is not used when generating code for the S12X, only when generating code for the S12. Does your code use _STORE_FAR_8?
While S12 code can run on a S12X, this wont take advantage of many of the S12X added features,
and also the _STORE_FAR_8 is not adapted to the S12X.



Daniel
0 Kudos
Reply