- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Labels:
-
XMC
- Tags:
- xmc1302
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @Rex_xu ,
You can change the codes like and try again:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Regards,
Owen_Su
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Owen
It seems to use I2C master APP, I will check with that and feedback to you.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
Hope this can help you.
Regards,
Owen_Su
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @Rex_xu ,
You can change the codes like and try again:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)'.
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