Code written for IIC to LCD (Codevision) does not like to codevision !

Go To Last Post
47 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi !

 

I tried to drive a 20x4 LCD using PCF8574 using  I2C(TWI) with tiny2313.

In another topic I found that topic  "I2C to LCD with PCF8574".I am using codevisionAVR compiler.The problem is that codevision reported about 20 errors during compilation.Mainly compiler can not find #include "headers.h" ...

Any held/ideas ?

 

The code of "I2C to LCD with PCF8574" (by Fricko) is the following:

Notice that author says that "The I2C routine expects an Atmel-Chip with TWI".

 

/*********************************************
Project : I2C to LCD Interface-Routinen
Version :
Date    : 2005
Author  : Andreas Schδfer         

Chip type           : ATMEGA8 / PCF8574
Clock frequency     : 4 MHz

Port PCF8574:  7  6  5  4  3  2  1  0
               D7 D6 D5 D4 *  EN RW RS
**********************************************/

#include "headers.h"

#pragma warn-

char lcdErr;

// Daten fόr selbstdefinierte Zeichen
flash char charSet[8][8] = {0x0f, 0x01, 0x0f, 0x01, 0x0f, 0x00, 0x00, 0x00,
                            0x0f, 0x01, 0x0f, 0x01, 0x0f, 0x00, 0x00, 0x00,   // "3"
                            0x18, 0x1c, 0x1e, 0x1f, 0x1e, 0x1c, 0x18, 0x00,   // gefόllter Pfeil rechts
                            0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x00,   // gefόlltes Quadrat
                            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
                              
//*****************************************************************
// LC-Display initialisieren
//*****************************************************************   
void lcd_init(void)
{
   char i;
   char dummy = 0;
   
// High-Nibble von Byte 8 = Display Control:
// 1DCB****  D: Disp on/off; C: Cursor on/off  B: blink on/off
   char init_sequenz[]= {0x34, 0x34, 0x34, 0x24,
                         0x24, 0xc4, 0x04, 0b11000100,
                         0x04, 0x14, 0x04, 0x64};
   
   delay_ms(30);     // 30 ms Delay nach power-up

   for (i = 0; i < 12; i++)
   {
      lcdErr = i2c_master_tx(0x40, &dummy, 1);           // enable toggeln;
      delay_ms(5);   // 5 ms verzφgern
      lcdErr = i2c_master_tx(0x40, &init_sequenz[i], 1); // write init-data  
   }
   
   delay_ms(5);      // 5 ms verzφgern
   
   write_cg_ram();
}


//*****************************************************************
// Selbstdefinierte Zeichen in das CG-Ram schreiben
//*****************************************************************  
void write_cg_ram(void)
{
   char i, n;
   
   n = 0;
   
   do
   {
      lcd_instruction(0, 0x40 + n);  //CG-Ram Adresse setzen
      
      delay_us(50);
      
      for (i = 0; i < 8; i++)
      {
         lcd_instruction(1, charSet[n/8][i]);
         delay_us(50);
      }
      n += 8;
   }
   while (n < 64);
}
      

//*****************************************************************
// Stringlδnge ermitteln
//*****************************************************************   
char str_len(char *string)
{
   char i = 0;
   
   while (*(string + i) != 0)
      i++;
      
   return i;
}


//*****************************************************************
// String an aktueller Curserposition ausgeben
//*****************************************************************   
void lcd_write(char *strLcd)
{
   char lNibble, hNibble;
   char dummy = 1;
   char length, i;
   
   #asm("sei")
   
   i = 0;
   
   length = str_len(strLcd);
   
   for (i = 0; i < length; i++)
   {
      lNibble = *(strLcd + i) & 0x0f;
      lNibble <<= 4;                   // untere 4-Bit
      hNibble = *(strLcd + i) & 0xf0;  // obere 4-Bit
      
      lNibble |= 0x05;  // Enable & RS setzen
      hNibble |= 0x05;
       
      lcdErr = i2c_master_tx(0x40, &dummy, 1);     // enable toggeln;
      lcdErr = i2c_master_tx(0x40, &hNibble, 1);   // obere 4-Bit
      
      lcdErr = i2c_master_tx(0x40, &dummy, 1);     // enable toggeln;
      lcdErr = i2c_master_tx(0x40, &lNibble, 1);   // untere 4-Bit
   }
}


//*****************************************************************
// Befehl senden
//*****************************************************************   
void lcd_instruction(char mode, char data)
{
   char lNibble, hNibble;
   char dummy = 0;  
   
   #asm("sei")
   
   lNibble = data & 0x0f;
   lNibble <<= 4;             // untere 4-Bit
   hNibble = data & 0xf0;     // obere 4-Bit
   
   switch (mode)
   {
      case 0:
         lNibble |= 0x04;     // Enable setzen
         hNibble |= 0x04;
         break;
      case 1:
         lNibble |= 0x05;     // Enable & RS setzen
         hNibble |= 0x05;
         break;
      case 2:
         lNibble |= 0x07;     // Enable, RS & Read-Data setzen
         hNibble |= 0x07;
   }
    
   lcdErr = i2c_master_tx(0x40, &dummy, 1);       // enable toggeln;
   lcdErr = i2c_master_tx(0x40, &hNibble, 1);     // obere 4-Bit
   
   lcdErr = i2c_master_tx(0x40, &dummy, 1);       // enable toggeln;
   lcdErr = i2c_master_tx(0x40, &lNibble, 1);     // untere 4-Bit
}


//*****************************************************************
// Cursor an Position xy
//*****************************************************************   
void lcd_gotoxy(char x, char y)
{   
   if(y == 1)
      x += 0x40;  // Fόr 1. Pos. in zweiter Zeile
      
   x |= 0x80;
       
   lcd_instruction(0, x);
}


//*****************************************************************
// LCD lφschen
//*****************************************************************   
void lcd_clear(void)
{
   lcd_instruction(0, 0x01);   
}


//*****************************************************************
// Cursor in Home-Position
//*****************************************************************   
void lcd_home(void)
{
   lcd_instruction(0, 0x02);
}
    

//*****************************************************************
// Datenbytes όber I2C an adressierten Baustein senden
//*****************************************************************
unsigned char i2c_master_tx(unsigned char addr, unsigned char *data, unsigned char length)
{
    unsigned char i;
    
    TWCR = 0xa4;                   // Start senden
    while (!(TWCR & 0x80));     // warten bis gesendet
       if (TWSR != 0x08)
            return I2C_START_ERROR;    
    
    TWDR = addr & 0xfe;            // Slave-Adresse + w in TW-Datenregister schreiben
    TWCR = 0x84;               // senden
    while (!(TWCR & 0x80));     // warten bis gesendet    
      if (TWSR != 0x18)              // Aknowledge ?
          return I2C_ADDR_AKN_ERROR;
         
    for (i = 0; i < length; i++)// Datenbytes senden
    {
        TWDR = *data;              // Datenbyte in TW-Datenregister schreiben
           TWCR = 0x84;            // senden
        while (!(TWCR & 0x80)); // warten bis gesendet    
           if (TWSR != 0x28)          // Aknowledge ?
                return I2C_DATA_AKN_ERROR;
            data ++;        
    }
         
    TWCR = 0x94;                 // Stop senden
    return I2C_WRITE_OK;    
}

#pragma warn+

 

Thank You !

 

Last Edited: Fri. Oct 10, 2014 - 08:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have posted code for this before now.    Fricko's code looks pretty complicated.

 

Anyway,   I am sure that it will work.    But you need the "headers.h" file and an I2C adapter board with the PCF8574 wired as in the notes and with a 7-bit Slave address of 0x20 (8-bit=0x40).    And most importantly,   you must buy $0.02 worth of pull-up resistors.

 

If you want a CV library,   tell me how your i/f board is wired.    Or a link to an Ebay photo.

These adapter boards come in all variations.   e.g. BL EN RW RS D7 D6 D5 D4 or with a PCF8574P

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi david !

 

The url for I2C to LCD interface is this :

http://www.ebay.com/itm/IIC-I2C-...

 

Were can I find that code that you posted ?

Were can I find  "headers.h" file ? And also, what is the exact purpose of that ?

 

I/f board is wired like this:

 

8574 Pin    Function    LCD (HD44780 Based)
4                 P0                  RS - Register Select
5                 P1                  RW - Read/Write
6                 P2                  EN - Clock (Enable)
7                 P3                  LCD Backlight Control
9                 P4                  D4 - Data Bit 4
10               P5                  D5 - Data Bit 5
11               P6                  D6 - Data Bit 6
12               P7                  D7 - Data Bit 7

 

Notice, that there are pull-up resistors at SCL & SDA, 4K7.Also, the default bus address is 0x27.

 

I can not understand  if I need 7 or 8 bit...

 

Is it possible to send me the code and the relevant CV library ?

 

 

Thank you !!!

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't you just love the Chinese Ebay vendors ?

The photo from your link implies 7-bit address of 0x27.    The text says 0x20!

 

"lcd_i2c.lib"

  1. /*********************************************
    Project : I2C to LCD Interface-Routine
    Version : 
    Date    : 2011
    Author  : David Prentice         
    
    Port PCF8574 :  7  6  5  4  3  2  1  0
                   D7 D6 D5 D4 BL EN RW RS
    **********************************************/
    
    #define PCF8574A            0x27
    
    // Universal library for bit-bang <i2c.h> and hardware <twi.h>
    // One day,   I might add support for Xmega hardware TWI.
    
    #include <stdint.h>
    #include <delay.h>
    
    #if defined(USE_TWI)
    #include <TWI.h>
    #include <lcd_twi.h>
    #define I2C_INIT()          twi_master_init(100)
    #define I2C_WRITESEQ(slave, buf, n)  twi_master_trans(slave, buf, n, 0, 0)
    #else
    #include <i2c.h>
    #include <lcd_i2c.h>
    #define I2C_INIT()          i2c_init()
    uint8_t I2C_WRITESEQ(uint8_t slave, uint8_t *seq, uint8_t n)
    {
        uint8_t ret = 1;
        if (i2c_start() && i2c_write(slave << 1)) {
            uint8_t i;
            for (i = 0; i < n; i++)
                i2c_write(seq[i]);
            ret = 0;
        }
        i2c_stop();
        return ret;
    }
    #endif
    
    #pragma used+
    static unsigned char _base_y[4]={0x80,0xc0};
    unsigned char _lcd_x,_lcd_y,_lcd_maxx;
    #pragma used-
    
    unsigned char wr_lcd_mode(char c, char mode)
    {
        char ret = 1;
        char seq[5];
        static char backlight = 8;
        if (mode == 8) {
            backlight = (c != 0) ? 8 : 0;
            return I2C_WRITESEQ(PCF8574A, &backlight, 1);
        }
        mode |= backlight;
        seq[0] = mode;                      // EN=0, RW=0, RS=mode
        seq[1] = (c & 0xF0) | mode | 4;     // EN=1, RW=0, RS=mode
        seq[2] = seq[1] & ~4;               // EN=0, RW=0, RS=mode
        seq[3] = (c << 4) | mode | 4;       // EN=1, RW=0, RS=mode
        seq[4] = seq[3] & ~4;               // EN=0, RW=0, RS=mode
        ret = I2C_WRITESEQ(PCF8574A, seq, 5);
        if (!(mode & 1) && c <= 2)
            delay_ms(2);                    // CLS and HOME
        return ret;
    }
    
    void _lcd_write_data(unsigned char data)
    {
        wr_lcd_mode(data, 1);
    }
    /* read a byte from the LCD character generator or display RAM */
    //unsigned char lcd_read_byte(unsigned char addr);
    
    /* write a byte to the LCD character generator or display RAM */
    void lcd_write_byte(unsigned char addr, unsigned char data)
    {
        wr_lcd_mode(addr, 0);
        wr_lcd_mode(data, 1);
    }
    // set the LCD display position  x=0..39 y=0..3
    void lcd_gotoxy(unsigned char x, unsigned char y)
    {
        wr_lcd_mode(0x80 | (_base_y[y] + x), 0);   //.kbv now use +
        _lcd_x=x;
        _lcd_y=y;
    }
    // clear the LCD
    void lcd_clear(void)
    {
        wr_lcd_mode(0x01, 0);
        _lcd_x = _lcd_y = 0;
    }
    void lcd_putchar(char c)
    {
        if (_lcd_x>=_lcd_maxx || c == '\n')
        {
            lcd_gotoxy(0,++_lcd_y);
        }
        if (c != '\n') {
            ++_lcd_x;
            wr_lcd_mode(c, 1);
        }
    }
    // write the string str located in SRAM to the LCD
    void lcd_puts(char *str)
    {
        while (*str) lcd_putchar(*str++);
    }
    // write the string str located in FLASH to the LCD
    void lcd_putsf(char flash *str)
    {
        while (*str) lcd_putchar(*str++);
    }
    // write the string str located in EEPROM to the LCD
    void lcd_putse(char eeprom *str)
    {
        while (*str) lcd_putchar(*str++);
    }
    // initialize the LCD controller
    void lcd_init(unsigned char lcd_columns)
    {
        char i;
        // High-Nibble von Byte 8 = Display Control: 
        // 1DCB****  D: Disp on/off; C: Cursor on/off  B: blink on/off
        char init_sequenz[] = { 0x33, 0x32, 0x28, 0x0C, 0x06, 0x01 };
        _lcd_maxx = lcd_columns;
        _base_y[2] = _base_y[0] + _lcd_maxx; 
        _base_y[3] = _base_y[1] + _lcd_maxx; 
        I2C_INIT();
        delay_ms(30);               // 30 ms Delay nach power-up
        for (i = 0; i < sizeof(init_sequenz); i++) {
            wr_lcd_mode(init_sequenz[i], 0);
            delay_ms(5);
        }
    }
    
    void lcd_backlight(char on)
    {
        wr_lcd_mode(on, 8);
    }
    
  2. /*********************************************
    Project : I2C to LCD Interface-Routine
    Version : 
    Date    : 2011
    Author  : David Prentice         
    
    Port PCF8574 :  7  6  5  4  3  2  1  0
                   D7 D6 D5 D4 BL EN RW RS
    **********************************************/
    
    #define USE_TWI             // for lcd_twi.lib
    
    #include <../lib/lcd_i2c.lib>
    
  3. /************************************************** 
      CodeVisionAVR C Compiler V2.04.9+
      (C) 1998-2010 Pavel Haiduc, HP InfoTech S.R.L.
    
      uses the same API as the standard CV <alcd.h> library
      for LCDs with an I2C adapter.
    **************************************************/
    
    
    #ifndef _LCD_I2C_INCLUDED_
    #define _LCD_I2C_INCLUDED_
    
    void _lcd_write_data(unsigned char data);
    /* read a byte from the LCD character generator or display RAM */
    //unsigned char lcd_read_byte(unsigned char addr);
    /* write a byte to the LCD character generator or display RAM */
    void lcd_write_byte(unsigned char addr, unsigned char data);
    // set the LCD display position  x=0..39 y=0..3
    void lcd_gotoxy(unsigned char x, unsigned char y);
    // clear the LCD
    void lcd_clear(void);
    void lcd_putchar(char c);
    // write the string str located in SRAM to the LCD
    void lcd_puts(char *str);
    // write the string str located in FLASH to the LCD
    void lcd_putsf(char flash *str);
    // write the string str located in EEPROM to the LCD
    void lcd_putse(char eeprom *str);
    // initialize the LCD controller
    void lcd_init(unsigned char lcd_columns);
    // turn backlight on
    void lcd_backlight(char on);
    
    #pragma library lcd_i2c.lib
    
    #endif
    
    
  4. /************************************************** 
      CodeVisionAVR C Compiler V2.04.9+
      (C) 1998-2010 Pavel Haiduc, HP InfoTech S.R.L.
    
      uses the same API as the standard CV <alcd.h> library
      for LCDs with an I2C adapter.
    **************************************************/
    
    
    #ifndef _LCD_TWI_INCLUDED_
    #define _LCD_TWI_INCLUDED_
    
    void _lcd_write_data(unsigned char data);
    /* read a byte from the LCD character generator or display RAM */
    //unsigned char lcd_read_byte(unsigned char addr);
    /* write a byte to the LCD character generator or display RAM */
    void lcd_write_byte(unsigned char addr, unsigned char data);
    // set the LCD display position  x=0..39 y=0..3
    void lcd_gotoxy(unsigned char x, unsigned char y);
    // clear the LCD
    void lcd_clear(void);
    void lcd_putchar(char c);
    // write the string str located in SRAM to the LCD
    void lcd_puts(char *str);
    // write the string str located in FLASH to the LCD
    void lcd_putsf(char flash *str);
    // write the string str located in EEPROM to the LCD
    void lcd_putse(char eeprom *str);
    // initialize the LCD controller
    void lcd_init(unsigned char lcd_columns);
    // turn backlight on
    void lcd_backlight(char on);
    
    #pragma library lcd_twi.lib
    
    #endif
    

The next three files are "lcd_twi.lib" ,   "lcd_i2c.h" and "lcd_twi.h".    Copy the two lib files to the /cvavr/LIB directory.    And the two H files to the /cvavr/INC directory.     This lovely editor does not allow you to write anything between two CODE blocks !

 

When you want to use the I2C adapter,   just #include <lcd_twi.h>

All the library calls are identical to the standard <alcd.h> library.

If you want to use non-TWI pins,   select your SDA and SCL pins in the Project configuration,   and #include <lcd_i2c.h>

 

It is set up for slave address of 0x27 and your wiring.    Note that I have not implemented the CV READ functions.

 

David.

 

Edit.  fixed a problem with lcd_gotoxy()

Last Edited: Sat. Oct 11, 2014 - 11:20 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi david !

 

First of all thank you again for your help ! I am in my office now, I will try it later and I will let you know.

Those things are common with Chinese vendors... But You have to admit that this module is very cheap and PCF8574 seems to be usefull IC for LCD solution and of curse as general I/O expander for I2C.

Two more questions, please:

How do you know that is 7 bit ? From the nibble and the the control signals ??? But with LCD Backlight Control, there are 8 bit...

Do you plan to implement CV READ functions in the future ?

 

 

 

Thank You !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you said that you had a valid use for the

unsigned char lcd_read_byte(unsigned char address) 

then it should be pretty straightforward.

 

You don't understand the 7-bit Slave versus 8-bit Slave anomaly.

I2C slave address uses bit#0 for Read/Write.    e.g. 0x4F (R) and 0x4E (W) as 8-bit addresses.

Some people just quote bit1..bit7 i.e 0x27.

 

When you shift the 7-bit value by 1,   you get the 8-bit addresses.  e.g.

(0x27 << 1) + 1 = 0x4F (R)

(0x27 << 1) + 0 = 0x4E (W)

 

I feel happier with using the 8-bit value-pair. e.g. 0xA0/0xA1 for a 24Cxxx memory.

Many I2C libraries use the single 7-bit value.  e.g. 0x50

 

<twi.h> functions use 7-bit

<i2c.h> functions use 8-bit

Fleury uses 8-bit

Stang uses 7-bit.

Arduino <Wire.h> uses 7-bit.

 

Confusing !!!!

 

David.

Last Edited: Wed. Oct 8, 2014 - 12:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi David !

 

That is true. It is confusing. Thanks anyway for the explanation !

 

Regarding I2C LCD.I am totaly lost !!!

 

 

In the past, I used 1 nibble and the three control signals to drive LCD. I used commands like that:

 

  lcd_gotoxy(7,0);                      
  lcd_putsf("Welcome");          
  //lcd_gotoxy(0,1);                        
  lcd_putsf("Caller-ID display");          
  //lcd_gotoxy(5,2);                       
  lcd_putsf("Version 2");          
 

  e.t.c. HOW can - from now on - use/drive the I2C LCD.And also, how to enable the relevant output of pcf8574 in order to enable backlight ?

 

Ι have to forget the above way. The CV report that this chip (tiny2313) does not support I2C.But in my project code everything work fine, using I2C DTMF encoder PCD3312.I did that (I2C) using wizard.

  Lets start from the begining, so forget my project code.

Could You please send me a test/demo code that will for example write "Welcome" to lcd, in order to understand what is wrong ?

 

 

Thank you !

 

 

 

 

 

Last Edited: Thu. Oct 9, 2014 - 06:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
#include <lcd_i2c.h>

void main(void)
{
    lcd_init(20);
    
    lcd_backlight(1);

    lcd_gotoxy(7,0);                      
    lcd_putsf("Welcome");          
    lcd_gotoxy(0,1);                        
    lcd_putsf("Caller-ID display");          
    lcd_gotoxy(5,2);                       
    lcd_putsf("Version 2");
    while(1);
}

In your project Configuration ->Libraries->I2C select your SDA and SCL pins for the Tiny2313.

 

Make sure that your adapter really does match the photo from your Ebay link.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi David !

 

Compilation is now ok. But LCD does not work...

 

Code:

 

/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.3 Standard

Chip type               : ATtiny2313
AVR Core Clock frequency: 2,000000 MHz
Memory model            : Tiny
External RAM size       : 0
Data Stack size         : 32
*****************************************************/

#include <tiny2313.h>

// I2C Bus functions
#include <i2c.h>
#include <lcd_i2c.h>


void main(void)
{

#pragma optsize-
CLKPR=0x80;
CLKPR=0x00;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif

PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0x00;
PORTD=0x00;
DDRD=0x00;
TCCR0A=0x00;
TCCR0B=0x00;
TCNT0=0x00;
OCR0A=0x00;
OCR0B=0x00;
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
GIMSK=0x00;
MCUCR=0x00;
TIMSK=0x00;
USICR=0x00;
UCSRB=0x00;
ACSR=0x80;
DIDR=0x00;

// I2C Bus initialization
// I2C Port: PORTB
// I2C SDA bit: 0
// I2C SCL bit: 1
// Bit Rate: 100 kHz
// Note: I2C settings are specified in the
// Project|Configure|C Compiler|Libraries|I2C menu.
i2c_init();

while (1)
      {
      lcd_init(20);
    
    lcd_backlight(1);

    lcd_gotoxy(7,0);                      
    lcd_putsf("Welcome");          
    lcd_gotoxy(0,1);                        
    lcd_putsf("Caller-ID display");          
    lcd_gotoxy(5,2);                       
    lcd_putsf("Version 2");
    while(1);

      }
}

 

 

Hardware pull-ups are 10K, Fuses: NO div/8,Ext osc 0.9-3 Mhz (XTAL=2Mhz), Osc capasitors are o.k

SDA is B0 and SCL is B1.

And yes the interface is the exact one as in url, and hardware verified one by one with multimeter (So i/o of 8574 correspond as we want):

Port PCF8574 :  7  6  5  4  3  2  1  0
               D7 D6 D5 D4 BL EN RW RS

 

Any ideas ?????

 

Regard,

 

Alex

 

Last Edited: Fri. Oct 10, 2014 - 08:57 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The photo from the Ebay link look as if there are onboard 4k7 pull-ups.

So I suggest that you check this for yourself.

 

Mind you,   an extra 10k in parallel with 4k7 should work just fine.   (e.g. ~3k3)

 

It 'looks' as if the A0-A2 address pads are empty.   So the chip will be 0x27 (7-bit)

I would be happier with A0-A2 being directly connected to VCC or GND.   i.e. not relying on internal PCF8574 pull-ups.

Or are there external 10k pull-ups on A0-A2.

 

Is the chip PCF8574 or PCF8574A ?

 

You can check the I2C address by doing:

     uint8_t slave;
     i2c_init();
     for (slave = 0x00; slave < 0x80; slave++) {
         if (i2c_start() && i2c_write(slave << 1))
              printf("7-bit slave is 0x%02X\n", slave);
         i2c_stop();
     }
     

Of course,   if your LCD is not working,   you need to write to the USART or flash some LEDs.

It should print "slave is 0x27" for PCF8574 and 0x3F for PCF8574A.   

 

You can always forget the loop and just re-compile for each possible Slave value.

 

David.

 

p.s.  life is much simpler when you have an Arduino.     The Arduino libraries expect you to connect pins all over the place and use non-standard I2C addresses.     It is overkill on a C program.    You have one adapter and are not going to change it half-way through a program.

Last Edited: Thu. Oct 9, 2014 - 10:31 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi David !

 

  • About pull-ups. There are 2 pull-up for each SDA and SCL signals. One 10k from my board and one on-board (interface), 10K too.So 5K.
  • All three address pins are tied to +5V with three 10K.
  • The IC is PCF8574T (I know about PCF8574A and the different addresses of it)
  • "You can check the I2C address by doing:" Who You mean to use that code ? Alone ?
  • When I bought that interface board I used a i2c scanner program from internet, for arduino and reported address 0X27, so address is ok.
  • I want to avoid - for the time being- Led's and UART... I am still trying to see something in LCD.
  • Could You please confirm, that in my code witch is following, B0 is SDA and SCL is B1 as I configured using CD wizard. (Although that I made the same thing with PCD3312 DTMF encoder without any problem).The wizard adds automatically comments that confirmed that, but what about commands ?

 

 

/*****************************************************

Chip type               : ATtiny2313
AVR Core Clock frequency: 2,000000 MHz
Memory model            : Tiny
External RAM size       : 0
Data Stack size         : 32
*****************************************************/

#include <tiny2313.h>
#include <i2c.h>
#include <lcd_i2c.h>

void main(void)
{
// Declare your local variables here

// Crystal Oscillator division factor: 1
#pragma optsize-
CLKPR=0x80;
CLKPR=0x00;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif

PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0x00;
PORTD=0x00;
DDRD=0x00;
TCCR0A=0x00;
TCCR0B=0x00;
TCNT0=0x00;
OCR0A=0x00;
OCR0B=0x00;
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
GIMSK=0x00;
MCUCR=0x00;
TIMSK=0x00;
USICR=0x00;
UCSRB=0x00;
ACSR=0x80;
DIDR=0x00;

// I2C Bus initialization
// I2C Port: PORTB
// I2C SDA bit: 0
// I2C SCL bit: 1
// Bit Rate: 100 kHz
// Note: I2C settings are specified in the
// Project|Configure|C Compiler|Libraries|I2C menu.
i2c_init();

while (1)
      {
       lcd_init(20);
    
    lcd_backlight(1);

    lcd_gotoxy(7,0);                      
    lcd_putsf("Welcome");          
    lcd_gotoxy(0,1);                        
    lcd_putsf("Caller-ID display");          
    lcd_gotoxy(5,2);                       
    lcd_putsf("Version 2");
    while(1);

      }
}

 

 

Thank You !

 

Alex

Last Edited: Fri. Oct 10, 2014 - 08:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David,

 

For me, this attachment is the confirmation that SDA @ B0 and SCL @ B1 are correclty configured.

 

 

 

 

 

Regards,

Alex

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well,   I compiled and ran your exact code on a real ATtiny2313A with a 8MHz crystal.

So all the timing will be 4x too fast.   i.e. making the PCF8574 flaky.

 

It worked fine.

 

 

I then wrote it properly.   i.e.   telling the Wizard that I had a Core frequency of 2MHz and it could divide the 8MHz by 4.

    // Crystal Oscillator division factor: 4
#pragma optsize-
    CLKPR = (1<<CLKPCE);
    CLKPR = (0<<CLKPCE)|(0<<CLKPS3)|(0<<CLKPS2)|(1<<CLKPS1)|(0<<CLKPS0);
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif

What is a complete mystery to me is "How do you get 2MHz with div1 ?"

No-one is going to use a 2MHz crystal.

The Internal RC can only do 128kHz, 4MHz, 8MHz.

 

If you possess an Arduino,   I could write you some diagnostic code for the LCD.

i.e. it could test for pull-ups,  verify Slave address,  verify the D4-D7 pins, verify the backlight, verify your SDA, SCL, ...

 

But there are already Arduino programs that do this.

 

I can't test your wiring on a tiny2313.

I would be a lot happier if you compared the Ebay photo with your actual adapter.

For example,   I can see 4k7 resistors and 10k resistors.

 

David.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David, Hi again !

 

 I found a big stupid about the ground connection of interface. Know the LCD response to backlight(1) and backlight(0). But nothing else.It is a first step.It seems that PCF8574 decodes correctly that command...

Is it necesery to use  "i2c_start();". And how can I verify that the code will use 0x27 ?

 

 

 

 

Regards,

Alex

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You connect your LCD to your Arduino.   And you test that it works with 0x27.    And the relevant arrangement of PCF8574 pins.  e.g.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//                   SLAVE EN RW RS D4 D5 D6 D7 BL  BL_POLARITY     
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);     // set the I2C address to 0x20-0x27 for a 16x2 display

I would advise anyone to buy an Arduino.    Even if you only use it to verify your hardware.

 

If your LCD works with that constructor(),   it will work with my code.

As I said,    you can write C libraries for "weirdly wired" hardware.

 

Just use the Arduino test programs to identify what your wiring actually is.

But first off,   I would compare your real-life adapter with the Ebay photo.

 

David.

Last Edited: Fri. Oct 10, 2014 - 01:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, David !

 

Finally it works !!! There was a problem with the cables and an error with the code that had to delay in order to be able to see the message at the LCD...

 

 

 

Thank You very much for Your time and the valuable information !

 

 

 

Regards,

Alex

Last Edited: Fri. Oct 10, 2014 - 08:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go on.   Explain.   Do you have a 2MHz crystal ?

What was wrong with the cables ?

 

You could have tested an Arduino sketch.

Then run a CV program on your Arduino using the same wiring.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi , David !

 

  • Of curse, the crystal is 2Mhz.Clock and fuses were ok.
  • There was a problem with ground cable
  • Another one concerning a quick loop that it was impossible to see the message on LCD. (Printf some things and immediately clear LCD, without delay do to a stupid wrong with a flag).

 

     But, before I wrote the first post, I tried to use another identical interface with an arduino sketch and worked fine (I have uno and 2560 to)!  The problem was with the second board and CV code attempt... As you said, arduino is the simple way ... But my code was based on CV.

 

 

 

THANK YOU AGAIN !!!

Last Edited: Fri. Oct 10, 2014 - 09:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, I did not answer something else about the clock that Yoy asked me...

 

The clock is external.As you said, it is impossible to get 2Mhz clock with internal RC and div by 1.The reason that I use 2Mhz crystal, is that HW was based to another older project that used tiny 2313 and 2Mhz crystal.Now, is a good idea to update it to 4Mhz, witch is more common.

Anyway, the conclusion of all these failures was that I tried many ways to make the HW and code to work, that I finally made many stupid things...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi !

 

 

 Although that LCD is now working, according to my following code, text "Version 0.0" seems to appears not in the correct position. Practically  it appears at first position of third line ! Do you now why ?

 

 

 while (1)
     {
    if (weldisp==0) 
    {
    
   lcd_init(20);           
   lcd_backlight(1); 
   lcd_clear();
   lcd_gotoxy(7,0);                           //put lcd cursor in 2nd pixel of 2st line
   lcd_putsf("Welcome");           //print message on lcd
   lcd_gotoxy(4,1);
   lcd_putsf("I2C LCD TEST");  
   lcd_gotoxy(4,2);
   lcd_putsf("Version 0.0");
   lcd_gotoxy(8,3);
   lcd_putsf("R&D"); 
  weldisp=1;
  delay_ms(3000);
  lcd_clear();         
  
  } 

Alex

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can confirm that the 3rd line (#2) was displaying wrongly.  Edit "lcd_i2c.lb":

// set the LCD display position  x=0..39 y=0..3
void lcd_gotoxy(unsigned char x, unsigned char y)
{
    wr_lcd_mode(0x80 | (_base_y[y] + x), 0);   //.kbv now +
    _lcd_x=x;
    _lcd_y=y;
}

This shows 3 methods of displaying text.  e.g. gotoxy(), using 'newline',  just wrapping text:

    while (1) {
        lcd_clear();
        lcd_gotoxy(7, 0);       //put lcd cursor in 2nd pixel of 2st line
        lcd_putsf("Welcome");   //print message on lcd
        lcd_gotoxy(4, 1);
        lcd_putsf("I2C LCD TEST");
        lcd_gotoxy(4, 2);
        lcd_putsf("Version 0.0");
        lcd_gotoxy(8, 3);
        lcd_putsf("R&D");
        delay_ms(3000);

        lcd_clear();
        lcd_putsf("       Welcome\n"
                  "    I2C LCD TEST\n"
                  "    Version 0.1\n"
                  "        R&D");            //print message on lcd
        delay_ms(3000);

        lcd_clear();
        lcd_putsf("       Welcome      "
                  "    I2C LCD TEST    "
                  "    Version 0.2     "
                  "        R&D         ");   //print message on lcd
        delay_ms(3000);
    }
    

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For another time your posts help me very much to understand the relevant subjects/tasks.

 

 

 

 

Thank You, for Your time David !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello David.

what version of codevision you use ? i have 2.05.0 version and it gives error.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using CV v3.21 at the moment.   I think the current version is v3.23 but I have not installed it yet.    I have obviously copied Pavel's <lcd.h> header.    I do not support read functions.    The #pragma library is different.  

 

I can see no reason for v2.05 not working.    However,  the CV <i2c.h> library uses 8-bit Slave addresses.   The <twi.h> library uses 7-bit Slave addresses.

 

<lcd_i2c.h>:

/**************************************************
  CodeVisionAVR C Compiler V2.04.9+
  (C) 1998-2010 Pavel Haiduc, HP InfoTech S.R.L.

  Universal alphanumeric LCD driver library
  for the HD44780 LCD controller

  Supports both ATxmega and non-ATxmega devices
**************************************************/

#ifndef _LCD_I2C_INCLUDED_
#define _LCD_I2C_INCLUDED_

void _lcd_write_data(unsigned char data);
/* read a byte from the LCD character generator or display RAM */
//unsigned char lcd_read_byte(unsigned char addr);
/* write a byte to the LCD character generator or display RAM */
void lcd_write_byte(unsigned char addr, unsigned char data);
// set the LCD display position  x=0..39 y=0..3
void lcd_gotoxy(unsigned char x, unsigned char y);
// clear the LCD
void lcd_clear(void);
void lcd_putchar(char c);
// write the string str located in SRAM to the LCD
void lcd_puts(char *str);
// write the string str located in FLASH to the LCD
void lcd_putsf(char flash *str);
// write the string str located in EEPROM to the LCD
void lcd_putse(char eeprom *str);
// initialize the LCD controller
void lcd_init(unsigned char lcd_columns);
// turn backlight on
void lcd_backlight(char on);

#pragma library lcd_i2c.lib

#endif

<lcd_i2c.lib>:

/*********************************************
Project : I2C to LCD Interface-Routine
Version :
Date    : 2011
Author  : David Prentice         

Port PCF8574 :  7  6  5  4  3  2  1  0
               D7 D6 D5 D4 BL EN RW RS
**********************************************/

//#define USE_TWI             // for lcd_twi.lib
//#undef USE_TWI              // for lcd_i2c.lib
#define PCF8574A            0x27      //0x38 for PCF8574A on dev board

#include <stdint.h>
#include <delay.h>

#if defined(USE_TWI)
#include <TWI.h>
#include <lcd_twi.h>
#define I2C_INIT()          twi_master_init(100)
#define I2C_WRITESEQ(slave, buf, n)  twi_master_trans(slave, buf, n, 0, 0)
#else
#include <i2c.h>
#include <lcd_i2c.h>
#define I2C_INIT()          i2c_init()
uint8_t I2C_WRITESEQ(uint8_t slave, uint8_t *seq, uint8_t n)
{
    uint8_t ret = 1;
    if (i2c_start() && i2c_write(slave << 1)) {
        uint8_t i;
        for (i = 0; i < n; i++)
            i2c_write(seq[i]);
        ret = 0;
    }
    i2c_stop();
    return ret;
}
#endif

#pragma used+
static unsigned char _base_y[4]={0x80,0xc0};
unsigned char _lcd_x,_lcd_y,_lcd_maxx;
#pragma used-

static unsigned char wr_lcd_mode(char c, char mode)
{
    char ret = 1;
    char seq[5];
    static char backlight = 8;
    if (mode == 8) {
        backlight = (c != 0) ? 8 : 0;
        return I2C_WRITESEQ(PCF8574A, &backlight, 1);
    }
    mode |= backlight;
    seq[0] = mode;                      // EN=0, RW=0, RS=mode
    seq[1] = (c & 0xF0) | mode | 4;     // EN=1, RW=0, RS=mode
    seq[2] = seq[1] & ~4;               // EN=0, RW=0, RS=mode
    seq[3] = (c << 4) | mode | 4;       // EN=1, RW=0, RS=mode
    seq[4] = seq[3] & ~4;               // EN=0, RW=0, RS=mode
    ret = I2C_WRITESEQ(PCF8574A, seq, 5);
    if (!(mode & 1) && c <= 2)
        delay_ms(2);                    // CLS and HOME
    return ret;
}

void _lcd_write_data(unsigned char data)
{
    wr_lcd_mode(data, 1);
}
/* read a byte from the LCD character generator or display RAM */
//unsigned char lcd_read_byte(unsigned char addr);
/* write a byte to the LCD character generator or display RAM */
void lcd_write_byte(unsigned char addr, unsigned char data)
{
    wr_lcd_mode(addr, 0);
    wr_lcd_mode(data, 1);
}
// set the LCD display position  x=0..39 y=0..3
void lcd_gotoxy(unsigned char x, unsigned char y)
{
    wr_lcd_mode(0x80 | (_base_y[y] + x), 0);   //.kbv now use +
    _lcd_x=x;
    _lcd_y=y;
}
// clear the LCD
void lcd_clear(void)
{
    wr_lcd_mode(0x01, 0);
    _lcd_x = _lcd_y = 0;
}
void lcd_putchar(char c)
{
    if (_lcd_x>=_lcd_maxx || c == '\n')
    {
        lcd_gotoxy(0,++_lcd_y);
    }
    if (c != '\n') {
        ++_lcd_x;
        wr_lcd_mode(c, 1);
    }
}
// write the string str located in SRAM to the LCD
void lcd_puts(char *str)
{
    while (*str) lcd_putchar(*str++);
}
// write the string str located in FLASH to the LCD
void lcd_putsf(char flash *str)
{
    while (*str) lcd_putchar(*str++);
}
// write the string str located in EEPROM to the LCD
void lcd_putse(char eeprom *str)
{
    while (*str) lcd_putchar(*str++);
}
// initialize the LCD controller
void lcd_init(unsigned char lcd_columns)
{
    char i;
    // High-Nibble von Byte 8 = Display Control:
    // 1DCB****  D: Disp on/off; C: Cursor on/off  B: blink on/off
    char init_sequenz[] = { 0x33, 0x32, 0x28, 0x0C, 0x06, 0x01 };
    _lcd_maxx = lcd_columns;
    _base_y[2] = _base_y[0] + _lcd_maxx;
    _base_y[3] = _base_y[1] + _lcd_maxx;
    I2C_INIT();
    delay_ms(30);               // 30 ms Delay nach power-up
    for (i = 0; i < sizeof(init_sequenz); i++) {
        wr_lcd_mode(init_sequenz[i], 0);
        delay_ms(5);
    }
}

void lcd_backlight(char on)
{
    wr_lcd_mode(on, 8);
}

Since you have a Tiny2313,  you will not be interested in <lcd_twi.lib>:

/*********************************************
Project : I2C to LCD Interface-Routine
Version :
Date    : 2011
Author  : David Prentice         

Port PCF8574 :  7  6  5  4  3  2  1  0
               D7 D6 D5 D4 BL EN RW RS
**********************************************/

#define USE_TWI             // for lcd_twi.lib

#include <../lib/lcd_i2c.lib>

In other words,   you do not have TWI.   So you would not be including <lcd_twi.h>.    If you do,   you will get the errors in your JPEG.

For people with TWI:  <lcd_twi.h> is exactly the same as <lcd_i2c.h> except for the #pragma library

 

Most I2C adapters have an address of 0x27.   And have the above PCF8574 layout.    If yours is different,  shout.  (run the Arduino diagnostic sketch from bperrybap)

 

Note that an I2C bus must have external pull-up resistors.    Some adapters have them on the pcb.   Some do not.

 

David.

Last Edited: Fri. Nov 6, 2015 - 10:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

lot of thanks for response David.
i dont have a attiny2313. i try use twi on atmega328. before i #include <lcd twi.h> i have set #include<mega328.h> but it looks like kompiler did not read <mega328.h> before <lcd twi.h>.
Giorgi.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you have a mega328, you can use < lcd_twi.h> if you use the hardware pins. If you connect your I2C to different pins, you must bit-bash with < lcd_i2c.h>

I am not at a PC right now. You normally include io.h in every CV program as the first statement. If you only print C expressions to the LCD, you should only need to include lcd_twi.h

I will try this later after I have taken my dog out, and post the result

David..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I created a CV project for a mega328P @ 16MHz.

I connected external pull-up resistors to the SCL, SDA lines

I connected an LCD with I2C adapter to the SCL, SDA lines.

 

/*
 * lcd_giorgi.c
 *
 * Created: 07/11/2015 08:13:23
 * Author: David Prentice
 */

#include <lcd_twi.h>
#include <delay.h>

void main(void)
{
    lcd_init(16);
    while (1) {
        // Please write your application code here
        lcd_clear();
        delay_ms(500);
        lcd_putsf("Hello Giorgi");
        delay_ms(500);
        lcd_gotoxy(4, 1);
        lcd_putsf("from David");
        delay_ms(1000);
    }
}

 

It ran fine.    Since my adapter does not have pull-ups,  it was essential to use the external pull-up resistors.

I have other adapters that do have pull-ups onboard.

 

If I used no delays,   I would not even need to include delay.h

If I use lcd_i2c.h I would have to configure the I2C pins in the Project Configuration Libraries menu.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

giorgi wrote:

hello David.

what version of codevision you use ? i have 2.05.0 version and it gives error.

Ah-ha.    I looked at your JPEG.   It looks as if you are using an old Evaluation version.    You can always download the current Evaluation version.

 

If you look at the V2 Revision History on the CV website,   TWI.h was not available until v2.05.1.  You claim to be using v2.05.0

The lcd_i2c.h library should work with the earliest versions of CV.

 

If you have an old licence,  you can easily upgrade to the current CV version at any time.    Integration with Atmel Studio is well worth the upgrade cost.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have cracked version ...
lcd i2c.h works perfect, so i use them :)
lot of thanks to you fot library and for time to me and excuse me for my english :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Buy a proper licence.   It is not expensive.   The v3 versions work with Atmel Studio.

 

If you do any amount of AVR development,   your "time saved" is well worth the cost of CV.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have cracked version ...

And thereby ends the help.

 

This board is populated by people who make a living selling software.  It isn't in their best interest to offer free help to someone who is stealing from the industry through which they make their living.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you David, I will try to gradually build up to purchase licenses :)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi. After so much time, I bought some I2C LCD modules but they use PCF8574AT instead of PCF8574T. The problem is that they do not work , because according to datasheet, their address is  0x3F (instead of 0x27 of those with suffix T).

My question is the following. Is it possible to define address inside my code ?

Last Edited: Thu. Mar 12, 2020 - 09:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Am I just being too optimistic but in:

/*********************************************
Project : I2C to LCD Interface-Routine
Version : 
Date    : 2011
Author  : David Prentice         

Port PCF8574 :  7  6  5  4  3  2  1  0
               D7 D6 D5 D4 BL EN RW RS
**********************************************/

#define PCF8574A            0x27

don't you just change the 0x27 to be 0x3F then??

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK. This could be possible. But I would like to do that inside my code.I don't want to modify lib and .h files. In my existing code, (since 2014) there was no lcd address, because default value was used.Now I would like to use also 0x3F.

By the way, in that specific code  I used also a second  I2C slave device (PCD3312 DTMF dialler) witch of course uses generic i2c library but address setup was made by this: i2c_write(0x48);

I need the same for PCF8574...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Well written code (like David's) is going to allow this I2C address to be defined or "passed in" at just one point and then it will use that same value all over the code where it is needed. So if you do want to make a change like this you just change it in the one place and it filters down throughout the code. If, on the other hand the code has the value 0x27 hard coded all over the place then I guess all you can do is a global search and replace and change every instance to the new value.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have a Codevision licence.  Codevision has supported I2C backpacks for several years.    I suggest that you use the regular CV libraries.

 

All the same,   the backpack code is available for different compilers.    From memory,   I set the Slave address via a #define.    But it is simple enough for you to alter the #define or to alter the code.

 

CV lets you set slave address (and backpack model) in a GUI.

It could not be easier.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
From memory,   I set the Slave address via a #define.  

Indeed - as Cliff showed!

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is licensed but it is old , i think 3.x. I have no idea what backpack is. What is that ?

As far as the master device (tiny2313) is concerned, I used to run wizard and Bib-banged I2C I just select SCL and SDA bits.

Last Edited: Thu. Mar 12, 2020 - 12:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bnsavr wrote:
what is backpack. What is that ?

a board which goes on the back of a standard (parallel interface) LCD module to convert it to a serial (eg, I2C) interface

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Memory is sub-menu ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bnsavr wrote:
Memory is sub-menu ?

Pardon ?

 

Are you referring to this:

david.prentice wrote:
From memory,   I set the Slave address via a #define.  

David is there referring to the memory in his head; ie, his recollection of what he did 5 years ago in the original discussion

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yes. What memory ? It that a menu or properties window in CV ?

Last Edited: Thu. Mar 12, 2020 - 01:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bnsavr wrote:

It is licensed but it is old , i think 3.x. I have no idea what backpack is. What is that ?

You can see the version number in the splash screen.   Or in Help->About CodevisonAVR

 

CV added support for PCF8574 backpack in V3.32 Commercial Release which looks like July 2018

 

If you are only using Tiny2313,  the Evaluation version should be able to build projects up to 4kB.

So you could just download and install the free Evaluation.    And decide whether you want to upgrade or buy a fresh licence.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bnsavr wrote:
What memory ?

The memory in his head - the things he remembers.

 

Like the memory you use when you remember where you live, or what you had got lunch

 

It that a menu or properties window in CV ?

No!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

bnsavr wrote:

What memory ?

 

The memory in his head - the things he remembers.

 

Like the memory you use when you remember where you live, or what you had got lunch

 

Not to be confused with the voices in his head...

 

"Well, I'm off! .. [but only a little and it hardly shows] "

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
what you had got lunch

looks like I had a memory error part way through writing that!

 

frown

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...