Butcher

Double Buffered I2C Difficulties (eg. KL27)

Discussion created by Butcher on Oct 11, 2015
Latest reply on Feb 25, 2018 by Butcher

Hi All

 

Although the migration guide for moving from the KL25 to the KL27 [http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4997.pdf ] states that the fact that the KL27 has double-buffered I2C has no impact on the software it has been known for some time that KL25 (or other KL or K parts) I2C code will not run correctly on a KL27.

Furthermore, the recommended software flow diagram for the KL27 in its user's manual is rather different from that in the KL25 user's manual.

 

So finally this source or difficulties was analysed in some detail by testing an I2C master/slave configuration involving a KL25 (standard single-buffered I2C which causes no troubles) and a KL27 (with the new double-buffered design).

Tests were alternated between the KL25 being master to the KL27 slave and the KL27 being master to the KL27. The behavour (interrupt and status register reactions) were compared and workarounds made in the KL27 software until operation was correct for all tests in both configurations.

 

The attached drawings show the results, indicating the differences (some minor and having no software impact) and others requiring extra interrupt handling to avoid the original driver either hanging in interrupt loops (on KL27) or the (KL27) I2C master sending rubbish when it should send the slave address.

For simplicity, the double-buffered capabilities (queuing two bytes) is not utilised so that the reasons for incompatibility with standard KL I2C drivers is obvious.

 

Note the worst behaviour found (detailed also in the drawings) was that it is not possible to send a "repeated start condition" by writing the repeated start control and sending the slave address (as the KL25 does) because the KL27 will then send the repeated start but with a slave address equal to the last data byte that it had sent. The only way to do this that could be identified was to command the repeated start, wait for it to actually have completed on the bus (using the KL27's new start condition interrupt) and then sending the required address.

 

If any one has comments (or personal experience) I would be interested in hearing them.

 

Regards

 

Mark

 

 

 

 

 

Kinetis: http://www.utasker.com/kinetis.html

KL25: http://www.utasker.com/kinetis/FRDM-KL25Z.html / http://www.utasker.com/kinetis/TWR-KL25Z48M.html

KL27: http://www.utasker.com/kinetis/FRDM-KL27Z.html / http://www.utasker.com/kinetis/Capuccino-KL27/Capuccino-KL27.html

For the complete "out-of-the-box" Kinetis experience and faster time to market

 

Out-of-the-box support for 46 Kinetis boards and 10 IDEs (460 combinations from a single code source with no porting required)

Attachments

Outcomes