james edwards

MCF5485 FlexBus interface

Discussion created by james edwards on Dec 11, 2006
Latest reply on Jan 8, 2007 by james edwards

Hi:

I’m having trouble interfacing a Compact Flash card to the FlexBus of a MCF5485.

 

I can write to the common memory of the Compact Flash card.  But when I read form the common memory of the Compact flash card I only get the Low Byte even though it’s setup as a 16 bit port on the FlexBus.  I have CE1(even byte) and CE2(odd Byte) of the Compact Flash card tied to FB_CS3. 

 

What is strange to me is that I can see that the write to the card was successful by plugging the card into my PC and looking at the sector that I wrote to.  So I think that I have the card “hooked up” to the FlexBus correctly.  (FlexBus Data on the top half and Address on the Bottom half of the bus not an address latch)

 

Have I missed somthing in the Chip select steup???

I have The Compact Flash card setup on FBCS3 as follows in

a CodeWarrior 5.7.0 project.

 

MCF_FBCS_CSAR3 = (MCF_FBCS_CSAR_BA (0x50010000));

    

MCF_FBCS_CSCR3 =(MCF_FBCS_CSCR_ASET(3)  // Address Setup time delay in clock cycles

 |MCF_FBCS_CSCR_RDAH(3) //Read Address hold time 1+x cycles

                  |MCF_FBCS_CSCR_WS(15)  // # of Wait States

                  |MCF_FBCS_CSCR_AA            // Auto Ack

                  |MCF_FBCS_CSCR_PS_16); // Port size in bits

                        

MCF_FBCS_CSMR3 =(MCF_FBCS_CSMR_BAM_64K   

                   |MCF_FBCS_CSMR_V);

 

Or if you prefer

MCF_FBCS_CSAR3 =0x5001

MCF_FBCS_CSCR3 =0x003C3D80

MCF_FBCS_CSMR3 =0x00000001

 

I have some test code to write the contents of an array "My_DataBuffer[512]" to the card and read the card back into another arrary "Cf_ReadData[512]".

 

Here are some defines so things below make sense…

 

unsigned char writeDosSector( unsigned long sector,

                       unsigned short sectorCount,

                       unsigned char * writeBuffer,

                       char fCode)

unsigned char readDosSector(  unsigned long sector,

                       unsigned short sectorCount,

                       unsigned char * writeBuffer,

                      char fCode)

/*The Test code.*/

unsigned char Cf_ReadData[512] = {0};

unsigned char My_DataBuffer[512] ={"James is the King"};

 

printf(" test_card %s\n",My_DataBuffer);

writeDosSector(1000,1,&My_DataBuffer[0],ENDIAN_SWAP);

printf(" test_card readDosSector\n");

     for(i=0; i <=511; i++) // flush Cf_ReadData befor the read

     {

     Cf_ReadData[i]=0;

     }

readDosSector(1000,1,&Cf_ReadData[0],ENDIAN_SWAP);

printf(" test_card Cf_ReadData = %s\n",Cf_ReadData);

 

 

The Output:

 

 test_card  James is the King

 

 test_card readDosSector

 

test_card Cf_ReadData = J m s i   h   i g

 

 

As you can see James is NOT the King!:smileysad: 

I'm only getting back every even byte correctly.  And every odd byte is getting set to 0x20 some how (the spaces you see in the string above)?

 

Any help form the true King would be appreciated

James

Outcomes