MOD54415x external IO's chip selsect

Post your example source code and application notes to share with others
Post Reply
mikinet
Posts: 5
Joined: Tue Jul 24, 2018 11:22 pm

MOD54415x external IO's chip selsect

Post by mikinet » Mon Oct 08, 2018 6:26 am

Hello,
i am using the MOD54415x and i need to use the external IO's.
I use that sample to init the chip select, but i get the error "'sim' was not declared in this scope" , can any one advice?

void InitChipBoardSelect12( void )
{
//Enable the Write Chip Select
sim.cs[1].cscr = 0x2180; // 0010 0001 1000 0000
sim.cs[1].csmr = 0x00000001;
sim.cs[1].csar = ( IO_DIG_WR >> 16 );
//Enable the Read Chip Select
sim.cs[2].cscr = 0x2180; // 0010 0001 1000 0000
sim.cs[2].csmr = 0x00000001;
sim.cs[2].csar = ( IO_DIG_RD >> 16 );
bInit = TRUE;
}

User avatar
TomNB
Posts: 214
Joined: Tue May 10, 2016 8:22 am

Re: MOD54415x external IO's chip selsect

Post by TomNB » Tue Oct 09, 2018 1:56 pm

sim.cs not valid for the 5441x platform. I think you may be building for the incorrect platform.

mikinet
Posts: 5
Joined: Tue Jul 24, 2018 11:22 pm

Re: MOD54415x external IO's chip selsect

Post by mikinet » Wed Oct 10, 2018 12:27 am

so what sim register i need to use?

User avatar
pbreed
Posts: 747
Joined: Thu Apr 24, 2008 3:58 pm

Re: MOD54415x external IO's chip selsect

Post by pbreed » Wed Oct 10, 2018 10:42 pm

54415 has two sims....

sim1 and sim2.

The chipcelects are sim2.cs[6]

and have fields:

vudword csar; /* 0x0000 -> 0x0003 - Chip Select Address Register */
vudword csmr; /* 0x0004 -> 0x0007 - Chip Select Mask Register */
vudword cscr; /* 0x0008 -> 0x000B - Chip Select Control Register */

mikinet
Posts: 5
Joined: Tue Jul 24, 2018 11:22 pm

Re: MOD54415x external IO's chip selsect

Post by mikinet » Wed Oct 10, 2018 11:37 pm

I am using this code, but i don't see the CS pin's moving, or the IO pins moving, can any one advice?

void InitChipBoardSelect12( void )
{
iprintf("InitChipBoardSelect12 \r\n");

//Enable the Write Chip Select
sim2.cs[4].cscr = 0x2180; // 0010 0001 1000 0000
sim2.cs[4].csmr = 0x00000001; // Set the valid bit for this chipselect
sim2.cs[4].csar = ( IO_DIG_WR >> 16 ); // Set base address


//Enable the Read Chip Select
sim2.cs[5].cscr = 0x2180; // 0010 0001 1000 0000
sim2.cs[5].csmr = 0x00000001; // Set the valid bit for this chipselect
sim2.cs[5].csar = ( IO_DIG_RD >> 16 ); // Set base address

bInit = TRUE;
}

void DisableChipSelect12( void )
{
iprintf("DisableChipSelect12 \r\n\n");
sim2.cs[4].csmr = 0x0;
sim2.cs[5].csmr = 0x0;
bInit = FALSE;
}

/*
* WriteToOutputs
*/
void WriteToOutputs( unsigned short output )
{
if (!bInit) InitChipBoardSelect12();
*(unsigned short *)(IO_DIG_WR) = output;
}
/*
* ReadFromInputs
*/
unsigned short ReadFromInputs( void )
{
if (!bInit) InitChipBoardSelect12();
return *(unsigned short *) (IO_DIG_RD);
}

sulliwk06
Posts: 86
Joined: Tue Sep 17, 2013 7:14 am

Re: MOD54415x external IO's chip selsect

Post by sulliwk06 » Thu Oct 11, 2018 5:45 am

What are your read and write base addresses, and why are you shifting them when you initialize? Make sure they are in an unused address range.

User avatar
TomNB
Posts: 214
Joined: Tue May 10, 2016 8:22 am

Re: MOD54415x external IO's chip selsect

Post by TomNB » Thu Oct 11, 2018 11:27 am

sulliwk06 has a very good point. Chip selects will only activate when the address range they are configured for is read or written to. So you need to ensure you are familiar with the memory map for the platform you are using, and are accessing unused space (there is plenty of it).

Also, the compiler is very aggressive regarding optimization. If accessing external hardware you will want to use the volatile keyword for any variables, flags, etc you use. Volatile tells the compiler not to optimize, which avoids things like repeated register reads ending up in a processor register instead of doing an external bus cycle.

mikinet
Posts: 5
Joined: Tue Jul 24, 2018 11:22 pm

Re: MOD54415x external IO's chip selsect

Post by mikinet » Sun Oct 14, 2018 4:45 am

Hi,Thanks all for your replays,

for the 54115 i am using this base address:


#define BASEADDRESS 0x10000000
#define IO_DIG_WR BASEADDRESS
#define IO_DIG_RD BASEADDRESS+0x1000000

like the sample in the prodact page:
https://www.netburner.com/products/core ... s/mod5441x

https://www.netburner.com/support/doc-s ... ion-5/file.

what am i doing wrong?

sulliwk06
Posts: 86
Joined: Tue Sep 17, 2013 7:14 am

Re: MOD54415x external IO's chip selsect

Post by sulliwk06 » Fri Oct 19, 2018 5:20 am

I'm not sure that example is correct. Based on the reference manual (MCF54415RM.pdf) section 20.3.1 the Chip-Select Address Register should only use the upper 16 bits, so if you are bit shifting it 16 to the right, then it definitely shouldn't work. Try putting base address without shifting it and see what happens.

mikinet
Posts: 5
Joined: Tue Jul 24, 2018 11:22 pm

Re: MOD54415x external IO's chip selsect

Post by mikinet » Sun Oct 28, 2018 4:21 am

Hi, i try to NOT shift the address, but i don't see any change on the IO pins.
do you have a working example?

Post Reply