I2C I/O pin setup - MC908JL16

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I2C I/O pin setup - MC908JL16

3,115 Views
BobMac
Contributor I
Hi there Freescale Experts;
 I have a IIC application for our 908JL16 and am a bit confused about the i/o pin configuration. I have selected PTA(2&3) for data and clock use. Does this set these port pins for open drain operation per the I2C spec?
Regards, Bob  
 
 
 
 
 
 
Added p/n to subject.


Message Edited by NLFSJ on 2008-09-03 10:55 PM
Labels (1)
0 Kudos
7 Replies

843 Views
alexod
Contributor I
Hi All,

I have a parallel issue.

I have several working boards with an I2C interface from an MC9S08AW32 to an NXP LED driver (PCA9633).

Thing is, I just noticed on a schematic review of the latest board in the family, our HW guy has given me a 10K pullup on SDA, not on SCL.  I check back on the older designs, and see no pull-ups, period.

I know that the pingroup used (port c) has available built in pull-ups, but I cannot find any place in where they are enabled.  I had used the Bean tools to set up the IIC port, but my licence level only gives me IIC_Init which yields...

void IIC2_Init(void)
{
  /* IIC1A: ADDR7=0,ADDR6=0,ADDR5=0,ADDR4=0,ADDR3=0,ADDR2=0,ADDR1=0,??=0 */
  setReg8(IIC1A, 0x00);                
  /* IIC1F: MULT1=0,MULT0=0,ICR5=0,ICR4=0,ICR3=0,ICR2=0,ICR1=0,ICR0=0 */
  setReg8(IIC1F, 0x00);                
  /* IIC1S: TCF=0,IAAS=0,BUSY=0,ARBL=1,??=0,SRW=0,IICIF=1,RXAK=0 */
  setReg8(IIC1S, 0x12);                /* Clear the interrupt flags */
  /* IIC1C: IICEN=1 */
  setReg8Bits(IIC1C, 0x80);            
  /* IIC1C: IICEN=1,IICIE=0,MST=0,TX=1,TXAK=0,RSTA=0,??=0,??=0 */
  setReg8(IIC1C, 0x90);                
}

Is there something turining on the pullups which I am just not finding?  I know it's not in my I2C code as that was ported from a coldfire project which had HW pullups.

Thanks

Alex
0 Kudos

844 Views
chempi
Contributor I

Hi , I am trying to use I2C in a 908JL16, but is not working, I am following the tutor from freescale.

 

I use the following code

 

void init_I2C (void)
{
MMCR_MMEN = 1; // Enable IIC;
MIMCR_MMBB = 1; // Clear bus busy flag;
MMCR_MMTXAK = 1;
MIMCR_MMRW = 0; // R/W bit = 0;
MIMCR_MMAST = 0; // Slave mode actually;
MIMCR_MMNAKIF = 0;
MIMCR_MMALIF = 0; // Clear flags;
MMSR = 0; // Clear all flags (Status register);
MIMCR_MMBR = 4; // Set speed to 78kHz for Bus = 2.46 MHz;
}

/* Funcion para enviar por I2C a un esclavo*/
void I2C_write_byte (byte addr, byte wr_data)
{
MIMCR_MMRW = 0;         // Set Write mode;
MMADR = 100;            // set combined address of Slave for write;
MMDTR = addr;           // set address of Slave to read;
//-------start of transmit bytes to IIC bus-----
MIMCR_MMAST = 1;        // Start transfer - Master bit = 1;
while (!(MMSR_MMTXBE)); // wait till data transferred;
while (MMSR_MMRXAK);    // wait for ACK from slave;
//-----Slave ACK occurred------------
MMDTR = wr_data;        // write data byte into EEPROM;
while (!(MMSR_MMTXBE)); // wait till data transferred;
MMDTR = 0xFF;           // generate SCL impulse for slave to send ACK bit;
while (MMSR_MMRXAK);    // wait for ACK from slave;
MIMCR_MMAST = 0;        // STOP bit;
}

/* Funcion para leer por I2C a un esclavo*/
byte I2C_read_byte (byte addr)//output is byte "rd_data";
{
byte rd_data;

MIMCR_MMRW = 0;         // Set Write mode;
MMADR = 100;            // set combined address of Slave for write;
MMDTR = addr;           // set address;
//-------start of transmit first byte to IIC bus-----
MIMCR_MMAST = 1;        // Start transfer - Master bit = 1;
while (!(MMSR_MMTXBE)); // wait till data transferred;
while (MMSR_MMRXAK);    // wait for ACK from slave;
//-----Slave ACK occurred------------
MIMCR_MMRW = 1;         // set read operation;
MMCR_REPSEN = 1;        // enable repeat Start bit;
MMCR_MMTXAK = 0;        // Master will generate ACK;
MIMCR_MMAST = 1;        // Start transfer - Master bit = 1;
//------start of transmit Repeat start & "A1" to IIC bus-------
MMDTR = 0xFF;           // send repeated start and combined address;
while (!(MMSR_MMTXBE)); // wait till data transferred;
while (MMSR_MMRXAK);    // wait for ACK from slave;
MMDTR = 0xFF;           // send SCL clocks for the slave to send data;
MMCR_MMTXAK = 1;        // Disable master ACK after read byte from Slave;
while (!(MMSR_MMRXBF)); // wait till data received;
rd_data = MMDRR;        // read received data;
MIMCR_MMAST = 0;        // generate STOP bit - End of transfer;
return rd_data;
}

/* Funcion para enviar string por I2C*/
void I2C_write_str(byte addr, byte *str)
{
 byte i=0;
 
 while (str[i]!='~'){
  I2C_write_byte(addr,str[i]);
  i++;
 }
}

 

Thanks

0 Kudos

844 Views
UcTechnoGeek
Contributor II
In my experience you still need to use the standard I2C pull-ups to make it work.
0 Kudos

844 Views
BobMac
Contributor I
Hey,Thanks;
 Do I set the DDRA pin for output when Transmitting and input when receiving? The manual does not seem clear on this point. If open drain with pull up, seems wired or function should allow Tx and Rx to work both ways. Your thoughts good Sir?

Bob
0 Kudos

844 Views
bigmac
Specialist III
Hello Bob,
 
As a general rule, when a peripheral module is enabled this will override any GPIO settings, including data direction, that may previously be present on the pin(s).  For the IIC case, I would suggest that you leave both pins set as inputs, for bus compatibility when the module is not enabled.  When the module is then enabled, the pins will automatically become open drain outputs.  External pullup resistors will be necessary in accordance with IIC requirements.
 
Regards,
Mac
 
0 Kudos

844 Views
BobMac
Contributor I
Thanks BigMac I owe youz an extra pickle.
BobMac
0 Kudos

844 Views
JimB
Contributor I

Sorry to interfere, but my hope (working on a program for this mcu and module, but not having touched the hardware) is that they do! I presume you mean "as opposed to PTD(7&6)" - so having made the pin selection and enabled the module I would say "yes". Check out the 3rd parapraph in section 8.1 in conjunction with the note at the bottom of section 8.1, p.109 of rev 1.1 datasheet.

Now: how about your opinion on my post a few days ago about this mcu and module - thanks! :smileyhappy:

Jim

0 Kudos