I2C to SPI Bridge

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

I2C to SPI Bridge

I2C to SPI Bridge

  • Background:

NXP SC18IS602B I2C bus to SPI bridge chip is using TSSOP16 package, which is 16 leads; 0.65 mm pitch; 5 mm x 4.4 mm x 1.1 mm body. pastedImage_1.png

Customer requires to use a smaller package to emulate the SC18IS602B function.

Kinetis L series MKL03Z16VFK4R product uses QFN24 package with 4 mm x 4 mm x 0.58 mm body.

pastedImage_6.png

  • Demo Overview

The I2C to SPI Bridge demo provides a replacement solution demo of SC18IS602B chip. The demo is based on FRDM-KL03Z board using I2C0 module as I2C slave and SPI0 module as SPI master. Provided data buffer size is 400bytes. The demo software is based on KSDK V2.0 for FRDM-KL03Z software.

I2C slave interface:

Pin number                 Function              FRDM-KL03Z jumper

PTB3                          I2C0_SCL           J2-10

PTB4                          I2C0_SDA           J2-9

 

SPI master interface:

Pin number                 Function              FRDM-KL03Z jumper

PTA5                           SPI0_SS             J2_3

PTA6                           SPI0_MISO         J2_5

PTA7                           SPI0_MOSI         J2_4

PTB0                           SPI0_SCK           J2_6

 

INT pin (indicates if I2C to SPI Bridge allows i2c master start a new i2c transfer, low is active)

Pin number                 Function              FRDM-KL03Z jumper

PTB11                        GPIO output         J2_2

 

Connect I2C master with FRDM-KL03Z I2C slave interface and connect SPI slave with FRDM-KL03Z SPI master interface; Connect FRDM-KL03Z GND to I2C master and SPI slave before add power to those boards.  Below is the hardware platform connection way:

1.jpg

  • I2C to SPI Bridge Demo Function

For the KL03 chip with one SPI0_PCS0 chip select pin, I2C to SPI Bridge demo only supports function ID 0x01 as SPI write command.

For example: if i2c master want to write 8bytes (0x21,0x22...0x28) to SPI slave, the i2c master needs to send below data to FRDM-KL03Z board:  

[START] + [I2C Slave address+/W] + [0x01](Function ID) + [0x21](data 1) + [0x22](data 2) + ... +[0x28](data 8) + [STOP]  

 

I2C to SPI bridge demo supports Function ID 0xF0 to configure SPI interface: There provides four SPI baud rate: 6Mbps/3Mbps/1.5Mbps/1Mbps. More detailed info, please check below picture (picture abstracted from SC18IS602B datasheet):

For example: customer could configure SPI baud rate to 3Mbps with send below data to FRDM-KL03Z board:

       [START] + [I2C Slave address+/W] + [0Xf0](Function ID) + [0x01](data 1) + [STOP]

  • Hardware Platform

The demo is based on FRDM-KL03Z board, using internal IRC48M clock as system and bus clock source. There doesn’t need external clock source.

pastedImage_10.png

  • Toolchain supported

- IAR embedded Workbench 7.60.1  (Tested)

- Keil MDK 5.18a

- GCC ARM Embedded 2015-4.9-q3

- Kinetis Development Studio IDE 3.2.0

  • Running the Demo
  1. Connect a USB cable between the host PC and the USB port on the target board.
  2. Open a serial terminal with the following settings:

    - 9600 baud rate

    - 8 data bits

    - No parity

    - One stop bit

    - No flow control

  1. Download the program to the target board.
  2. I2C master start to configure SPI interface

     I2C to SPI bridge board I2C address is 0x7E.

1.jpg

  1. I2C master write data to SPI slave

   I2C master write 10bytes to SPI slave, it will send 11bytes (includes one function ID 0x01). The first data is 0xAA and the last data is 0x22.

   After I2C to SPI Bridge receive the data, it will send 10bytes to SPI slave.

  1.jpg

     I2C to SPI Bridge receive 10 bytes

1.jpg

1.jpg

    I2C to SPI Bridge send 10bytes to SPI slave

1.jpg

1.jpg

  1. I2C master read data from SPI slave

   I2C master read 10bytes(0x10 to 0x19) from SPI slave need to write data to SPI slave at first, then read data from I2C to SPI bridge data buffer directly.

   Here just shows read 10bytes from I2C to SPI bridge data buffer.

1.jpg

1.jpg

1.jpg

Attached I2C to SPI Bridge demo software default location is:

..\SDK_2.0_FRDM-KL03Z\boards\frdmkl03z\user_apps\i2c_to_spi

Attachments
Comments

Hello,

when I use the chip I can only send 12 IC2 bytes at once (Address + FunctionID + data).

If I send more than 12 Bytes the chip pull the clock low, but not back (clock stretching).

Sometimes I get no acknowledge for the IC.

The IC has a buffer of 200 bytes but I can use only 10 bytes.

On you pictures, I see that you send only 12 bytes. (you send only 10 data bytes).

Do you have the same issue like me?

Hi,

I had tested the data buffer with 400 bytes.

The I2C master send 400 bytes to I2C to SPI bridge without any problem, the SPI slave could get those 398 bytes sent from I2C master. 

best regards,

Mike

Hello,

how can you send 400bytes at once?

The chip has only a buffer of 200 bytes.

Hi,

I am using KL03 simulate the SC18IS602B chip and extend the data buffer to 400bytes.

Please check the i2c-to-spi code:

pastedImage_4.png

And I do a test to send 400 bytes from I2C master, which works normally as below pictures show:

pastedImage_5.png

pastedImage_7.png

pastedImage_8.png

pastedImage_6.png

pastedImage_13.png

I2C data start with 0x1, 0x21

pastedImage_9.png

I2C data stop with 0xad, 0xae, 0xaf

pastedImage_10.png

SPI master send data start with 0x21, 0x22 ... :

pastedImage_1.png

SPI master send data stop with 0xad, 0xae and 0xaf:

pastedImage_12.png

Thank you for the attention.


Have a great day,
Ma Hui

I can configure the chip but get no clock or data when i send address+functionid+data.  Any ideas would be welcome.  Im using arduino as controller.

Please check the SPI pins related configure.

I can configure this chip and it will run for some time and then it stops responding to I2C commands and the SPI bus appears to stop working correctly.  No MISO data and the clock rate changes from the 460 kHz that I set it to to 1.8 MHz.  Here is what the data looks like when it failsLogic Analyser screen shot.JPG

What's the SPI slave device you connected?

best regards,

Mike

No ratings
Version history
Last update:
‎01-22-2017 07:36 PM
Updated by: