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.