probs mit GLCD Nokia3100

Gast #366683
Lesenswert?
• ▲
▼
Hallo

Habe hier im Forum eine Libary gefunden und an meinen  128iger
angepasst leiser tut das Display nichts mit Bascom und der Lib von
Display 3000 Funktionioert das Display.

http://www.mikrocontroller.net/forum/read-4-74872.html#new

Meine Ports:
Port B
RS=B.6
CS=B.5
SData=B.2
SCLK=B.1

Habe ich in der glcd.h eingesetzt

  #define LCD_PORT                PORTB
  #define LCD_PIN                 PINB
  #define LCD_DDR                 DDRB
  #define LCD_CS                  5     // SS
  #define LCD_SDA                 2     // MOSI
  #define LCD_RESET               6     // MISO
  #define LCD_SCL                 1     // SCK

Was muß man noch anpassen

Die MCU habe ich auf Mega128 gesezt
Gast #366684
Lesenswert?
• ▲
▼
Habe mal probiert alles von Bascom nach C zu Portieren geht auch nicht.


inhalt von display.c

#include <avr/io.h>
#include <util/delay.h>

#define WHITE                   0xff

const int Kommando = 0;
const int Parameter = 1;

unsigned char lcd_initdata[] ={0x00 , 0x02 , 0x04 , 0x06 , 0x09 , 0x0B
, 0x0D , 0x0F , 0x00 , 0x02 , 0x04 , 0x06 , 0x09 , 0x0B , 0x0D , 0x0F ,
0x00 , 0x04 , 0x0B , 0x0F};

void lcd_sendbyte(int befehl,char ausgabe);
void waitms(char x) ;
void lcd_window(int x1,int x2,int y1,int y2);
void lcd_box(int lx1,int lx2,int ly1,int ly2,unsigned char color);
void lcd_cls(int px1,int px2,int py1,int py2,unsigned char color);


void lcd_cls(int px1,int px2,int py1,int py2,unsigned char color)
{
  lcd_box(px1,px2,py1,py2,color);
}

void init_displ (void)
{

  DDRB = (1 << DDB1) | (1 << DDB2) | (1 << DDB5) | (1 << DDB6) ;
  SPSR     |= (1 << SPI2X);
  SPCR      = (1 << MSTR) | (1 << CPOL) | (1 << CPHA);

  PORTB &= ~(1 << DDB6);
 waitms(10);
  PORTB |= (1 << DDB5);
  PORTB |= (1 << DDB2);
  PORTB |= (1 << DDB1);
  lcd_sendbyte(Kommando,0x01);
  waitms(10);
  lcd_sendbyte(Kommando,0x11);
  waitms(40);
   lcd_sendbyte(Kommando,0x29);
   waitms(40);
   lcd_sendbyte(Kommando,0x3a);
   lcd_sendbyte(Parameter,0x02);
   lcd_sendbyte(Kommando,0x20);
   lcd_sendbyte(Kommando,0x36);
   lcd_sendbyte(Parameter,0x00);
   lcd_sendbyte(Kommando,0x2d);

  int i;
   for (i = 1;i<21;i++)
   {
      lcd_sendbyte(Parameter,lcd_initdata[i]);
  }

   lcd_cls(0,0,132,132,WHITE);


}

void lcd_box(int lx1,int lx2,int ly1,int ly2,unsigned char color)
{

int px;
int py;
int pixel;
int i;
  lcd_window(lx1,lx2,ly1,ly2);
   px = lx2 - lx1;
   px++;
   py = ly2 - ly1;
   py++;
   pixel = px * py;
   for (i = 1;i<= pixel;i++)
   {
      lcd_sendbyte(Parameter,color);

   }

}



void lcd_window(int x1,int x2,int y1,int y2)
{
 lcd_sendbyte(Kommando,0x2a);
 lcd_sendbyte(Parameter,x1);
 lcd_sendbyte(Parameter,x2);
 lcd_sendbyte(Kommando,0x2b);
 lcd_sendbyte(Parameter,y1);
 lcd_sendbyte(Parameter,y2);
 lcd_sendbyte(Kommando,0x2c);
}


void lcd_sendbyte(int befehl,char ausgabe)
{

PORTB &= ~(1<<DDB5);
PORTB &= ~(1<<DDB1);
 if (befehl ==0)
 {
  PORTB &= ~(1<<DDB2);

}
 else
{
PORTB |= (1<<DDB2);
}
PORTB |= (1<<DDB1);
SPCR |= (1 << SPE);
SPDR = ausgabe;
PORTB |= (1<<DDB5);
}

void waitms(char x)
{
unsigned char a, b; // zmnienne licznikowe
for( ; x > 0; --x) // ta petla zostanie wykonana x-razy
  for(b = 10; b > 0; --b) // a ta 10 razy
   for(a = 100; a > 0; --a) // natomiast ta 100 razy
   __asm("nop"); // dodatkowa instrukcja opózniajaca o 1 cykl
   // razem to da opóznienie ok. x * 1ms
   // x od 0 do 255
}



inhalt von display.h

void init_displ (void);

inhalt von main.c
#include <avr/io.h>
#include "display.h"




int main(void)
{
init_displ();
while(1)
{

}
return (0);

}



Das Display müsste danach weiss werden.

Tut es aber nciht es macht gar nichts.

Antwort schreiben

Hinweis: der ursprüngliche Beitrag ist mehr als 6 Monate alt. Bitte hier nur auf die ursprüngliche Frage antworten, für neue Fragen einen neuen Beitrag erstellen.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.