Page 1 of 1
					
				MOD54415x  external IO's chip selsect
				Posted: Mon Oct 08, 2018 6:26 am
				by mikinet
				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;
}
			 
			
					
				Re: MOD54415x  external IO's chip selsect
				Posted: Tue Oct 09, 2018 1:56 pm
				by TomNB
				sim.cs not valid for the 5441x platform. I think you may be building for the incorrect platform.
			 
			
					
				Re: MOD54415x  external IO's chip selsect
				Posted: Wed Oct 10, 2018 12:27 am
				by mikinet
				so what sim register i need to use?
			 
			
					
				Re: MOD54415x  external IO's chip selsect
				Posted: Wed Oct 10, 2018 10:42 pm
				by pbreed
				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                            */
			 
			
					
				Re: MOD54415x  external IO's chip selsect
				Posted: Wed Oct 10, 2018 11:37 pm
				by mikinet
				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);
}
			 
			
					
				Re: MOD54415x  external IO's chip selsect
				Posted: Thu Oct 11, 2018 5:45 am
				by sulliwk06
				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.
			 
			
					
				Re: MOD54415x  external IO's chip selsect
				Posted: Thu Oct 11, 2018 11:27 am
				by TomNB
				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.
			 
			
					
				Re: MOD54415x  external IO's chip selsect
				Posted: Sun Oct 14, 2018 4:45 am
				by mikinet
				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?
 
			
					
				Re: MOD54415x  external IO's chip selsect
				Posted: Fri Oct 19, 2018 5:20 am
				by sulliwk06
				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.
			 
			
					
				Re: MOD54415x  external IO's chip selsect
				Posted: Sun Oct 28, 2018 4:21 am
				by mikinet
				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?