MCF5485 FlexBus interface

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

MCF5485 FlexBus interface

3,699 Views
james_edwards
Contributor I

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

Labels (1)
0 Kudos
5 Replies

681 Views
james_edwards
Contributor I
I just wanted to up date this thread with some more info.
 
It has been pointed out to me that I had neglected to setup the FBCS0 boot strap Address line state.  And the CLKCONFIG[4:0].  ( Thanks to Roger forester at Axiom Support)  With out this my Boot Flash will not work and the core clock comes up randomly at 2x and 4x.
 
I'm in the process of gluing a driver onto my board to configure FBCS0 and the clock scalar out of reset.
 
But I think I should still be able to write to the FBCSx registers in DEBUG mode, configure the Flexbus and run the test code without configuring FBCS0 out of reset??  Yes? No?  Anyone want to chime in on that?.
 
0 Kudos

681 Views
JWW
Contributor V
The 548x and 547x family do require you to establish a reset configuration. This will provide an initial setting for the "global" chipselect (FBCS0) and will configure the PLL and it's divider logic to provide the desired clock ratios between CPU and the various external and internal buses.

But don't forget to actually configure FBCS0 after your boot or connect with your debugger of choice. The act of setting the "valid" bit will disable the "global feature" and you can then proceed to configure your other FBCSx(s). If you do not disable the "global" feature, then all bets are off because the FlexBus address decoder will decode any internal bus cycles and cause FlexBus traffic. This feature is really only intended to aid in booting.. Once boot code is started, the global feature of FBCS0 should always be turned off.

Also...I noticed another question in a later post. Coldfire A0 (address zero) on FlexBus is always a byte address. When configuring FlexBus to a 16 bit wide memory you might want to use byte strobes/enables, but regardless the A0 on Coldfire is still a byte address even when the port is set to 16 bit.

So the A1 is the 16 bit boundary and would be assigned/connected to A0 on the 16 bit wide device. If that 16-bit wide device allows for byte addressing, then go ahead and connect Coldfire's A0 if you want to use the device in his manner. But that is up to you.

Hope this helps.
-JWW
0 Kudos

681 Views
james_edwards
Contributor I
Well I found my problem.
 
I had a bus contention with my 8 bit LCD module.  The LCD was driving at the same time as my Compact Flash.
 
James
0 Kudos

681 Views
Marreshe
Contributor I
Have you looked at how you are wiring A0 and A1 ?
0 Kudos

681 Views
james_edwards
Contributor I
Marreshe,
 
Thanks for the reply.  As my Sig says I'm a noob to the ColdFire.  And I sure appreciate any light you can shed on this.
 
The Compact Flash is both Byte and Word accessible registers on it. 
The Common memory of the Compact Flash is 16bit Word sized and the Card Information Structure is only Byte accessible. So I tied FlexBus AD0 to AD0 on the Compact Flash through a 74LCX16244 Buffer.  I enable the output of the Buffer when ever the micro detects that a card is in the socket.
 
Will the ColdFire only access Even addresses if it is configured with a port size of 16 bits?  Will it expect FlexBus AD0 to be connected to AD1 of every thing on the FlexBus?
 
Where is the "Device Tutorial" for the MCF648x ?? You know the ColdFire for Dummies Doc??  something like the "Device Tutorial" for the MC68HC16 Freescale doc "MC68HC16Z1TUT"
 
James
 
0 Kudos