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
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?
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.
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
Thanks for posting your solution. I would have never guessed that was causing an issue.
A different question on this topic. The Pro Mini apparently does not have pullup resistors on the A4 and A5 (I2C) pins, but does have solder pads next to them. Are the pads connected to pullup resistors on board, so I can just jumper the pads to the pins, or do I need to connect the pads to the pins with resistors? If the latter, are 4.7K resistors appropriate? And can you include a photo of the proper installation (not sure how to install resistors this way). Thanks, Eric