AN2417 Freescale Semiconductor / Motorola, AN2417 Datasheet - Page 22

no-image

AN2417

Manufacturer Part Number
AN2417
Description
PCMCIA and Compact Flash Interface for the MC9328MX1 and MC9328MXL Application Processors Application Note
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Freescale Semiconductor, Inc.
Programming Example
3.6 I/O Mode Test Program
3.6.1 Configure the Card to Work in I/O Mode
Compact Flash memory card can be configure as I/O mode in the configuration option register.The
configuration option register is a 8 bit register located in attribute memory space address 0x200. To
configure the Compact Flash as I/O mode, the lower 6 bit of the configuration option register should be set
as 0x01
// configure compact flash device to I/O mode
*(P_U8) (CS5_BASE_ADDR+0x200) = (*(P_U8) (CS5_BASE_ADDR+0x200) &0xC0) +0x1;
3.6.2 Write to Memory Block
The procedure for writing a block of memory in I/O mode is the same as in memory mode. The only
different is that correct address space should be used. Procedure for writing to a block of memory:
1, Write the number of block of data to be access to the sector count register
2, Write the LBA Address to the card
3, Issue 30H command
Example Program to write 512 byte of data to a memory block at LBA Address 0x0000001
U8 tempU8;
U16 i;
//Set sector count
*(P_U8) (CS5_BASE_ADDR+0x800002) = 0x1;//sector count =1
//Set the LBA address of memory block to be written
*(P_U8) (CS5_BASE_ADDR+0x800003) = 0x1; //LBA [7:0] =1
*(P_U8) (CS5_BASE_ADDR+0x800004) = 0x0; //LBA [15:8] =0
*(P_U8) (CS5_BASE_ADDR+0x800005) = 0x0; //LBA [23:16] =0
*(P_U8) (CS5_BASE_ADDR+0x800006) = 0xE0; //LBA [27:24]=0 (lower 4 bit of register)
//Issue write command
*(P_U8) (CS5_BASE_ADDR+0x800007) = 0x30;//issue 30H command for sector write
//Poll for busy bit
tempU8 = *(P_U8) (CS5_BASE_ADDR+0x800007);
while ( tempU8&0x80) {//poll for busy bit (bit 7 of register), quit loop when busy bit =0
tempU8 = *(P_U8) (CS5_BASE_ADDR+0x800007);
}
//Write data to data buffer until DRQ is clear
22
MC9328MX1/MXL Application Note
MOTOROLA
For More Information On This Product,
Engineering Draft / Preliminary
Go to: www.freescale.com

Related parts for AN2417