Can I2C pin remap to another pins at MOD5234?

Discussion to talk about software related topics only.
Post Reply
michael.li9
Posts: 3
Joined: Fri May 14, 2010 1:12 pm

Can I2C pin remap to another pins at MOD5234?

Post by michael.li9 »

Hi
I use Mod5234 and its carrier board V100 (v1.12). I2C shares J2[42]and J2[39] with CAN0 at default setting. We need three UARTs, one CAN and one I2C in our project. So we have to remove i2c to J2[25] and J2[27]. I have added the following code before I2CInit();
J2[25].function(PINJ2_25_SCL);
J2[27].function(PINJ2_27_SDA);
But the I2C still works at J2[42] and J2[39].
I found the I2CInit() is write like that,
void I2CInit( BYTE freqdiv )
{
#if ( defined MOD5270 || defined MOD5282 || defined MOD5234 )
J2[39].function( PINJ2_39_SDA ); // Set Pins to I2C
J2[42].function( PINJ2_42_SCL );
#elif ( defined MOD5213 )
Pins[4].function( PIN4_SDA );
Pins[5].function( PIN5_SCL );
#elif ( defined MCF5270 || defined MCF5208 || defined MCF5234 )
sim.gpio.par_feci2c |= 0xF;
#else
#error PLATFORM_NOT_DEFINED_FOR_I2C_PIN_INIT
#endif

sim.i2c.sr = 0; //clears all interupts and previous i2c conditions
sim.i2c.cr = 0; //clears all interupts and previous i2c conditions
OSSemInit(& Master_I2C_TX_Semaphore, 0); //initialize interrupt semaphores
OSSemInit(& Master_I2C_RX_Semaphore, 0);

#if ( defined MCF5270 || defined MCF5213 || defined MCF5208 )
SetIntc( ( long ) &i2c_master_int_routine, 17, 5 /* IRQ 5 */, 1 );
#elif ( defined MCF5234 || defined MCF5282 )
SetIntc( 0, ( long ) &i2c_master_int_routine, 17, 5 /* IRQ 5 */, 1 );
#endif

//Initialization according to 22.6.1 in MCF5213 user manual
//Step 1
sim.i2c.fdr = freqdiv;
//Step 2
//sim.i2c.ar = (slave_Addr<<1); //master only mode has no addr
//Step 3
sim.i2c.cr = 0x80;

if(I2C_SR_BUSY)
{
sim.i2c.cr = 0x0;
sim.i2c.cr = 0xA0;
volatile BYTE bv;
bv = sim.i2c.dr;
sim.i2c.sr = 0x0;
sim.i2c.cr = 0x0;
}

//Step 4
sim.i2c.cr = 0xC0; //interupts, slave, ack
return;

}


I2CInit will remap the I2C pins at the first two lines. If I change the two line to anothers pins, it looks work. I don't know why they put pins remaps sentence inside I2CInit(); Netburnner doesn't like to remaps I2C to other pins or any potentional issues?

Thanks
greengene
Posts: 164
Joined: Wed May 14, 2008 11:20 am
Location: Lakeside, CA

Re: Can I2C pin remap to another pins at MOD5234?

Post by greengene »

good catch!
i'd delete the two .function() calls in I2CInit and just be sure you set the
functions properly elsewhere in your program for the pins you are using,
like right after/before your call to I2CInit.

the 5270 code has the same problem but our hardware uses the same pins as the
I2CInit function sets so no harm done for us. but now that i looked at the code
they are setting more bits than they need to, but that doesn't appear to be
hurting us.

and doesn't appear to be a problem for the 5282 as they only can be in one place.
Post Reply