Help in configuring chip select for 5282

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

Help in configuring chip select for 5282

2,703 Views
tama
Contributor I
Hi Guys
I am using Netburner Mod5282 core and trying to interface a FPGA to it. I want to use CS1 for it, and want to allocate 1Mbyte memory for it. How do i set CSMR1 register. CSAR1  is used to set the upper 16 bit base address. But how do i set CSMR1. I read the data sheet but its bit confusing.

Can any one pls explain me how to set it.

Thanks
Tama
Labels (1)
0 Kudos
Reply
5 Replies

678 Views
SimonMarsden_de
Contributor II

To set the CSMR for a 1MB area and enable the chip select, you want something like:smileyembarrassed:/p>

    MCF5282_CS1_CSMR = MCF5282_CS_CSMR_BAM_1M |                       MCF5282_CS_CSMR_V;

If you're using CodeWarrior, the header files contain the definitions you need for these equates. Otherwise you also need:

#define MCF5282_CS_CSMR_BAM_1M               (0x000F0000)#define MCF5282_CS_CSMR_V                    (0x00000001)

You'll also need to make sure that you configure the CSCR appropriately.

You might find it helpful to look at a free program called ColdFire Init, which lets you configure the ColdFire processor (including the Chip Selects) through a GUI front-end, and then generates initialisation code for you. It's available from MicroAPL's web site:

http://www.microapl.co.uk/CFInit/cfinit_main.html


Cheers


Simon
0 Kudos
Reply

678 Views
mccPaul
Contributor I
Hi
 
This works for me for a Xilinx Spartan FPGA:
 
Code:
 MCF5282_CS1_CSAR = MCF5282_CS_CSAR_BA((uint32)__BASE_ADDR_FPGA); MCF5282_CS1_CSCR = (0  | MCF5282_CS_CSCR_WS(2)  | MCF5282_CS_CSCR_AA  | MCF5282_CS_CSCR_BSTR  | MCF5282_CS_CSCR_PS_16); MCF5282_CS1_CSMR = MCF5282_CS_CSMR_BAM_1M | MCF5282_CS_CSMR_V;

 

So __BASE_ADDR_FPGA is your base address. All the other constants come from Freescale's headers and set CS1 for 2 wait states, auto acknowledge, burst read enable, 16 bit port size.

CSMR is set to 1MB and Valid. If you don't have the header

MCF5282_CS_CSMR_BAM_1M is 0x000F0000 and

MCF5282_CS_CSMR_V is 0x00000001

Paul.


 
0 Kudos
Reply

678 Views
tama
Contributor I
Hi Guys
 
Thanks for your info..
 
Can you pls tell me how does CSMR value is calculated.
MCF5282_CS_CSMR_BAM_1M is 0x000F0000
 
The rest of the portion i could understand but how is 0x000F0000 calucated.
 
Can you pls explain in more detail.
 
Thanks
Tama
 
0 Kudos
Reply

678 Views
mccPaul
Contributor I
Hi
 
The CSAR is used to specify the start address of the memory that is dedicated to the chip select. The base address can only be on a 64KB boundary so only bits 31 to 16 of the address are specified.
 
The BAM bits in the CSMR (bits 31 to 16) are the Base Address Mask. Each bit in the BAM is used to mask or unmask bits in the base address so that you can specify the limit of the chip select block. If a bit is set in the BAM, the corresponding bit in the base address is ignored.
 
Example:
 
You set the base address to 0xa0000000. You also set the BAM to 0x0000. The chip select module does not care about the lowest 16 bits of the memory, so at the moment you are telling the chip select module that any address beginning with 0xa000 belongs to this chip select. That means that from address 0xa0000000 to 0xa000ffff belong to the chips selct and the block is 64KB long.
 
 If you set the BAM to 0x0001, you are masking bit 17 of the address. In this case only the top 15 bits of the address are significant so the block runs from 0xa0000000 to 0xa01ffff - 128KB.
 
If you want 1MB of memory mapped to the chip select, you need to set the BAM so that 1MB of address space is masked:
 
Start = 0xa0000000, end = 0xa00fffff. If you examine the addresses, you can see that only the top 12 bits are significant when you want to specify the memory block that the chip select is using so you set the BAM to 0x000f to mask bits 19 to 16.
 
What you are trying to do is to tell the chip select module which address lines to monitor so that it can identify an access to the memory controlled by this chip select.
 
The user guide doesn't explicitly say that if you set a bit in the BAM then you must also set all the bits below that bit. So if you set bit 17 in CSMR, bit 16 must also be set. If you left gaps between the bits, you would end up specifying a block that is not contiguous - this is not normally what you want to do. If you assume that you will never leave a gap in the mask then the calculation in the user guide can be used to speficy the size of the memory block:
 
block size = 2^n where n = number of bits set +16
 
Cheers,
 
Paul.
 
 
 
 
 
0 Kudos
Reply

678 Views
tama
Contributor I
Hi MCCP

Thanks a lot for your help. You have explained it to the depth. Now i got the calculation behind setting CSMR.
The data sheet dosnt mention about the lower bits hence i got confused.

Thanks once again.

Tama
0 Kudos
Reply