I2C on Pro Micro

For the discussion of Arduino related topics.

Moderator: phalanx

I2C on Pro Micro

Postby rgsparber » Sat Jul 15, 2017 5:42 pm

I have a Pro Micro 5V/16 Mhz and want to use the I2C. What libraries should I include?

I tried Wire and HardWire but neither of them turn on the weak pull up resistors which tells me they are not compatible. When I add external 1K resistors, I see clock and data activity. I was getting the correct address but no ACK from an MCP23017 connected to the I2C bus. I tried a few things and thought I got back to the original configuration but the activity has changed. It was the correct address with a read bit but no ACK. Now I just see 010 between START and STOP.

Thanks,

Rick
rgsparber
 
Posts: 8
Joined: Tue Jul 04, 2017 4:28 pm

Re: I2C on Pro Micro

Postby rgsparber » Sun Jul 16, 2017 8:42 am

I see that the serial clock out of the Pro Micro is 1 MHz and the highest frequency "mode" of the MCP23017 is 1.7 MHz. There is a note that says the SCL should be at least 16 times slower than the slave. I played with TWBR prescalers but could not change the SCL frequency. This was done within twi.c. Is there another place I should be going to lower the SCL rate?
rgsparber
 
Posts: 8
Joined: Tue Jul 04, 2017 4:28 pm

Re: I2C on Pro Micro

Postby rgsparber » Tue Jul 18, 2017 7:42 am

In looking at the spec sheet, I can see that given a prescaller value of 1 (both bits = 0), a TWBR of 18 decimal should generate a SCL of 100 KHz. In twi.c there are two places TWBR is set. I commented out both lines and replace them with TWBR = 0x12 without the ";". The compiler found the error which proves I'm changing the correct file. Then I added the ";" and it just flagged that I'm not using the variable "frequency". The SCL rate did not change. It is still 1 MHz. The logic analyzer see 1.008 MHz. I changed TWBR to 0 and there was no change to SCL rate.

I searched all other code that is being compiled and found no other instances where TWBR is touched.

Has anyone out there successfully used the I2C on the Pro Micro?

A TWBR of 0 will cause a SCL of 1 MHz.
rgsparber
 
Posts: 8
Joined: Tue Jul 04, 2017 4:28 pm

Re: I2C on Pro Micro

Postby rgsparber » Sun Jul 23, 2017 6:36 am

I found the root cause of my problem: The "Wire" folder existed in Program Files (x86)/Arduino/libraries and also in my sketchbook/libraries. No error messages generated during compilation. I removed the copy in my sketchbook and now button runs as expected.

Rick
rgsparber
 
Posts: 8
Joined: Tue Jul 04, 2017 4:28 pm


Return to Arduino

Who is online

Users browsing this forum: No registered users and 1 guest