Does the i2c_smbus_write_i2c_block_data function send the high or low 8 bits of each value in the displaybuffer first? It may be that it's sending the wrong bits initially. The low bits must be sent first (they're the ones connected to the segment). If it's sending the high bits first, then that may be the issue.
When I did this, I was sending them as follows:
- Code: Select all
i2c_write(0x70 << 1 + 0x00); // send the address
i2c_write(0x00); //starting register
for (int i = 0; i < 8; i++) {
i2c_write(displayBuffer[i] & 0xFF);
i2c_write(displayBuffer[i] >> 8);
}
I do it in a series of discrete 8 bit transfers.
The project I'm working on is a Peugeot 206 GTi, which has currently ground to an exacting and complete halt! It turns out that when I wrote this up last year that my wife was pregnant with our second child and I rather grossly underestimated the time required to look after 2 babies under 1.5 years!
Anyway, the idea was that I was developing a monitoring box that has a 20Hz GPS, accelerometer and gyrometer which would interface with a MegaSquirt V3 ECU controlling the car's fuel and spark. Since the plan was for it to be a dedicated track car, the work I was doing would substitute as a dash and datalogger. It would also provide a synchronised trigger to a couple of GoPro cameras scattered around the car.
At this stage, the 206 will be going back on the road, ready to drive another few 10's of thousands of kilometres until I find enough time to do the work to turn it into a track car. Mechanically it was getting pretty close, but electrically and safety wise, it still had someway to go, and they're the bigger jobs, so back to the road it goes for now.
Have attached my code here. It will need some additional files to compile as is, but it should be enough to show how it works.
i2c.tar.gz
- i2c source
- (2.21 KiB) Downloaded 19 times