Witam próbuje uruchomić graficzny wyświetlacz lcd ze sterownikiem nt7532 i na razie nie chce ze mną gadać
Pisał może ktoś sterownik do podobnego wyświetlacza i chciałby się podzielić kodem
Wrzucam kodzik mojego stera może ktoś znajdzie jakieś rażące błędy
#include <avr/io.h>
#include <util/delay.h>
#include <inttypes.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <avr/wdt.h>
#include "harddef.h"
#include "makra.h"
//#include <stdio.h>
void sendByte (uint8_t byte)
{
for(uint8_t a=0; a<8 ; a++)
{
if((byte & 0x80)!=0){
PORT(LCD_SDA_PORT) |= 1<<LCD_SDA;
}else{
PORT(LCD_SDA_PORT)&= ~(1<<LCD_SDA);
}
PORT(LCD_SCK_PORT) |= 1<<LCD_SCK;
PORT(LCD_SCK_PORT) &= ~(1<<LCD_SCK);
byte = byte*2;
}
}
inline void lcd_on (void)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0xAF);
}
inline void lcd_off (void)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0xAE);
}
inline void lcd_setDisplayStartLine (uint8_t line)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0x40|(line & 0x3F));
}
inline void lcd_setPageAddress(uint8_t address)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0xB0 | (address & 0x0F));
}
inline void lcd_setColumnAdderss(uint8_t address)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0x10|((address>>4)&0x0F));
sendByte(address&0x0F);
}
inline void lcd_writeDisplayData(uint8_t data)
{
PORT(LCD_A0_PORT) |= 1<<LCD_A0;
sendByte(data);
}
#define RIGHTROT 0
#define LEFTROT 1
inline void lcd_ADCselect (uint8_t dir)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0xA0 | (dir & 0x01));
}
#define DISPLAY_NORMAL 0
#define DISPLAY_REVERSE 1
inline void lcd_display(uint8_t dir)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0xA6 | (dir & 0x01));
}
inline void lcd_entireDisplayOn(uint8_t mode)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0xA4 | (mode& 0x01));
}
inline void lcd_setLCDbias(uint8_t bias)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0xA2|(bias&0x01));
}
inline void lcd_readModifityWrite(void)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0xE0);
}
inline void lcd_end(void)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0xEE);
}
inline void lcd_reset(void)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0xE2);
}
#define STATUS_NORMAL 0
#define STATUS_REVERSE 8
inline void lcd_outputStatusSelactRegister(uint8_t status)
{
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
sendByte(0xC0 | (status&0x08));
}
void lcd_initIO(void)
{
DDR(LCD_RESET_PORT) |= 1<<LCD_RESET;
DDR(LCD_A0_PORT) |= 1<<LCD_A0;
DDR(LCD_CS_PORT) |= 1<<LCD_CS;
DDR(LCD_SCK_PORT)|= 1<<LCD_SCK;
DDR(LCD_SDA_PORT)|= 1<<LCD_SDA;
DDR(LCD_LEDK_PORT)|=1<<LCD_LEDK;
PORT(LCD_RESET_PORT) &= ~(1<<LCD_RESET);
PORT(LCD_A0_PORT) &= ~(1<<LCD_A0);
PORT(LCD_CS_PORT) |= 1<<LCD_CS;
PORT(LCD_SCK_PORT)&= ~(1<<LCD_SCK);
PORT(LCD_SDA_PORT)&= ~(1<<LCD_SDA);
PORT(LCD_LEDK_PORT)&= ~(1<<LCD_LEDK);
}
inline void lcd_init(void)
{
PORT(LCD_RESET_PORT) &= ~(1<<LCD_RESET);
PORT(LCD_RESET_PORT) |= 1<<LCD_RESET;
}
int main (void)
{
lcd_initIO();
lcd_init();
lcd_on();
lcd_reset();
lcd_setLCDbias(0x01);
lcd_ADCselect(RIGHTROT);
lcd_setDisplayStartLine(0);
lcd_setPageAddress(0);
lcd_setColumnAdderss(0);
for(uint8_t licznik=0;licznik <100;licznik++)
{
lcd_writeDisplayData(licznik);
}
for(;;){}
return 0;
}
