PPC 8270: I2C Initialization

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

PPC 8270: I2C Initialization

Jump to solution
3,401 Views
Karl_H
Contributor III

Hi,

I am trying to get I2C to work on PowerPC 8270. I think I have everything set up according the reference manual, but apparently I am missing something. Here is what I am doing:

 

On pin port D:

PDIRD bits 14 and 15 clear

PPARD bits 14 and 15 set

PSORD bits 14 and 15 set

PODRD bits 14 and 15 set (I think these don't matter when special function bits are enabled)

 

The I2C anchor location at IMMR + 0x8AFC is set to 0x9000, which is where I want the I2C parameter block to go.

 

At IMMR + 0x9000, I have set up rbase and tbase to point with 0x1000 and 0x1080, which puts my BD arrays for rx and tx at IMMR + 0x1000 and IMMR + 0x1080 respectively. I have set rfcr and tfcr in the parameter block to BO = 1 and T2 set (all other bits clear). I've tried the T2 bit both ways.

All rx BD's are configured with their E-bits set. All tx BD's are configured with their R-bit clear and their S, and L bits set. Last BDs in both rx and tx arrays are configured with their W-bit set.

At this point I am issuing the code to CPCR (IMMR + 0x119C0) with the values from table 14-6:

 

PAGE = 0b1010

SBC = 0b1011

FLG set

 

I am seeing the CP clear the FLG bit after this.

I2COM is then set to master mode (bit 7 set).

I2BRG is set to 208 (calculated to give 100 kbaud when predivider is 4)

I2CMR and I2CER are written with all condition bits set (this should set them in I2CMR and clear them in I2CER).

I2MOD predivider field is set to 0b11 to get a pre-divider of 4.

At this point I set the EN bit in I2MOD, and the initialization is assumed to be complete.

On the test bench I have pin port D bits 14 and 15 pulled up with 10K resistors. I have the scope monitoring both of those pins.

 

The test transmission is effected setting the first tx buffer with the target slave address in the first byte and two data bytes following. The byte count field in the corresponding BD is set to 3. Then I set the R bit in the corresponding tx BD. Then I set STS in I2COM.

 

At this point I am expecting to see the transmission on the scope and the CP to reset the R bit and set the NAK bit, since there is no device out there to answer.

 

But none of this happens.

 

Is there an app-note that has sample initialization code for this device? There is surely something I have neglected to do here, but I can't figure out what it is.

 

Karl

 

Message Edited by Karl_H on 2009-12-14 04:07 PM
0 Kudos
Reply
1 Solution
2,323 Views
Karl_H
Contributor III
Found the problem. Had the I2C anchor at IMMR + 8AFC declared at a word instead of a half word. Now that it's fixed, my I2C works as expected.

View solution in original post

0 Kudos
Reply
2 Replies
2,324 Views
Karl_H
Contributor III
Found the problem. Had the I2C anchor at IMMR + 8AFC declared at a word instead of a half word. Now that it's fixed, my I2C works as expected.
0 Kudos
Reply
2,323 Views
Karl_H
Contributor III

ADDENDUM: I just noticed that I'm getting an indication of SDMA error on the local bus in register SDSR (IMMR + 0x11018). This is strange because in the tcfr field of the parameter block, I am putting a 0 in bit 6 (DTB; should select the 60x bus). I've checked the errata and there is nothing about this bit being other than 0 for 60x and 1 for local bus.

 

0 Kudos
Reply