I am currently upgrading a project from the FRDM-KL27Z to the new FRDM-KL82Z, which means using the standalone KL82Z SDK as it has not been integrated with KSDK 1.3 yet. I've been walking through my source files and testing the code that uses the SDK drivers such as SPI, I2C, etc. Everything I tested either worked immediately or needed minor modification until I started in on the I2C Master driver (blocking).
I am using the I2C1 driver to communicate with an Atmel ATECC508 CryptoAuthenticator IC. The code I built on top of the I2C driver wasn't working so I decided to start from scratch (with an SDK driver example) to see if I was missing something. I am using the i2c_blocking_master_example_frdmkl82z project as a testing ground and only made modifications necessary to use I2C1 instead of I2C0 which is the default bus.
These modifications included:
- Change hardware_init() to configure I2C1_IDX instead of I2C0_IDX
- PORTC10 is used for SCL
- PROTC11 is used for SDA
- Changed I2C_DRV_MasterInit to use instance number 1
- Commented out the demo code and replaced with a single call to I2C_DRV_MasterSendDataBlocking() using instance number 1
NOTE: My problem is very similar to the question found here: K22 I2C SDK Driver behaving strangely? (As in failing...) but the suggestions there did not help.
The issue I'm experiencing is that it appears the i2c master interrupt handler is not getting called when using I2C_DRV_MasterSendDataBlocking(). This is what I know:
- Master sends a start condition successfully (Oscope)
- Master sends the slave device address successfully (Oscope)
- Slave ACKs the device address successfully (Oscope)
- This is where the transaction stops and the driver returns kStatus_I2C_Timeout every time
(Above is my Oscope readout confirming the device address of 0xC0 is sent and ACK'd by slave)
What I've tried:
- The suggestions here: K22 I2C SDK Driver behaving strangely? (As in failing...)
- Confirming the same code works on the FRDM-KL27Z using SDK 1.3 (Yes it does)
- Walked through SDK calls and confirmed that I2C_HAL_SetIntCmd(baseAddr, true) is called before sending the slave address. (Enabling interrupts)
- I've tried re-installing the KL82Z standalone SDK and rebuilding ksdk_platform_lib_KL82Z7. No change.
- KL27Z uses PE Micro debugger and KL82Z uses JLink debugger (should that matter?)
- I've tried running the i2c driver with debug running and after a power-on-rest without debugger running. Same result.
- I've tried resistances from 1K to 10K for the bus pull ups. Same result)
- Varying baud rates
- I2C1 configured as open drain with 5.6K pull-up resistors (I've tried resistances from 1K to 10K. Same result)
- KDS 3.1.0
I don't know what else to try since the device does indeed ACK its own address, but the master driver does not seem to "receive" the ACK and follow up with transmitting the byte data to the slave device, indicating that the issue lies in interrupt handler not getting called which I've confirmed with breakpoints in the handler. Please help!