Giter Site home page Giter Site logo

Comments (12)

discoHR avatar discoHR commented on August 24, 2024 1

It's not the code, it's INA. I removed both usi_i2c_master and tinusaur-ssd1306xle code, disabled all interrupts and wrote my own I2C bitbanging code including autodetecting INA's slave address. There is aboslutely no response from INA at any slave address, it's not sending ACK at all. Thought it was working earlier but I was mistaking SDA going up for an ACK (technically, it's a NAK and it was going up because of the pullup, INA had nothing to do with it).

There is a lot of garbage on I2C bus immediately after power-up. Could be it's messing up INA's I2C but I added procedure for resetting INA's I2C bus before trying to talk to INA, same problem. INA's bus is reset when SDA or SCL are pulled low for at least 28ms.

Replaced R4 with 0 ohm resistor, same problem.

Checked optoisolator, signals seem to pass to both ends. There is about 4.2V on one end and 5V on the other but that shouldn't matter.

Removed optoisolator and tried accessing INA directly, same problem.

Either INA you sent me is dead or it's I2C doesn't work without a load. There is only 2.45 mV on the shunt resistor while the red LED is on, if it matters.

Ordered 2x INA219 from an EU seller, it will be faster than ordering from China.

Some screenshots...

I2C bus garbage on boot:
i2c-boot-garbage

Autodetection of INA's slave address, no ACK was ever received:
ina-autodetect-fail

Same as above but zoomed in and after improved ACK/NAK timing in the code. INA is not sending ACK. Pullup resistor is doing NAK, INA must pull it low for ACK.
ina-ack-fail

Further I2C timing improvements with releasing SDA earlier and proper termination of INA's reset sequence. Every xfer start has a green dot and every xfer stop has a red dot. 5 us minimum per high/low and still no sign of life from INA.
further-i2c-timing-improvements

from c64-saver-bwack.

bwack avatar bwack commented on August 24, 2024 1

SDA and SCL are mixed up.

from c64-saver-bwack.

bwack avatar bwack commented on August 24, 2024

I think it got stuck here in the usi_i2c_master library

	while (!(PIN_USI & (1<<PIN_USI_SCL)));		//Wait for SCL to go high

	#ifdef I2C_FAST_MODE
		USI_I2C_WAIT_HIGH();
	#else
USI_I2C_WAIT_LOW();

sorry too long ago I don't remember.. I suspect the ssd1306 library, or the way we use it. maybe it needs to be freed or something. At least the i2c_master expects a state that it never gets. Could be a state set in the TWI register. Not sure.

Back when I tested this I had my scope up and I could see the I/Os got stuck.

from c64-saver-bwack.

bwack avatar bwack commented on August 24, 2024

It could be both the ina and the issue I descibed above. Just beware of that.

from c64-saver-bwack.

bwack avatar bwack commented on August 24, 2024

maybe the voltage on the ina's VDD is too low because of the drop-out voltage in the 5V regulator driven at V_IN=5V. Edit: just checked. recommended is 3.3V, and absolute max is 6V. No problem there then.

from c64-saver-bwack.

bwack avatar bwack commented on August 24, 2024

Great work btw. Tell you what. I will hook up the addon-board to my c64 DIY PSU with ina219 voltage meter. I can easily unscrew the cables going to the ina and connect the addonboard and see if I get read-out on the PSU display (if you know, I have a C64 DIY PSU with ina219 and arduino pro micro)

from c64-saver-bwack.

bwack avatar bwack commented on August 24, 2024

Here are the I2C data recorded from my C64 DIY PSU with only INA219 on the I2C bus. The data rate is 100kHz. I have used the adafruits ina219 library. You can see how it at very first writes calibration bits, and it does that several times too. Second transfer is the configuration h00. No reset command (that would be most significant bit set to h00.

recorded from power on:

Start, h80 [ h40 | WR ], h05, h10, h00, Stop     set calibration register
Start, h80 [ h40 | WR ], h00, h3C, h1F, Stop     set config register
Start, h80 [ h40 | WR ], h02, Stop               request bus voltage register
Start, h81 [ h40 | RD ], h27, hD2 NAK, Stop
Start, h80 [ h40 | WR ], h05, h10, h00, Stop     another set config register
Start, h80 [ h40 | WR ], h04, Stop               request current register
Start, h81 [ h40 | RD ], h02, h9C NAK, Stop
Start, h80 [ h40 | WR ], h02, Stop
Start, h81 [ h40 | RD ], h27, hCA NAK, Stop
Start, h80 [ h40 | WR ], h05, h10, h00, Stop
Start, h80 [ h40 | WR ], h04, Stop
Start, h81 [ h40 | RD ], h02, h5D NAK, Stop
Start, h80 [ h40 | WR ], h02, Stop

from c64-saver-bwack.

bwack avatar bwack commented on August 24, 2024

This is from with your code. I have replaced the pullups on my board now. oled disconnected.


Start, h80 [ h40 | WR ] NAK, h05 NAK, h10 NAK, h00 NAK, Stop
Error
Error
Start, h80 [ h40 | WR ] NAK, h00 NAK, h3C NAK, h1F NAK, Stop
Error
Error
Start, h80 [ h40 | WR ] NAK, h01 NAK, Stop
Error
Error
Start, h81 [ h40 | RD ] NAK, hFF, hFF NAK, Stop
Error
Error
Start, h80 [ h40 | WR ] NAK, h02 NAK, Stop
Error
Error
Start, h81 [ h40 | RD ] NAK, hFF, hFF NAK, Stop
Error

from c64-saver-bwack.

discoHR avatar discoHR commented on August 24, 2024

I tried with TinyWireM for Arduino, same problem. It's highly unlikely that both codes are faulty. The problem is most likely on the addon board itself. I've replaced 3 INAs so far and none of them sent any ACKs ever no matter what code I use. Please fix the board.

screenshot 2018-11-03 at 13 02 51

screenshot 2018-11-03 at 13 03 20

from c64-saver-bwack.

bwack avatar bwack commented on August 24, 2024

let me try this first.

from c64-saver-bwack.

bwack avatar bwack commented on August 24, 2024

Regarding the title. The two libraries ssd1306 and discoHR's ina219 go well together. Example shown in the hans-doodle branch.
https://github.com/bwack/C64-Saver-bwack/tree/hans-doodle/addon%20board/src

from c64-saver-bwack.

bwack avatar bwack commented on August 24, 2024

I'm closing this issue. Open a new one if you encounter a new problem.

from c64-saver-bwack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.