Problem regarding ASF4 API and I2C.

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Hey all. 

 

I'm using a samd21g18a, and trying to connect it to an IMU using an I2C connection. I've set up my chip with atmel start, but am currently experiencing problems when debugging. 

 

I am using the ASF4 functions included in the hal folders, that are generated when using atmel start. The functions can be found here: 

http://atmel-studio-doc.s3-websi...

 

In the sidebar navigate to I2C Master Sync -> Functions. 

 

Here, the functions i2c_m_sync_cmd_write and i2c_m_cmd_read are defined. They have specific sequences specified in the manual, in the way that the protocol is set up. 

 

To communicate with my IMU though, a different sequence is used. Both the read and write functions from ASF4 have: sta->address(write)->ack->reg address->ack->resta->address(read)->ack->reg value->nack->stt.

 

This works alright for reading informations from the registers of the IMU, but when it comes to writing, the sequence is different, and therefore incompatible. If you look at this link: https://invensense.tdk.com/wp-co...

on page 30 chapter 6.3 I2C communications protocol. The singlebyte read sequence is identical, but the write is different. 

 

I've been looking in the function definitions of i2c_m_sync_cmd_write, but can't seem to find where i must make changes to get them to communicate. 

 

Is there any workaround for this? My logic analyser sees proper I2C communication the one way, but nothing happens the other. 

The files with the functions are attatched. 

 

 

 

 

Attachment(s): 

Last Edited: Thu. Sep 3, 2020 - 07:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Victosroeby.

 

Have you checked if you have configured the I2C clock stretching?

While using the ASF3 I2C API to communicate with the BNO055 I had to set the clock stretching to the max, otherwise it did not work at all.

 

Regards!
FS.