EmbeddedRelated.com
Forums

Using i2c.lib on a port other than D

Started by Douglas Groen October 28, 2005
Hi,

The custom board I plug my RCM3360 into was designed
(not by me!) to use PB6 and PB7 for the I2C bus. How
do I handle the changes to the #defines in i2c.lib and
the function calls (setting up the open-drain
capability of the pins, for example) in i2c_init.c? To
float the lines do I need to make them inputs? I do
have external pull-ups on the board, I'm just
concerned about the different functionalities of Port
B compared to Port D. Anyone gone through this
already? Thank you!

Doug

__________________________________


it s very easy,just replace the default pins with ur pins.if u want know how to set pins to float ,just reference user manual.here is my example,pf0 is ckl and pf6 is sda line,using rcm3410.hoep it is helpful to u.
#ifndef I2CSCLBit
// The clock bit, if on port F.
#define I2CSCLBit 0
#endif

#ifndef I2CSDABit
// The data bit, if on port F.
#define I2CSDABit 6
#endif

#ifndef i2c_SCL_H()
#define i2c_SCL_H() BitWrPortI(PFDDR,&PFDDRShadow,0,I2CSCLBit)
#define i2c_SCL_L() BitWrPortI(PFDDR,&PFDDRShadow,1,I2CSCLBit)
#define i2c_SDA_H() BitWrPortI(PFDDR,&PFDDRShadow,0,I2CSDABit)
#define i2c_SDA_L() BitWrPortI(PFDDR,&PFDDRShadow,1,I2CSDABit)
#define i2c_SCL() BitRdPortI(PFDR,I2CSCLBit)

#define i2c_SDA() BitRdPortI(PFDR,I2CSDABit)
#endif

void i2c_init()
{
// Set the bits to tristate and the output to 0. Toggle using
//tristate reg.
// This function affects the port F transfer transfer clock
// Transfer clock on port F is PCLK/2
WrPortI(PFCR,&PFCRShadow,0);
BitWrPortI(PFFR ,&PFFRShadow ,0,I2CSCLBit);
// Set the bits to normal function
BitWrPortI(PFFR ,&PFFRShadow ,0,I2CSDABit);
BitWrPortI(PFDDR,&PFDDRShadow,0,I2CSCLBit);
// Set the bits to input (=0)
BitWrPortI(PFDDR,&PFDDRShadow,0,I2CSDABit);
BitWrPortI(PFDCR,&PFDCRShadow,1,I2CSCLBit);
// Set the bits to Open Drain
BitWrPortI(PFDCR,&PFDCRShadow,1,I2CSDABit);
BitWrPortI(PFDR ,&PFDRShadow ,0,I2CSCLBit);
// Set the outputs to 0, when outputs
BitWrPortI(PFDR ,&PFDRShadow ,0,I2CSDABit);
i2c_clocks_per_us = (int)(19200L*32*freq_divider/1000000L);
if(i2c_clocks_per_us < 3)
{
i2c_clocks_per_us = 3;
}
} ----- Original Message -----
From: "Douglas Groen" <douggroen@doug...>
To: <rabbit-semi@rabb...>
Sent: Saturday, October 29, 2005 3:16 AM
Subject: [rabbit-semi] Using i2c.lib on a port other than D > Hi,
>
> The custom board I plug my RCM3360 into was designed
> (not by me!) to use PB6 and PB7 for the I2C bus. How
> do I handle the changes to the #defines in i2c.lib and
> the function calls (setting up the open-drain
> capability of the pins, for example) in i2c_init.c? To
> float the lines do I need to make them inputs? I do
> have external pull-ups on the board, I'm just
> concerned about the different functionalities of Port
> B compared to Port D. Anyone gone through this
> already? Thank you!
>
> Doug >
>
> __________________________________
> > ------------------------ Yahoo! Groups Sponsor --------------------~-->
> Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
> http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/dN_tlB/TM
> --------------------------------~- > Yahoo! Groups Links >
>


I haven't done much with I2C to know whether it requires open drain I/O,
but if you do you're in trouble because only ports D, F & G can be
configured as open drain on the R3000.

Nathan

-----Original Message-----
From: rabbit-semi@rabb... [mailto:rabbit-semi@rabb...]
On Behalf Of Douglas Groen
Sent: Saturday, 29 October 2005 5:16 AM
To: rabbit-semi@rabb...
Subject: [rabbit-semi] Using i2c.lib on a port other than D

Hi,

The custom board I plug my RCM3360 into was designed
(not by me!) to use PB6 and PB7 for the I2C bus. How
do I handle the changes to the #defines in i2c.lib and
the function calls (setting up the open-drain
capability of the pins, for example) in i2c_init.c? To
float the lines do I need to make them inputs? I do
have external pull-ups on the board, I'm just
concerned about the different functionalities of Port
B compared to Port D. Anyone gone through this
already? Thank you!

Doug

__________________________________ Yahoo! Groups Links



I2C does require open-drain outputs.

--- Nathan Johnston <nathan.johnston@nath...>
wrote:

> I haven't done much with I2C to know whether it
> requires open drain I/O,
> but if you do you're in trouble because only ports
> D, F & G can be
> configured as open drain on the R3000.
>
> Nathan
>
> -----Original Message-----
> From: rabbit-semi@rabb...
> [mailto:rabbit-semi@rabb...]
> On Behalf Of Douglas Groen
> Sent: Saturday, 29 October 2005 5:16 AM
> To: rabbit-semi@rabb...
> Subject: [rabbit-semi] Using i2c.lib on a port other
> than D
>
> Hi,
>
> The custom board I plug my RCM3360 into was designed
> (not by me!) to use PB6 and PB7 for the I2C bus. How
> do I handle the changes to the #defines in i2c.lib
> and
> the function calls (setting up the open-drain
> capability of the pins, for example) in i2c_init.c?
> To
> float the lines do I need to make them inputs? I do
> have external pull-ups on the board, I'm just
> concerned about the different functionalities of
> Port
> B compared to Port D. Anyone gone through this
> already? Thank you!
>
> Doug >
>
> __________________________________ > Yahoo! Groups Links >
>