Can I2C pin remap to another pins at MOD5234?
Posted: Wed May 19, 2010 3:40 pm
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
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