cancel
Showing results for 
Search instead for 
Did you mean: 

ST9+ I2C

sandra
Associate II
Posted on April 01, 2003 at 22:55

ST9+ I2C

13 REPLIES 13
sandra
Associate II
Posted on May 17, 2011 at 11:32

Dear All

I'm using ST9+ and trying to I/F to Z86229 via I2C. I'm running into following problem

- EV5, EV6, EV8 -- NO problem (start, ack, address)

- problem is that the I2CDR contains address value regardless of data loaded for o/p (in this case 28h).

- since the mirco is soldered to the board I can NOT run emulator

- I'm running RS232 debug and all data sent/received is logged and printed.

- I2C is configured for 100 KHz

Is there any bit(s) in SR1,2 that I need to check for.

I'm using Error and Xmitt interrupt functions to check for SB, ADDTX, BTF, TRA and EVF flags (when it works DMA will be used.

Any help would greatly be appreciated

Nick Crljenica

johanpauvert2
Associate II
Posted on May 17, 2011 at 11:32

I have used the I2C peripheral in master mode no DMA with both ST92F120 emulator and ST92F120V1Q7 and it works fine with me. Speed is 200kHz and up but I just ran a quick test at 100kHz and it is still ok

I perform my I2CDR address load upon EV5 and my I2CDR data load upon EV8 (your case which seems to be write/transmitter and master mode).

These are some ideas...

- if your interrupt flags are not clear correctly you may loop forever in the same piece of code. And maybe this code performs the I2CDR address load.

- how do you define the string to be transmitted (address + data) ? If it is a table, make sure that your pointer is incremented to the next byte, here your first data byte

Regarding your 2nd question, the BTF flag will tell you when an EV8 has occured.

Skywalker
Posted on May 17, 2011 at 11:32

The enclosed ST92F120 program is an example of I2C communication using the ST9 I2C peripheral.

It interfaces with a ST24C08 (8k serial I2C EEPROM). This code can be run on the ST9GP-EVAL evaluation board from ST.

I hope it will help you solving your issue.

Jojo

[ This message was edited by: jojo on 27-01-2003 22:16 ]

johanpauvert1
Associate II
Posted on May 17, 2011 at 11:32

Talking about I2C, I discover that the first revision of the ST92F150 emulator did not support I2C : there was a bug on the emuchip's I2C peripheral. This emuchip was tagged version 1.0A.

Latest emuchip revision, version 1.2, works fine

Breizh

sandra
Associate II
Posted on May 17, 2011 at 11:32

Thanks gentlemen for your input.

I scoped SDA line and I could see that the data I was sending out was correct even as DR register was displaying address byte. Please note that this is on my board and micro I/F to Zilog 86229 OSD IC.

Since my debug writes everything to the RAM buffer which is then dumped through RS232 port to the disk file and displayed. The program writes to the RAM from each interrupt routine, each byte send/received, the whole picture.

The I2C I/F has been tried from 20K to 100K with NO difference.

Any suggestion is welcome.

Nick

Posted on May 17, 2011 at 11:32

My only suggestion is to really add test code (pin toggle) to validate step by step your code. The ST92F120/F150 I2C peripheral spec is pretty straight foward. No big surprise.

Or maybe just one

: the I2C speed formulas are not correct !!! This is what I notice :

In fast mode , targeted I2C speed at INCLK = 24MHz, 200kHz

- formulas give us I2CECCR = 0x00 and I2CCCR = 0xA6

- scope

I2CECCR = 0x00 and I2CCCR = 0xA6 --> ~185kHz

I2CECCR = 0x00 and I2CCCR = 0xA2 --> ~200kHz

I2CECCR = 0x00 and I2CCCR = 0xA0 --> ~210kHz

In standard mode, targeted I2C speed at INCLK = 4MHz, 10kHz

- formulas give us I2CECCR = 0x01 and I2CCCR = 0x46

- scope

I2CECCR = 0x01 and I2CCCR = 0x42 --> ~2kHz

I2CECCR = 0x01 and I2CCCR = 0x46 --> ~5kHz

I2CECCR = 0x01 and I2CCCR = 0x60 --> ~10kHz

I got this issue on both ST92F120 and ST92F150, emulator and device. So, If you need a specific frequency, just tune your register as I did

I don't think this is the source of your communication problem. Nevertheless, keep this in mind because if you are around 100kHz, you may be in standard mode (speed < 100kHz) while your I2C is configured in fast mode and vise versa. This is not good, I guess : may this screw up some ST9 timing ???

Jojo

[ This message was edited by: jojo on 20-11-2002 03:52 ]

johanpauvert1
Associate II
Posted on May 17, 2011 at 11:32

I got another surprise with the ST92F150 I2C peripheral : the EV5 event happens to be generated twice. The address field is then generated twice

Pretty inconvenient, isn't it

Breizh

romain2399
Associate II
Posted on May 17, 2011 at 11:32

Yes, I saw this double start generation before with the ST92F150, but it is linked to the C-compiler.

Have a look at the assembler generated (*.lis file), if you do not specify any optimization option the control register is loaded twice.

Add any optimization option in the make file ( -O2 for example) and the double load disappeares, it will clean your problem.

[ This message was edited by: Romain on 20-11-2002 17:48 ]
Posted on May 17, 2011 at 11:32

FYI, It looks like the ST92F120 is not concerned by this double start bit generation. Code works fine even with no optimization.

Do we know where this difference between the ST92F120 and ST92F150 I2C peripheral comes from ? The 2 peripheral looks the same based on the datasheets.

Jojo