[an error occurred while processing this directive]
Народ подскажите в чем проблема, нашел где то в сети исходник для работы с ЖК индикатором подправил его под себя, но почему-то не работает (+)
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено ilychoff 29 мая 2006 г. 10:49

компилятор IAR кварц 8 МГц

<>

/***********************************************************************
Port, PINS and LCD defines
***********************************************************************/
// LCD pins
#define DB7 0x80 //PORTC_Bit7
#define DB6 0x40 //PORTC_Bit6
#define DB5 0x20 //PORTC_Bit5
#define DB4 0x10 //PORTC_Bit4
#define ENABLE 0x04 //PORTC_Bit2
#define RS 0x01 //PORTC_Bit0

// Port
#define LCDDDR DDRC
#define LCDPORT PORTC
#define LCDPIN PINC
// General defines
#define DATA 0x01
#define CTRL 0x00
// Delay factor, increase with higher CPU clock. Use 40 with 8MHz
#define DELAY 40

/***********************************************************************
Prototypes
***********************************************************************/
void tlcd_init(void);
void tlcd_cls(void);
void tlcd_goto(unsigned char column, unsigned char line);
void tlcd_write_string(char *ptr);
void tlcd_write_byte(unsigned char control, unsigned char byte);
void tlcd_delay(int loops);


-------------------------------------------------------
<>

/***********************************************************************
Includes
***********************************************************************/
#include
#include
#include "tlcd.h"


/***********************************************************************
Clears all text.
***********************************************************************/
void tlcd_cls()
{
tlcd_write_byte(CTRL,0x01);
tlcd_delay(50);
}


/***********************************************************************
Goto specified column and line. 1,1 is the upper left corner.
***********************************************************************/
void tlcd_goto(unsigned char column, unsigned char line)
{
unsigned char addr;
line--;
column--;
addr = (line * 64) + column;
tlcd_write_byte(CTRL, addr | 0x80);
}


/***********************************************************************
Write strings to the display. Set position with tlcd_goto first.
Text will wrap if to long to show on one line.
***********************************************************************/
void tlcd_write_string(char *ptr)
{
while (*ptr != 0x00) tlcd_write_byte(DATA,*ptr++);
}


/***********************************************************************
Write a control or data byte to the display. Control: 1=Ctrl, 0=Data
If data (control=0) set position with lcd_goto first.
Since the LCD is driven in 4-bit modus, we write the MSB nibble first
and the the LSB nibble.
***********************************************************************/
void tlcd_write_byte(unsigned char control, unsigned char byte)
{

if ((byte & 0x80) == 0x80) LCDPORT |= DB7; else LCDPORT &= ~DB7;
if ((byte & 0x40) == 0x40) LCDPORT |= DB6; else LCDPORT &= ~DB6;
if ((byte & 0x20) == 0x20) LCDPORT |= DB5; else LCDPORT &= ~DB5;
if ((byte & 0x10) == 0x10) LCDPORT |= DB4; else LCDPORT &= ~DB4;
if (control == 1) LCDPORT |= RS; else LCDPORT &= ~RS;
LCDPORT |= ENABLE;
LCDPORT &= ~ENABLE;

if ((byte & 0x08) == 0x08) LCDPORT |= DB7; else LCDPORT &= ~DB7;
if ((byte & 0x04) == 0x04) LCDPORT |= DB6; else LCDPORT &= ~DB6;
if ((byte & 0x02) == 0x02) LCDPORT |= DB5; else LCDPORT &= ~DB5;
if ((byte & 0x01) == 0x01) LCDPORT |= DB4; else LCDPORT &= ~DB4;
if (control == 1) LCDPORT |= RS; else LCDPORT &= ~RS;
LCDPORT |= ENABLE;
LCDPORT &= ~ENABLE;

tlcd_delay(2);

}


/***********************************************************************
Makes a variable delay
Use the DELAY define to adjust for MCU clock.
***********************************************************************/
void tlcd_delay(int loops)
{
int i,j;
for (i=0;i {
for (j=1; j asm("WDR");
}
}


/***********************************************************************
Set up selected port and initialize the LCD controller in 4-bit modus.
***********************************************************************/
void tlcd_init(void)
{
LCDPORT = 0x00;
LCDDDR = 0xF5;
tlcd_delay(350);
LCDPORT = (DB6 + DB7);
LCDPORT |= ENABLE;
LCDPORT &= ~ENABLE;
tlcd_delay(100);
LCDPORT |= ENABLE;
LCDPORT &= ~ENABLE;
tlcd_delay(100);
LCDPORT |= ENABLE;
LCDPORT &= ~ENABLE;
tlcd_delay(100);
LCDPORT = DB6;
LCDPORT |= ENABLE;
LCDPORT &= ~ENABLE;
tlcd_delay(100);
tlcd_write_byte(CTRL,0x28);
tlcd_write_byte(CTRL,0x0c);
tlcd_write_byte(CTRL,0x01);
tlcd_delay(100);
tlcd_write_byte(CTRL,0x06);
tlcd_delay(10);
}

--------------------------------------------------------

<>

/***********************************************************************
Includes
***********************************************************************/
#include
#include "tlcd.h"


/***********************************************************************
Main
***********************************************************************/
void main(void)
{


tlcd_init();
tlcd_cls();
tlcd_goto(1,1);
tlcd_write_string("Test");

while(1);
}



Составить ответ  |||  Конференция  |||  Архив

Ответы


Отправка ответа

Имя (обязательно): 
Пароль: 
E-mail: 
NoIX ключ Запомнить

Тема (обязательно):
Сообщение:

Ссылка на URL: 
Название ссылки: 

URL изображения: 


Rambler's Top100 Рейтинг@Mail.ru
Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание

E-mail: info@telesys.ru