How to access external address while using a mc9s12kt256?

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

How to access external address while using a mc9s12kt256?

930 Views
yellowmaple
Contributor II

     hi,I'am Interfacing HCS12(mc9s12kt256) Microcontrollers to the MFR4310 FlexRay Controller.But I do not know how to access external bus.

     I have configured the MCU to normal expanded wide mode(PEAR=0xAC,EBICTL=0x00,MISC=0x0DMODE= 0xED),and I can see ECLK ,W/R,LBSTRB signal sent out.But I know all the signals above are generated by accessing internal memory.I have also consulted the AN3260 (Interfacing HCS12 Microcontrollers to the MFR4310 FlexRay Controller), the example makes me confused,especially the statement below

// Set up ports

PORTB = 0xFF; // Port B = 0xFF

DDRB = 0xFF; // Set port B as output

PTS = 0x00; // Port S = 0x00

DDRS = 0x04; // Set port PS2 as output

// Enable PULL UPS on PTE

PUCR_PUPEE = 1; // Pull ups enabled on bits 7, 4-0

PTH = 0x04; // ASC[2, 1, 0] = 100match 0x8000 on ADR bus

DDRH = 0x07; // make PortH an Output

PPAGE = PAGE0; // Pages $00 - $2F = External

                               // Pages $30 - $3F = Internal

 

I donot know why this example would have configure PORTB  and DDRB  first,in the expande mode ,aren;t they used as buses ?and I can not find any detail in my KT256 mannual about pages pointing to extermal address.How can I access the external bus ?

Labels (1)
3 Replies

644 Views
lama
NXP TechSupport
NXP TechSupport

I would like to provide you answer I send in  2009 to another customer. It is not direct but provides overview for design of external bus for these devices. Please, do not care about different part number because all these parts use the same version V3 of the MEBI module.

ECS can not be used for EXBUS even it is on the chip. ECS pin is not assigned to be used for external chip select. This pin is given for emulation modes – please read AN2287 page 2.

ECS pin has meaning only in emulation mode when internal ROM is fully disabled (ROMON bit) and entire program is placed inside external ROM.

If you want to use ExBUS together with internal program Flash then you can start MCU in normal expanded mode directly by setting external pins to correct configuration or you can start the MCU in special single chip mode and then you can switch to normal expanded mode by writing MODE register. For debugging purposes second option should be used.

As examples for external bus design you can use AN2408 – examples #1, #2, #3, #8 because the A256 does not contain XCS signal. (link is placed below)

Entire address space which is not used internally is addressed on the external bus. Internal flash pages are $30~$3F (256kB). Pages $00~$2F can be used for external bus access.

These pages can address 768kB (786432 Bytes) external address space. (16kB window address * ($2F+1))

As an external bus address are used PTK5:0:XAB13:0. It gives 20bit external bus address.

The address creation you can see in the Excel sheet ADDRESS ON BUS 02.xls (attached).

The external bus can be used together with internal flash. There is one condition which has to be fulfilled. If you R/W external RAM or internal flash data then you have to keep in mind that the PPAGE register has to be set properly. For example, if the code is running from page, for example, $30 then access to another page requires change of the PPAGE register content and the code will be not performed correctly.

Because of this you should use routines for R/W paged memory space which are placed inside non banked memory space. (4000~7FFF, C000~FFFF). IOW, if the code is running from page unlike unbanked (4000~7FFF, C000~FFFF) then the part of code which changes pages has to be placed inside unbanked memory space. It must be done this way because during access to data the PPAGE register is changed. This register is also used for program address. In the case you do not do it this way it happens collision between program and data pages.

Metrowerks Code Warrior uses “far” pointer. This pointer express extended address PPAGE:OFFSET. If the compiler recognizes access to the far variable then it automatically calls suitable function from the module datapage.c. The module is automatically added to project during its creation.

However, if you want to use your own routines you can write them but I think you will not be faster than Code Warrior.

a) AN2287 - HCS12 External Bus Design.pdf

http://www.freescale.com/files/microcontrollers/doc/app_note/AN2287.pdf

b) AN2408 - Examples of HCS12 External Bus Design_ A Companion Note to AN2287-D.pdf

http://www.freescale.com/files/microcontrollers/doc/app_note/AN2408.pdf

c) Moreover, Regarding HW - take into account: A Guide for Motorola HCS12 Expanded Mode Bus-Design and for Connecting an HCS12 Expanded Mode Target to a Nohau HCS12 Full-ICE By: Doron Fael, Nohau Corporation October 20, 2003

http://www.icetech.com/appnotes/hcs12-expanded-mode-guide.pdf

You can find there some notes about problematic timing.

If your memory is not able to fit problematic hold time requirements then the easiest way how to access ExRAM is to use Example #8 — Software External Interface from AN2408.

* Compiler note: Do not forget to set PPAGE register to be used for banking:

- Add compiler option PPAGE is used for banking.

Write: -CpPPAGE=RUNTIME -CPUHCS12 -D__NO_FLOAT__ -Mb

Or: Alt F7-> Options -> Code Generation -> select PPAGE register is used for paging.

Into cell which will appear write RUNTIME.

Regarding the memory you want to use and its speed. You should try to find some memory with the parameters comparable with the memory CY7C1041CV33.

Examples of addressing of external space can be seen in attached DP256B - MEMORY MAPPING-CW45.

(Prepared under Code Warrior v.4.5.)

I hope and believe you will understand. If does not, do not hesitate to ask.

Note related to Code Warrior: I have found out that CW does not work correctly with page 0 if it is addressed directly, for example:

x = *((unsigned char *far) 0x0080000);

In this case it does not changes the page and reads only from address 0x8000 with current page set => it reads from wrong address. As a workaround can be use far pointer, for example:

volatile unsigned char *far p_RAM_PG; // pointer to external memory

p_RAM_PG = (unsigned char *far)0x008000; // initialize pointer to page 0 address 0x8000 =>

                                                                    // => ExBUS address is 0*0x4000+ (0x8000-0x8000)= 0x000000

x = *p_RAM_PG;                                          // read byte data from EXRAM address 00:8000

                      

As an alternative I would like to recommend you newer S12X family (MC9S12XD…, S12XE…) for external mode designs. Pin compatible with A256. The S12X external bus is much more user friendly and easy to implement for expanded mode use (no ugly timing in Normal Expanded mode either). It has much less problems in referencing very large RAMs (up to MBytes in size) with the help of the S12X new GPAGE register, or even better using the RPAGE register through the RPAGE window. More chip selects. No problem with bus timing as in the case of DG256B.

The S12X also has many other silicon improvements over the HCS12 family, and especially for rapid performance increase: It executes to 40/50MHz bus-speed (vs 25MHz on HCS12), has an improved instruction set as compared to the HCS12 family, and a new, second co-processor named XGate that executes at 80MHz bus speed and is very efficient in I/O intensive tasks. I saw benchmarks that give the S12X between 2 to 5 times performance increase compared to HCS12, and at about the same or even smaller price vs. HCS12 in a year or two.

If this does not answer your question(s), or I have forgotten something, or if you need more assistance, please contact me again.

  1. This issue will auto close in 7 days upon no reply.

Best Regards, Ladislav

644 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

is there a possibility to get your code.

If it is not public then I would like to ask you to create a case on the basis of following procedure and just start the text of the case with "Hello Ladislav" the I will now it is for me. How to submit a new question for NXP Support

Best regards,

Ladislav

0 Kudos

644 Views
yellowmaple
Contributor II

Hi,

     I wish I could paste my code here,but it is not on my laptop.

     Now I still have a problem.I have created a new project just like the one you gave me.When I run my program in full_chip_simulation Mode,I can access any address,internal or external .I think it is a great advance.But when I put my code  on chip (mc9s12kt256),and run ,it just cannot access external address,all accesses become internal ,i donot know why.

     And my simulator is P&E USB BDM Multilink.

     1. simulation ,everything is OK.

fzdy.jpg

fzdm.jpg

     2.on_chip mode, the same case,it reads from internal memory.I donot connect any physical memory to KT256.

real.jpg

0 Kudos