Communicate with the NXP SAA1064 I2C controller

I’ve been trying during a couple days to communicate via I2C with this device, in order to control a 4-digit seven-segment module , but i have to recognise that I´m totally lost.

I’ve made a simple counter to check the communication, but it doesn’t work::
`local Segment = [63, 6, 91, 79, 102, 109, 125, 7, 127, 111];//7Segment leds [0 to 9]

local Dig1=0;
local Dig2=0;
local Dig3=0;

//CONFIGURE Address Y BITs Control
local Add =0x70; //[70,72,74,76]
local SubAd =0; //Sub Adress
local Ctrl_B= 0x76; //Control Bits

function Counter(){
if (Dig1==10){
if (Dig2==10){
if (Dig3==10) Dig3=0;

function Write(){

local SubAd_Data=format("%x %x %x %x %x",SubAd, Ctrl_B, Segment[Dig1], Segment[Dig2], Segment[Dig3]);




imp.configure(“Imp Contador”, [], []);

I also tried other code, and doesn’t work neither:
hardware.i2c12.write(0x70,"\\x00\\x77");//turns on all the segments

But while I was changing the lenght of the data I could check with the oscilloscope that the lenght of the signal wasn´t changing. Why could be happening this?

I have to mark that the SAA1064 works at 5V, but I think that I have adaptated correctly the voltage logic of the IMP with the 4050B converter.

Do you find any mistake or know what could be happening?

The datasheet for the SAA1064 can be found here.

Ok, so the main issue here is how to write to I2C. I2C expects raw bytes, but you’re sending it hex bytes in text form, which will confuse it rather :slight_smile:

Change this:

local SubAd_Data=format("%x %x %x %x %x",SubAd, Ctrl_B, Segment[Dig1], Segment[Dig2], Segment[Dig3]);

to this:

local SubAd_Data=format("%c%c%c%c%c",SubAd, Ctrl_B, Segment[Dig1], Segment[Dig2], Segment[Dig3]);

(ie, just the raw bytes).

You may also want to print the result from the hardware.i2c12.write() command to see if the transaction succeeded.

Other things: have you got pull-ups on the I2C? Is the ADDR pin on the chip pulled to ground?

An all-segment on test would probably be a string of “\x00\x08” (bit C3 on, all other bits off), or maybe “\x00\x0E” (bit C3 on, no digits blanked) - bit hard to tell from the datasheet. \x77 is not going to turn all the segments though.

Oh, and you do not need a voltage adaptor for the imp. Just ensure the I2C pull-ups are to 3.3v (say, 2.2kohm), not 5v.

If you look in the datasheet for the chip, you will see that Vih(l) is minimum 3.0v - this means that anything over 3.0v will be interpreted as a logic 1, hence it’s 3.3v I2C compatible.