Search Sample AVR and SAA1064-I2C LED Driver

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
User avatar
joe
Posts: 8
Joined: Wed Nov 22, 2006 6:32 am
Location: Berlin
Contact:

Search Sample AVR and SAA1064-I2C LED Driver

Post by joe »

Hello

i search a sample for SAA1064 IΒ²C 7segmentdriver.

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Search Sample AVR and SAA1064-I2C LED Driver

Post by Sean »

Hello Joe,

We do not have any examples for this specific device, but it can be controlled using the Flowcode I2C component. Its interface appears to be similar to the 23017 I/O expander used for the I/O expansion article:

http://www.matrixmultimedia.com/mmforum ... =26&t=4868

It should be possible to reuse the register read and write macros from the I2C version of the example program (with slight modifications) to communicate with the SAA1064.

User avatar
joe
Posts: 8
Joined: Wed Nov 22, 2006 6:32 am
Location: Berlin
Contact:

Re: Search Sample AVR and SAA1064-I2C LED Driver

Post by joe »

Thanks,

it soo simple :lol:

My Clock:

Code: Select all

int counter = 0;
char sekunde = 0;
char minute = 0;
char stunde = 0;

void wait() {
  Delay_ms(100);
}
char seconds, minutes, hours, day, month, year;    // Global date/time variables

// Software I2C connections
sbit Soft_I2C_Scl_Output    at PORTD2_bit; //     PORTC0_bit;
sbit Soft_I2C_Sda_Output    at PORTD1_bit; //     PORTC1_bit;
sbit Soft_I2C_Scl_Input     at PIND2_bit;  //     PINC0_bit;
sbit Soft_I2C_Sda_Input     at PIND1_bit;  //     PINC1_bit;
sbit Soft_I2C_Scl_Direction at DDD2_bit;   //     DDC0_bit;
sbit Soft_I2C_Sda_Direction at DDD1_bit;   //     DDC1_bit;
// End Software I2C connections

//--------------------- Display SAA 1064
void Display() {
  char Zahl[10] = {0xdb,0x11,0xcd,0x9d,0x17,0x9e,0xde,0x91,0xdf,0x9f};
  char temp = 0;
  
  Soft_I2C_Start();               // Issue start signal
  Soft_I2C_Write(0x70);           // Address SAA 1064
  Soft_I2C_Write(0);              // Start 
  Soft_I2C_Write(0xf7);           // config

  if (sekunde % 2)
  {
   temp = Zahl[stunde % 10] | 0x20;
  }
  else
  {
   temp = Zahl[stunde % 10];
  }

  Soft_I2C_Write(Zahl[stunde / 10 ]);           // Position 4, from left 1
  Soft_I2C_Write( temp );            // Position 3, from left 2
  Soft_I2C_Write(Zahl[minute / 10]);           // Position 2, from left 3
  Soft_I2C_Write(Zahl[minute % 10]);           // position , from left 4
  Soft_I2C_Stop();                // Issue stop signal
}


//-------------------- Output values to LCD

//------------------ Performs project-wide init
void Init_Main() {

  Soft_I2C_Init();           // Initialize Soft I2C communication
}

//----------------- Main procedure
void main() {

  Init_Main();               // Perform initialization
  DDRA = 0xff;     // set direction to be output
  PORTA = 0x00;    // turn OFF the PORTA leds
  counter = 0;
  Dispaly();             // Display with sec-takt over dp2

  while (1) {                // Endless loop
    Delay_ms(500);          // Wait 1 second
    ++sekunde;
    Dispaly();             // Display with sec-takt over dp2

    if (sekunde == 60)
    {
     sekunde = 0;
     ++minute;
     if (minute == 60)
     {
      minute = 0;
      ++stunde;
      if (stunde == 24)
      {
       stunde = 0;
      }
     }
    }

    Delay_ms(500);          // Wait 1 second
  }
}

Post Reply