[SOLVED] ATMega1284P with UTFT

I am using this shield for I/O on an arduino UNO (ATMega328p) and a custom arduino (bobuino ATMega1284p).

On UNO it works fine, but on bobuino there is no signal, just a white screen. I thought i'd check the voltages on the uC pins and here is what i found:

bobuino uno
shield no shield shield no shield
rst 4 4.6 4.08 4.7
3.3V 3.3 3.3 3.3 3.3
5V 4.4 4.6 4.5 4.7

0 0.93 1 1 1
1 2.38 2.5 2.5 2.5
2 1.6 1.7 1.6 1.7
3 1.11 1.18 1.1 1.2

4 0.05 0 0.7 0.7 --
5 0.05 0 1.4 1.5 --
6 0.05 0 1.4 1.5 --
7 0.05 0 0.4 0.4 --
8 1.38 1.5 0 0 --
9 1.48 1.5 3.25 0 --

10 4.36 4.6 4.4 4.7
11 4.36 4.6 4.4 4.7
12 3.24 0 3.25 0
13 0 0 0 0

A0 2.52 2.7 2.6 2.7
A1 1.7 1.8 1.7 1.8
A2 3.6 3.8 3.6 3.8
A3 4.37 4.6 4.5 4.7
A4 2.47 0 2.5 0
A5 0.06 0 0.07 0

I checked both uC pins as well as board pins. As you can see, the board pins 4-9 have different voltages, something i don't understand why is happening.

The LCD uses pins 0-7 as data pins and pin 8 as TF card SS and pin 9 as Touch IRQ. The fact that the data pins have close to 0V explains why the screen is white and does not print anything.

Why two different uCs produce different signals on their pins while having loaded the same program?

fleshmachine:
Why two different uCs produce different signals on their pins while having loaded the same program?

The differences seem pretty small and might be accounted for by differences in the power regulation and any other external components between the microprocessor chip and the external pins. The same sketch on different chips can also produce very different behaviours if you use different Board types since this will determine the relationship between the hardware abstraction that the runtime library presents to the sketch, and the underlying hardware.

Post your sketch, may be a functional difference on a couple of the pins too.
Are some of those PWM outputs?

CrossRoads:
Post your sketch, may be a functional difference on a couple of the pins too.
Are some of those PWM outputs?

I am using any sketch from the UTFT library with an LCD screen using SSD1289 chip. Instead of getting the resulting messages/screens, i get a white glowing screen, which leads me to think that the data bus* is the one with the problem, meaning pins 4-7, which show the only important voltage differences between the two boards. I checked the voltage output from both the pins and the uC legs. There is no difference between these two, which makes me believe that the difference in uCs is what is causing the problem

*the data bus for the LCD screen are the digital pins 0-7

There is no info on the LCD user guide about the signals used
http://www.uctronics.com/download/Arduino_shileds/3inch2_Arduino_LCD_Shield_RevB_UG.pdf

From looking in the UTFT library a little bit i think i understand that there are different structures for each mC in it. For example, there are differing codes for an ATMega328p and an ATMega1280. Isn't the ATMega1284 supposed to be "similar" to the ATMega1280? Am i supposed to "tweak" the library in order to make it think it works with an ATMega1280?

http://www.henningkarlsen.com/electronics/h_utft_arduino_shield_on_mega.php
From reading the above link i found this out: ATMega328 uses PD0-PD7 pins for digital D0-D7
while ATMega1284 uses PD0-PD3 for D0-D3 and PB0-PB3 for D4-D7. I guess that's why there is no output in pins 4-7.

I checked the outputs again. From looking at the voltages that differ you get this info:

  1. bobuino pin 8 is PD5 which is why it's equal to UNO pin 5 (PD5)
  2. bobuino pin 9 is PD6 which is why it's equal to UNO pin 6 (PD6)
  3. in general, ATMega1284 pins 18-21 are PD4-7 and are equal to UNO pins 4-7
  4. While the same principle works on pins 4 and 5 on bobuino (PB0 and PB1), it does not work with the SPI pins, which already have similar outputs on both boards, even though they are different uC pins (bobuino uses PB4-7 while UNO uses PB2-5)

OK! Final update. As Henning Karlsen said on this ATMega1280 tutorial, you must find which output works for each microcontroller, in his example, ATMega1280 uses ports this way:

Digital Pin 0 = PE0 (Port E - bit 0)
Digital Pin 1 = PE1 (Port E - bit 1)
Digital Pin 2 = PE4 (Port E - bit 4)
Digital Pin 3 = PE5 (Port E - bit 5)
Digital Pin 4 = PG5 (Port G - bit 5)
Digital Pin 5 = PE3 (Port E - bit 3)
Digital Pin 6 = PH3 (Port H - bit 3)
Digital Pin 7 = PH4 (Port H - bit 4)

While Bobuino uses ports this way:

Digital Pin 0 = PD0 (Port D - bit 0)
Digital Pin 1 = PD1 (Port D - bit 1)
Digital Pin 2 = PD2 (Port D - bit 2)
Digital Pin 3 = PD3 (Port D - bit 3)
Digital Pin 4 = PB0 (Port B - bit 0)
Digital Pin 5 = PB1 (Port B - bit 1)
Digital Pin 6 = PB2 (Port B - bit 2)
Digital Pin 7 = PB3 (Port B - bit 3)

So i had to go to libaries/UTFT/HW_AVR.h and insert some code in there

Specifically:
in
void UTFT::LCD_Writ_Bus(char VH,char VL, byte mode)
i added after
#if defined(AVR_ATmega1280) || defined(AVR_ATmega2560)
ends and before
#else
this code:

#elif defined(AVR_ATmega1284P)
PORTD = ((VH & 0X0F));
PORTB = ((VH & 0xF0) >> 4);
pulse_low(P_WR, B_WR);
PORTD = ((VL & 0X0F));
PORTB = ((VL & 0xF0) >> 4);
pulse_low(P_WR, B_WR);

and in
void UTFT::_set_direction_registers(byte mode)
i added after
#if defined(AVR_ATmega1280) || defined(AVR_ATmega2560)
and before
#else
this code:

#elif defined(AVR_ATmega1284P)
DDRB = 0x0F;
DDRD = 0x0F;

What these two codes do is this:
The second one defines Port B pins 0~3 and Port D pins 0~3 as output
The first one takes the VH and VL bytes and puts them in these pins.

Hope this helps anyone who uses bobuino with the UTFT code :smiley:

Cool!

Hi,

I would like to use 2.8 Adafruit TFT with 1284p arduino compatible PCB.

However, the file "HW_AVR.h" contains only this:

Void UTFT :: _ convert_float (char * buf, double num, int width, byte prec)
{
Dtostrf (num, width, prec, buf);
}

How can I modify the code?
and
how do I enter the pin parameters?
UTFT myGLCD(DMTFT28105,?,?,?,?);

I use the "maniacbug" Mighty 1284p 16MHz using the Optiboot directory.

thanks.