XMC1302 how to read CYPD3177 specific register through i2c

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Rex_xu
Level 2
Level 2
Distributor - Zenitron(GC)
25 sign-ins 10 replies posted 10 sign-ins

Dear,

I want to use I2C to ready CYPD3177's register, do you have the sample codes for how to read a specfic register?

CYPD3177 slave address: 0x08

Register address : 0x1400

expected return value is 0x02 (success)

Thanks.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Owen_Su
Moderator
Moderator
Moderator
250 solutions authored 500 replies posted 50 likes received

Hi, @Rex_xu ,

    You can change the codes like and try again:

Owen_Su_0-1661319274923.png

    I also found an example which is for a two-board I2C communication, you can have a look at it. Hope this can help you.

Regards,

Owen_Su

View solution in original post

0 Likes
12 Replies
lock attach
Attachments are accessible only for community members.
Owen_Su
Moderator
Moderator
Moderator
250 solutions authored 500 replies posted 50 likes received

Hi, @Rex_xu ,

    Here is the website which you can find the example codes of I2C: XMC1300_I2C . You can download the code and the application notes in the link above(in the section 'Documents--Application Notes'). Hope this can help you.

Owen_Su_0-1660727595100.png

Regards,

Owen_Su

0 Likes
lock attach
Attachments are accessible only for community members.
Rex_xu
Level 2
Level 2
Distributor - Zenitron(GC)
25 sign-ins 10 replies posted 10 sign-ins

Hi Owen

Thank you for your reply. I write my code as below based on the method of how to read data from CPD3177. (You can refer to the screenshot)

The problem is I2C Master transmit only can send 8bit data, but register address is 0x1400, it caused the large integer implicitly.

Could you please give me some advice on that, and also wether there's something wrong with my code for the read logic? Thanks.

Rex_xu_0-1660874236373.pngRex_xu_1-1660874299569.png

 

0 Likes
lock attach
Attachments are accessible only for community members.
Owen_Su
Moderator
Moderator
Moderator
250 solutions authored 500 replies posted 50 likes received

Hi, @Rex_xu ,

    For the first problem:  I2C Master transmit only can send 8bit data, but register address is 0x1400, it caused the large integer implicitly. You can send the high byte(8 bits) and low byte(8 bits) of the register address successively.

    I tested your codes with my XMC1300, there is something wrong with the part 'wait until ACK' and the following parts, the data flow can't go through it. Maybe you can follow other example codes to recode this part. Hope this can help you.

Regards,

Owen_Su

0 Likes
Rex_xu
Level 2
Level 2
Distributor - Zenitron(GC)
25 sign-ins 10 replies posted 10 sign-ins

Hi Owen

It seems to use I2C master APP, I will check with that and feedback to you.

Thank you.

0 Likes
lock attach
Attachments are accessible only for community members.
Rex_xu
Level 2
Level 2
Distributor - Zenitron(GC)
25 sign-ins 10 replies posted 10 sign-ins

Hi Owen

Good Day.

I have tried the code followed by I2C master APP. I think something wrong was happend. My code is as below. I cannot catch the I2C log info, that was strange. But the Error LED is light on, that I think code was runing. I provide you the correct I2C log and command.

I don't know how to go on. Could you give me some advise or help? Thanks.

Rex_xu_1-1661139047273.png

 

Rex_xu_0-1661139013783.png

 

Rex xu

0 Likes
Owen_Su
Moderator
Moderator
Moderator
250 solutions authored 500 replies posted 50 likes received

Hi, @Rex_xu ,

    Follow the example "I2C EXAMPLE XMC45" can easily understand the logic of I2C, it can be used in XMC13(some functions name and symbols need to change).

    For the problem that you can't  catch the I2C log, here you can try this:

    1) change this 'false' to 'true' in I2C_MASTER_Receive. Here is a notice: if Send_stop is set to TRUE, bus_acquired flag is set to FALSE; if Send_start is set to FALSE and bus_acquired is set to FALSE then API will return an error.

Owen_Su_0-1661153456145.png

    2) here xmc13 is your master, 0x08 is your slave address, you should use a scope to check if the corresponding address has receive the correct data? Or you can add an judgement after the transmit function. If the transmit data is correct, then you should check your slave equipment if there is something wrong with the transmit. 

Owen_Su_1-1661153854767.png

    Hope this can help you.

    Regards,

    Owen_Su

 

0 Likes
Rex_xu
Level 2
Level 2
Distributor - Zenitron(GC)
25 sign-ins 10 replies posted 10 sign-ins

Hi Owen

It seems doesn't work out. If I use xmclib, it will stuck in while((XMC_I2C_CH_GetStatusFlag(i2c) & XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED) == 0U). Something wrong with the ACK?

0 Likes
Owen_Su
Moderator
Moderator
Moderator
250 solutions authored 500 replies posted 50 likes received

Hi, @Rex_xu ,

    Can you share your project file with us? It seems that you follow the example 'Gateway_XMC13' to write and read slave, then you need to make sure the state and configuration  of your slave are correct. Base your statement, can I  confirm that the transmition of your master works well?  

 

0 Likes
lock attach
Attachments are accessible only for community members.
Rex_xu
Level 2
Level 2
Distributor - Zenitron(GC)
25 sign-ins 10 replies posted 10 sign-ins

Hi Owen

I found the issue why I2C not work, it turns out the pull up resistance requires more bigger.

Now it works, but the code will stuck in the judgement of receive command. "while(tx_completion_0 == 0);"

I can capture the correct waveform, and the received data is correct. but it stuck, and can't go to next command.

Could you help me on this? Thanks.

Rex_xu_0-1661306704050.png

 

0 Likes
lock attach
Attachments are accessible only for community members.
Owen_Su
Moderator
Moderator
Moderator
250 solutions authored 500 replies posted 50 likes received

Hi, @Rex_xu ,

    You can change the codes like and try again:

Owen_Su_0-1661319274923.png

    I also found an example which is for a two-board I2C communication, you can have a look at it. Hope this can help you.

Regards,

Owen_Su

0 Likes
lock attach
Attachments are accessible only for community members.
Rex_xu
Level 2
Level 2
Distributor - Zenitron(GC)
25 sign-ins 10 replies posted 10 sign-ins

Thanks Owen,

I finallly use xmclib to pass the code. Now I have two questions,

first, the code only can read 1 byte received data, what can we do if want to read 4 bytes?

second, can you help to provide the delay function code? I want XMC1302 to read the register after CYPD3177 is power up and ready.

Another question is do you familiar with OPTIGA TRUST device?

Thank you very much.

Rex Xu

0 Likes
Owen_Su
Moderator
Moderator
Moderator
250 solutions authored 500 replies posted 50 likes received

Hi, @Rex_xu ,

   1) You can refer to other example like 'Blinky1' , in the c source file 'IIC. c' , there is the function 'Read received data: Data = XMC_I2C_CH_GetReceivedData(I2C_CH_NUM)'.

Owen_Su_0-1661329291421.png

    2) You can find the delay function in this website: Delay-Functions ;

    3) If you have any questions about OPTIGA TRUST device, you can open another thread on the community, and there will have another support team to answer you questions.

Hope this can help you.

Regards,

Owen_Su

0 Likes