Problem using high level I2C API

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

cross mob
lock attach
Attachments are accessible only for community members.
DavideM
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

Hi everyone,

I'm attempting to implement a I2C communication between a PSoC 6 (CY8CPROTO-BLE), which acts as a master, and a PSoC 5LP (CY8CKIT-059), which acts as a slave.

The slave part is fully working, since I tested it with the Bridge Control Panel. On the master side, I'm struggling to make the high level API functions work correctly.

Right now the firmware of my master device sends 2 bytes per write transaction: the first byte is always 0, the second bytes goes from 0 to 255, then from 254 to 0, and so on every 10 ms. If I use the high level function Cy_SCB_I2C_MasterWrite and then I check the Master Status I always get CY_SCB_I2C_MASTER_BUSY. I also implemented a 1 second timeout if this occurs, and after this time elapsed I disable and enable again the SCB block, but the next transaction always results in a CY_SCB_I2C_MASTER_BUSY flag.

If, instead, I use the low level functions (Cy_SCB_I2C_MasterSendStart, Cy_SCB_I2C_MasterWriteByte, Cy_SCB_I2C_MasterSendStop) everything is working properly. What could be the cause of this behaviour?

I attach here my workspace, where you can find 3 commented projects:

  • Slave (the project for the slave device, running on a PSoC 5LP)
  • Master_PSoC_2 (the project for the master device, running on a PSoC 6)
  • CE220818 (the code example from which I took inspiration for the PSoC 6 master code)

Thank you!

Davide

0 Likes
1 Solution
DavideM
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

Just realized that I forgot to enable the interrupt in the NVIC. After adding: NVIC_EnableIRQ((IRQn_Type) I2CM_SCB_IRQ_cfg.intrSrc); ​everything works as expected.

View solution in original post

0 Likes
1 Reply
DavideM
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

Just realized that I forgot to enable the interrupt in the NVIC. After adding: NVIC_EnableIRQ((IRQn_Type) I2CM_SCB_IRQ_cfg.intrSrc); ​everything works as expected.

0 Likes