external memory accessing for MC9S12XDP512

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

external memory accessing for MC9S12XDP512

1,776 次查看
durfalakshmi
Contributor I

Hi,

i am using MC9S12XDP512, i have connected an external uart to the MCU. used ~cs2 as chip selection and i am using C as a programming. i am unable to access external memory.. how to access(read and write) external memory. please share examples.... 

标签 (1)
0 项奖励
回复
9 回复数

1,479 次查看
durfalakshmi
Contributor I

Hi,

i have connected an UART externally... i have to configure this UART as external memory accessing..  used CS2 as a chip selection.. and i am unable to access the UART memory registers ..

void main (void) {

        MODE = 0xa0;

       for(i1=0;i1<=100;i1++);

       MMCCTL0 |= MMCCTL0_CS2E_MASK ;

       EBICTL0 = 0x0A;

     EBICTL1 =0x01;

   

      while(1)

     

      { 

    

    WRITE_BYTE_B(0x03,0x01);

   

   x1=R_BYTE_B(0x00,0x03);  

      

    

}

}

unsigned char  R_BYTE_B(unsigned char s) {

  unsigned char ret;

  val= ((s*2)+0x140200);

  ret= *((unsigned char *far)(val)) ;

 

      return ret;

void  WRITE_BYTE_B(unsigned char a,unsigned char d) {

 

  val=((a*2)+0x140200);

*((unsigned char *far)(val))=d;

 

}

0 项奖励
回复

1,479 次查看
lama
NXP TechSupport
NXP TechSupport

I would like to direct you to the document related to the EBI I put here a few days ago:

S12XD, S12XE - External BUS design - Addendum To AN2708

Best regards,

Ladislav

0 项奖励
回复

1,479 次查看
kef2
Senior Contributor V

According to Figure 1-3. S12X CPU & BDM Global Address Mapping, CS2 is active in global address range from 0x100000'G to 0x1FFFFF'G with internal EEPROM memory hole at 0x13F000'G..0x13FFFF'G. This further gives you two choices

1) use global memory addressing for any CS2 address 0x100000'G..0x13EFFF'G and 0x140000'G..0x1FFFFF'G,

2) below the address 0x140000'G, from 0x100000'G to 0x13EFFF'G you can use EPAGE memory window to access your device. To access one of these global address X, write ((X / 4096 ) & 0xFF) to EPAGE register and access data at nonbanked address ((X % 4096) + 0x800).

(Probably you have lots of external memory? Else it wouldn't make sense to interface external uart via external memory bus. S12XE with more SCI's or external SPI<->UART's are certainly easier to go)

0 项奖励
回复

1,479 次查看
durfalakshmi
Contributor I

help me in initialization of registers for cs2 address accessing... (i am using external memory accessing to access or to configuring the external UART registers )

0 项奖励
回复

1,479 次查看
kef2
Senior Contributor V

MMCCTL0 |= MMCCTL0_CS2E_MASK;

0 项奖励
回复

1,479 次查看
durfalakshmi
Contributor I

Hi,

following i used to access external memory..

////////////////////////////////////////

void main (void) {

   MMCCTL0 |= MMCCTL0_CS2E_MASK;

      while(1) {

       

       

      send_data(0x03,0x1);

      }

}

void send_data(unsigned int Addr , unsigned int Data) {

*((volatile char far *)(0x148000+Addr))=Data;

}

/////////////////////////////////

but cs2 not going to low state during write operation...

0 项奖励
回复

1,479 次查看
kef2
Senior Contributor V

You need to move '*' to the left from "far"

   *((volatile char * far )(0x148000+Addr))=Data;

0 项奖励
回复

1,479 次查看
durfalakshmi
Contributor I

Hi,

i tried so many trails. but i am unable to access external memory... ~CS2 always in logic high state...

0 项奖励
回复

1,479 次查看
kef2
Senior Contributor V

Is memory bus enabled?

0 项奖励
回复