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.