Problems writing to paged ram on an HC12

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problems writing to paged ram on an HC12

ソリューションへジャンプ
1,794件の閲覧回数
CJTill
Contributor I

I am a using CodeWarrior version 5.7.0 with an MC9S12XDP512 processor.

I am trying to reserve 3 pages of paged RAM (FA, FB and FC) that will be accessed only by using far pointers.  Basically I have a very basic file system that sequentially stores data to those pages of RAM and I want to be able to access that data later without it being overwritten.  Whenever i try to write to memory, the contents of the memory say they are undefined.

 

I have declared the start addresses of my file system like this:

INT16U *__far startAddress = (INT16U*__far) 0xFA1000;
INT16U *__far endAddress = (INT16U*__far) 0xFC1FFF;
INT16U *__far currentAddress;

The addresses of each page are in the .prm file like this:

RAM_FA        = READ_WRITE  0xFA1000 TO 0xFA1FFF ALIGN 2[1:1];
RAM_FB        = READ_WRITE  0xFB1000 TO 0xFB1FFF ALIGN 2[1:1];
RAM_FC        = READ_WRITE  0xFC1000 TO 0xFC1FFF ALIGN 2[1:1];

 

These 3 pages are reserved in this way:

 PAGED_RAM              /* paged data accessed by CPU12 only */

                     INTO   RAM_FC, RAM_FB, RAM_FA;

 

One page was reserved for the X-Gate processor:


      XGATE_STRING_RAM,     

      XGATE_CONST_RAM,       

      XGATE_CODE_RAM,         

      XGATE_DATA             

                        INTO  RAM_F8;

 

This is how I am writing to memory and initializing the pointer:

  currentAddress = startAddress;   //initialize the currentaddress pointer to the beginning of page A

*currentAddress = variable;  //write data to the current address in ram

 

In the debugger it says that *currentAddress = undefined.  Any ideas why I can't write to paged RAM?

ラベル(1)
0 件の賞賛
返信
1 解決策
729件の閲覧回数
kef
Specialist I

I think the problem is that pointers to far data use global addressing GPAGE+16bit G-page offset. And you specified your addresses using RPAGE + 16bit cpu local address. For example 0xFA1000 is RPAGE=0xFA, and CPU local address 0x1000. I don't know how familiar you are with this, but try converting RPAGE RAM addresses to GPAGE RAM addresses, like this

 

#define RPAGE2GPAGE(x) ((x&0xFFF) |  ((x>>4)&0xFF000))

INT16U *__far startAddress = (INT16U*__far) RPAGE2GPAGE(0xFA1000);
INT16U *__far endAddress = (INT16U*__far) RPAGE2GPAGE(0xFC1FFF);

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
730件の閲覧回数
kef
Specialist I

I think the problem is that pointers to far data use global addressing GPAGE+16bit G-page offset. And you specified your addresses using RPAGE + 16bit cpu local address. For example 0xFA1000 is RPAGE=0xFA, and CPU local address 0x1000. I don't know how familiar you are with this, but try converting RPAGE RAM addresses to GPAGE RAM addresses, like this

 

#define RPAGE2GPAGE(x) ((x&0xFFF) |  ((x>>4)&0xFF000))

INT16U *__far startAddress = (INT16U*__far) RPAGE2GPAGE(0xFA1000);
INT16U *__far endAddress = (INT16U*__far) RPAGE2GPAGE(0xFC1FFF);

0 件の賞賛
返信
729件の閲覧回数
CJTill
Contributor I

Ok, thanks I see what I need to do now.  I will need to change the RPAGE register to write to the correct location.

0 件の賞賛
返信