cancel
Showing results for 
Search instead for 
Did you mean: 

Serial clock and Serial data on SPC5STUDIO evaluation board

Angle
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
ODOUV.1
ST Employee

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.

View solution in original post

9 REPLIES 9
ODOUV.1
ST Employee

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

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

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.

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
ST Employee

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.

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

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.

I read and write as in my device registers using the 0x3B adress with dev_addr = 0x68.But i got no data reading flow. This is my code. May i know where is my mistake?

0x68 = gyro sensor adress module

0x3B is accelerometer adress to read the data

0693W00000WHxbrQAD.png the output

0693W00000WHxcBQAT.png

Are you sure you need to write 2 bytes at address 0x3B before to read ? if yes, is data is containing the 2 good bytes before to write ?

are you sure you need to read 6 bytes to reg_data ? you do not check the result of i2c_lld_read ?

I am suspicious with this convertion line Ax = acc_x_rax / 16384.0;

you mix int16 wiht floats

I suggest you to just print and debug acc_x_raw values