microcontroller doesn't work with Nokia 5110 LCD (PCD8544)

I'm struggling with my first AVR microcontroller - AtTiny85 to make it work with the known Nokia 5110 display. I wrote my own code to handle the LCD, it didn't work. Then I tried a code found somewhere on the Internet, it supposed to handle the display, but it didn't too. I though that my display is broken, but I attached it to Raspberry Pi and executed an Adafruit script - it worked without any problems.

#include <avr/io.h> #include <util/delay.h>  #define PIN_SCE PB0 #define PIN_RESET PB1 #define PIN_DC PB2 #define PIN_SCLK PB3 #define PIN_MOSI PB4  enum {     FUNCTION_SET = 0x20,     FS_CHIP_POWERDOWN = 0x4,     FS_VERTICAL_ADDR = 0x2,     FS_EXTENDED_INSTR = 0x1,      DISPLAY_NORMAL = 0xc,     DISPLAY_BLANK = 0x8,     DISPLAY_ALL_ON = 0x9,     DISPLAY_INVERSE = 0xd,      DRAM_SET_X = 0x80,     DRAM_SET_Y = 0x40, };  void BitTransfer(uint8_t Bits) {     PORTB &= ~(1 << PIN_SCE);     int8_t i;     for(i = 7; i>=0; i--)     {         if((Bits >> i) & 1)             PORTB |= (1 << PIN_MOSI);         else            PORTB &= ~(1 << PIN_MOSI);          PORTB |= (1 << PIN_SCLK);         _delay_us(10);         PORTB &= ~(1 << PIN_SCLK);         _delay_us(10);     }     PORTB &= ~(1 << PIN_MOSI);     PORTB |= (1 << PIN_SCE); }  void SendCommand(uint8_t Command) {     PORTB &= ~(1 << PIN_DC);     BitTransfer(Command); }  void SendData(uint8_t Data) {     PORTB |= (1 << PIN_DC);     BitTransfer(Data); }  int main(void) {     DDRB |= (1 << PIN_SCE);     DDRB |= (1 << PIN_RESET);     DDRB |= (1 << PIN_DC);     DDRB |= (1 << PIN_SCLK);     DDRB |= (1 << PIN_MOSI);     PORTB = 0;     _delay_us(10);     PORTB |= (1 << PIN_RESET);     PORTB |= (1 << PIN_SCE);     _delay_us(10);      SendCommand(FUNCTION_SET | FS_EXTENDED_INSTR);     SendCommand(0xa5); // VOP     SendCommand(0x06); // temp coefficient     SendCommand(0x13); // BIAS     SendCommand(FUNCTION_SET);     SendCommand(DISPLAY_ALL_ON);     while(1)     {     }      return 0; } 

I power my AVR using 3.3v pinout of Raspberry Pi, same with the LCD. The AVR is working at 1 MHz frequency. When I disconnect the plug leading to the ground, a black line appears on the screen for a short while. I don't know, maybe it's a hardware problem?

Replay

Category: avr Time: 2016-07-28 Views: 0
Tags: lcd avr spi

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.137 (s). 12 q(s)