Skip to main content
Angle
Associate III
October 17, 2022
Solved

Serial clock and Serial data on SPC5STUDIO evaluation board

  • October 17, 2022
  • 3 replies
  • 2738 views

Hi,

May i know which pin on SPC57S-Eval kit board use for serial clock and serial data?

I want to connect the gyroscope sensor to the board.

This topic has been closed for replies.
Best answer by ODOUV.1

Hello,

this detect_device function is trying to detect an I2C slave device by its I2C address in range [0x8 .. 0x7F]

for each address (so for each device), it trye to read 2 bytes from device register 0x00

in case of read success, it means a device was found at address "dev_addr"

uint8_t data[2] => because we try to read 2 bytes, sot we need a buffer of at least 2 bytes

Best regards.

3 replies

ODOUV.1
ST Employee
October 17, 2022

Hello,

I understand that you want to control a sensor through I2C (1 serial clock line SLK + 1 serial data line SDA)

SPC57S MCU have no I2C hardware module, but use can use 2 PINOUTs programmed as GPIOs in strong mode in the pin-map wizard, then configure and use a software I2C driver to control the external device.

We have no I2C demo for SPC57S to provide but you can take as example this software I2C demo: "SPC560Dxx_RLA I2C Test Application for Discovery" which is based on a SPC560D and is using 2 GPIOs to do the same.

Best regards

Angle
AngleAuthor
Associate III
October 18, 2022

Okay found it.

But can i know why it use set as a i/o instead of only output?

0693W00000UoE0PQAV.png 

and why ouput opendrain ?

0693W00000UoDz2QAF.png

ODOUV.1
ST Employee
October 18, 2022

Hello,

>>But can i know why it use set as a i/o instead of only output?

The I2C standard defines SDA and SCL lines as bidirectional, SDA because the slave must acknowledge to the master, SCL because the slave can become the master.

>>and why ouput opendrain ?

In I2C standard, the SDA and SCL lines are configured in pull-up with a resistor connected to VDD to force the state to HIGH. Then when the master and slaves want to communicate, they need to force the line state to LOW, it means the PINOUT must be configured in open drain.

Best regards.

Angle
AngleAuthor
Associate III
November 7, 2022

Hi, may i know why the device adress using the 0x08U instead of 0x6B? and why data [2] ?

and i got confuse for the driver setting. since the pinout using the GPIOs, so how can i know which driver i using? in the example, it enable the driver 1.

0693W00000WHXaYQAX.png

ODOUV.1
ODOUV.1Best answer
ST Employee
November 7, 2022

Hello,

this detect_device function is trying to detect an I2C slave device by its I2C address in range [0x8 .. 0x7F]

for each address (so for each device), it trye to read 2 bytes from device register 0x00

in case of read success, it means a device was found at address "dev_addr"

uint8_t data[2] => because we try to read 2 bytes, sot we need a buffer of at least 2 bytes

Best regards.

Angle
AngleAuthor
Associate III
November 8, 2022

okay then if i want to read the data from the gyroscope, so just need to add another adress?

ODOUV.1
ST Employee
November 8, 2022

Hello,

In case you know the address of your slave device, you do not need to use the detect function.

You will just read and write in your device registers with dev_addr=0x6B if 0x6B is the actual address of your gyroscope.

Best Regards.