NHD-C12832A1Z Andy Gock glcd library atmega328p no output

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

I'm trying to make a graphic lcd work. Specifically the glcd NHD-C12832A1Z-FSW-FBW-3V3 that uses ST7565R driver ic.
I am using atmega328p at 8MHz internal and glcd library from Andy Gock.

 

I already setup the symbols as describe in the readme of glcd library.

DEBUG
GLCD_DEVICE_AVR8
GLCD_CONTROLLER_ST7565R
GLCD_USE_SPI
GLCD_INIT_NHD_C12832A1Z_FSW_FBW_3V3
GLCD_USE_AVR_DELAY
__DELAY_BACKWARD_COMPATIBLE__
F_CPU=8000000

I changed port and pin definitions in /devices/AVR8.h to suit my mcu.

    #define AVR_SS_PORT          PORTB
    #define AVR_SS_PIN           2
    #define CONTROLLER_MOSI_PORT PORTB
    #define CONTROLLER_MOSI_PIN  3
    #define CONTROLLER_MISO_PORT PORTB
    #define CONTROLLER_MISO_PIN  4
    #define CONTROLLER_SCK_PORT  PORTB
    #define CONTROLLER_SCK_PIN   5

    #define CONTROLLER_A0_PORT   PORTD /**< Output port to GLCD A0 pin. */
    #define CONTROLLER_A0_PIN    5     /**< Output pin number to GLCD A0 pin. */
    #define CONTROLLER_SS_PORT   PORTD
    #define CONTROLLER_SS_PIN    6
    #define CONTROLLER_RST_PORT  PORTD
    #define CONTROLLER_RST_PIN   7

I wired my hardware according to datasheet of the glcd. I am using 1uF caps for all pins that require caps. I used my own custom pcb breakout. Using TC1262-3.3VAB regulator from 5v powerbank.


Compiled the code without any errors.
Flash the program but nothing happened on glcd.

It supposed to output the demo and test from glcd library. Circles, counter and graph, text, hello world, etc.

I don't have any clue as to why it does not work.

 

Please help to find my mistakes so I can fix and make it work.
 

Hobbyist
Language:C
IDE:Atmel Studio v7.0.1931
Compiler:gcc v5.4.0 (AVR_8_bit_GNU_Toolchain_3.6.1_1750)
Tool:Atmel-ICE v1.27

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

Backlight is not connected?  This may be required to see the display.

Just a guess.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

Based on datasheet..the backlight is separate from lcd pins..
Nevertheless, I have tested with backlight connected now, and when powered, only the led lights up..
Any other ideas?

Hobbyist
Language:C
IDE:Atmel Studio v7.0.1931
Compiler:gcc v5.4.0 (AVR_8_bit_GNU_Toolchain_3.6.1_1750)
Tool:Atmel-ICE v1.27

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

After applying power to the display, wait a while

before trying to initialize it.

 

--Mike

 

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

You don't seem to have 4K7 pullup resistors on the I2C pins. It is unlikely to work without them.

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

From the Authors Website:

 

Are you using Atmel Studio?  Have you set F_CPU in the Studio Project?  I muddled through some of the files and saw nothing mentioned for setting f_CPU.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

avr-mike wrote:

After applying power to the display, wait a while

before trying to initialize it.

 

--Mike

 


I am at work..will try this when I get home
Kartman wrote:

You don't seem to have 4K7 pullup resistors on the I2C pins. It is unlikely to work without them.


Do I need them if I am using SPI?
jgmdesign wrote:

From the Authors Website:

 

Are you using Atmel Studio?  Have you set F_CPU in the Studio Project?  I muddled through some of the files and saw nothing mentioned for setting f_CPU.

 

JIm


Yes I am using AS7..I already set the F_CPU in the symbols

Hobbyist
Language:C
IDE:Atmel Studio v7.0.1931
Compiler:gcc v5.4.0 (AVR_8_bit_GNU_Toolchain_3.6.1_1750)
Tool:Atmel-ICE v1.27

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

Okay..I solved my problem...there is nothing wrong with the code...I just put 100k pullup on the lcd RST and CS1(SS) pins...

this is after looking at the xmega-a3bu xplained board's schematic...

I really don't know how else I'm going to know to put the pullup on these two pins if I haven't look at the schematic...

Now anyone got any ideas? Not even the lcd datasheet mention about a pullup on these two pins...

Hobbyist
Language:C
IDE:Atmel Studio v7.0.1931
Compiler:gcc v5.4.0 (AVR_8_bit_GNU_Toolchain_3.6.1_1750)
Tool:Atmel-ICE v1.27

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

Go on.   The controller datasheet will mention if there is an internal pullup.
 

In practice pullups are external resistors mounted on pcb or flexi-ribbon.

/CS always needs an external pullup to ensure the device is deselected before the MCU starts.

 

/RST is less critical but equally important to have under your control.

 

Most Chinese TFT modules have header pins for /CS and /RST but do not have pullups on the pcb.

COG Graphics modules seldom have the pullups.

 

David.

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

saifulkoh wrote:
.I just put 100k pullup on the lcd RST and CS1(SS) pins...

saifulkoh wrote:
Now anyone got any ideas? Not even the lcd datasheet mention about a pullup on these two pins...

Glad you got it working, as for the pull ups, that is something taught in engineering school, never leave important input pins (when connected to outputs that can tri-state) to float, provide default state with pull up or pull down....

Lessons learned the hard way, are never forgotten! smiley

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

The GLCD is sharing the SPI with the same pins that are used to program the 328. What can happen is that during chip programming the GLCD receives 'odd' commands because at this time its RESET and CS lines float because the 328 pins are all inputs during programming. Unless the code in the init() routine reliably returns the GLCD to a good state with a reset sequence then it will be unresponsive.

 

Character LCD displays with I2C interfaces are the same when you use bit-banged I2C on the SPI port. I found this out the hard way.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

Ah...I see...well..after looking at the code again, I think it did have something wrong...

In the glcd_init(), I can see the pins are set to output and pulled high...but no where the init for RST pin...so I added these

sbi( DDR(CONTROLLER_RST_PORT), CONTROLLER_RST_PIN );	//sk: set output
sbi(CONTROLLER_RST_PORT,CONTROLLER_RST_PIN);		//sk: set high

now it works perfectly without the external resistors smiley

Hobbyist
Language:C
IDE:Atmel Studio v7.0.1931
Compiler:gcc v5.4.0 (AVR_8_bit_GNU_Toolchain_3.6.1_1750)
Tool:Atmel-ICE v1.27