Pages: [1]   Go Down
Author Topic: ATMEGA 1284p and I2C LCD Woes  (Read 1106 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone

I am trying to integrate a 20x4 LCD into a project running on a bigger MCU

Basically simple LCD4bit->PCF8574A->SDA/SCL_with_4.7KPullups->MCU   circuit

Hardware (external to micro) not the issue:  If I connect SCL/SDA and GND to a ATmega328p with same sketch uploaded, I2C works, and my LCD works too
Running the I2CScanner.pde sketch (from Playground) - it detects my PCF8574 on 0-x38 just fine and dandy from a 328p

Software also works - as two different scenarios has same symptoms:
1.  I2C Scanner:  On ATMega328p : finds the I2C Device -  On ATmega1284P : Does not find any I2C Devices
2.  LiquidCrystal_I2C  -  On ATMega328p - no issue, change Board to 1284 (Gen7 with Marlin cores on Arduino 1.0.3) - upload (i.e. no changes to code: I2C pins are coded in cores so no need to define, and I2C Address/pinout stays the same - same sketch goes to both boards) and darn, display does not even initialise

Now since the I2C Scanner sketch does not even detect any I2C devices on the 1284p it would not find a device to initialise at the address either (despite we knowing it is correct address)

Now about 2 months ago when I started developing this, I was using a ATmega644P (had on hand) and that was working with same (though slightly older) codebase (Arduino 1.0.0 with Gen 7 2.0 Cores).   Then later in the project switched to 1284p.  Now the actual project's code is of no importance, as I am simply testing with the LiquidCrystal_I2C sketch:

SO the question started arising, I2C in some way disabled on the 1284p?  Looked at Engbedded's Fuse Calc and cannot see any fuses related to I2C/TWI (only SPI - which is enabled for my SD)

Someone mentioned PPR - a way to turn of LCD in code - but doubt strongly thats the case as it worked on the 644p...

Any ideas?

Code:
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR    0x38  // Define I2C Address where the PCF8574A is
#define En_pin  6
#define Rw_pin  5
#define Rs_pin  4
#define D4_pin  3
#define D5_pin  2
#define D6_pin  1
#define D7_pin  0

int n = 1;

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{
  pinMode(13, OUTPUT);
  lcd.begin(20,4);
 
  lcd.home();                   // go home

 lcd.print("I2C tester"); 
  lcd.setCursor ( 0, 1 );        // go to the 2nd line
  lcd.print("F Malpartida library");
  lcd.setCursor ( 0, 2 );        // go to the third line
  lcd.print("Test By OpenHardware");
  lcd.setCursor ( 0, 3 );        // go to the fourth line
  lcd.print(".co.za ");}

void loop()
{
  lcd.setCursor(14,3);        // go col 14 of line 3
  lcd.print(n++,DEC);
  digitalWrite(13, HIGH);
  delay(100);
  digitalWrite(13, LOW);
  delay(100);
 
}


Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My setup works when I use A0 for SCL and A1 for SDA.  The documentation for the ship says A4 and A5.  Could that be your problem?

Also, my backpack works at address 0x20. 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The 1284p has dedicated I2C pins on physical pins 22=SCL and 23=SDA

This is what I am using, and the 644 is in same place so still does not indicate what is different why 1284 does not work

Peter



Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using the ATMEGA 328 and its documentation says that SDA and SCL are at PC4 and PC5, but I found the signals at PC0 (Analog 0) and PC1(Analog 1).  Your documentation has them at PC0 and PC1.  I was able to find my signals by attaching LEDs and resistors to those pins.  The sketch "i2c_scanner" sends out a continuous signal. 

http://playground.arduino.cc/Main/I2cScanner

Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What pin mappings are you using.

On the Uno I have I2C at A4/Pin 27 (SDA) and A5/Pin 28 (SCL)

On the 1284P I use the Bobuino pin mapping and I have I2C at D22/Pin 22 (SCL) and D23/Pin 23 (SDA)

My I2C LCD/Keypads, via 3 different backpacks and a breadboarded 8574, work fine.

Everything was set by initially installing the Mighty1284P Optiboot bootloader with Bobuino pin map. That's just to set fuses etc and from then on I'm uploading via a 328 chip set as ISP. Fuses are Low = 0xff, High = 0xde, Extended = 0xfd

What pins are you connecting to on the 1284P, and have you checked the order as they are the opposite way round to on 328P, with SCL on the lower pin (22) and SDA on the higher (23).
« Last Edit: January 20, 2013, 01:45:18 pm by tack » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Guys, I really do not want you to take offence, but please read up about I2C before offering useless advice.  I2C is not "mapped pins" - it physical device connected to the pins as indicated.   

Please refrain from replying if you have less than 1 year of MCU experience.... I was hoping for input from someone who actually has it working with a PCF8574 and the library in question

@tack, have not tried the Boduino cores - doubtful the reprap community supports it
But glad to know you have it working on a 1284P!

My fuses are

Gen7-1284P-20.bootloader.low_fuses=0xF7
Gen7-1284P-20.bootloader.high_fuses=0xDC
Gen7-1284P-20.bootloader.extended_fuses=0xFC

Will check the difference on a fusecalc now...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oscilator:   Mine:  Crystal 8+, Yours Full Swing
Boot flash size:   Mine:  512 words, Yours 1024 words
Brownout:  Mine: 4.3v, Yours 2.7v
I have CKSEL3 on, yours off
I have BOOTSZ1 on, yours off

First three definately not related - checking datasheet re CKSEL3 (Clock source)

Peter
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I understand that I2C is on physical pins, but the equivalent position in Arduino digital/analog mapping IS dependent on the pin map.

If I used the mighty1284 standard map then the equivalent Arduino digital pins would NOT be D23 and D24, although the 1284P IC physical pins are obviously still 23 & 24.

You just said you were hoping from help from someone who has this working with the libraries in question. I do; a 1284P using several differently connected 8574, with both LiquidCrytal_I2C and Keypad_I2C, yet I'm offering 'useless advice'

If you don't want any input from someone with 'less than 1 years experience in MCU' then fine. The bottom line is that I2C works fine on my 1284p setup and not on yours, so go figure it out yourself without any further useless attempts from me to help.
Logged

Pages: [1]   Go Up
Jump to: