Требуется программист в Зеленограде
- обработка данных с датчиков; ColdFire; 40 тыс. e-mail:jobsmp@pochta.ru |
ЖКИ: AMG-320240B-SBTLW-W-6
Схема: ЖКИ подключается напрямую к ногам контроллера.
D7-D0,^RST,^RD,^WR,A0-команда/данные.
Листинг: программа работала на мотороловском MC68HC908GP32 int main( void ) __disable_interrupt();//disable all interrupts LCD_INITIA(); //LCD controller SED1335 communication procedures //*********************************************************** LCD_SYSTEM(); //******************************************************* //*************************************************************** //*************************************************************** //*************************************************************** //*************************************************************** //*************************************************************** //*************************************************************** //*************************************************************** //*************************************************************** LCD_OUTCOM(0x46); //Set cursor position command YL_meadres2.i = I; //*************************************************************** unsigned char x; //*************************************************************** LCD_CSRW(0x0000); //*************************************************************** LCD_CSRW(0x0000); //*************************************************************** LCD_CSRW(0x1000); //*************************************************************** LCD_CSRW(0x3800); //*************************************************************** //*************************************************************** //*************************************************************** //*************************************************************** /***************************************************************
теперь не работает.
#include
#include
//define symbol names
#define SymNWr0 LcdPrt = LcdPrt & (0xFF - WRmask)
#define SymNWr1 LcdPrt = LcdPrt | WRmask
#define SymNRd0 LcdPrt = LcdPrt & (0xFF - RDmask)
#define SymNRd1 LcdPrt = LcdPrt | RDmask
#define SymRES0 LcdPrt = LcdPrt & (0xFF - RESmask)
#define SymRES1 LcdPrt = LcdPrt | RESmask
#define SymCD0 LcdPrt = LcdPrt & (0xFF - A0mask)
#define SymCD1 LcdPrt = LcdPrt | A0mask
#define SymDPTR P1DIR//DDRA
#define SymPrt P1OUT//PTA
#define LcdDPTR P2DIR//DDRA
#define LcdPrt P2OUT//PTA
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1OUT=0x00;
P1DIR=0xFF;
P1IES=0x00;
P1IE=0x00;
P1SEL=0x00;
P2OUT=0xff;
P2DIR=0xFF;
P2IES=0x00;
P2IE=0x00;
P2SEL=0x00;
//;RESET LCD
SymRES1;
delayUs(300);
SymRES0;
delayUs(300);
SymRES1;
delayUs(300);
return 0;
}
#include
#include "LCD_Hard_Interface.h"
#include "Delay.h"
/*
LCD Initialization
Port A & others, used in interface, set during main initialization (go_start).
(Without main init "go_start" you can't output to LCD)
*/
// LCD init
// ! See SED1335 command description
//***********************************************************
void LCD_INITIA()
{
SymNWr1;
LCD_SCROLL();
I_HDOT_SCR();
I_OVLAY();
I_DISPL_OFF();
I_CSR_RIGHT();
I_CLR_TXT0();
I_CLR_TXT1();
I_CLRGRF0();
I_CLRGRF1();
LCD_CSRW(0x0000);
I_CSRFORM();
I_DISPL_ON();
I_CSR_RIGHT();
//* Test
//*******************************************************
//message "EPSON"
I_CSR_RIGHT();
LCD_OUTCOM(0x42);
LCD_OUTDAT(0x20);
LCD_OUTBYT(0x45);
LCD_OUTBYT(0x50);
LCD_OUTBYT(0x53);
LCD_OUTBYT(0x4f);
LCD_OUTBYT(0x4e);
LCD_OUTCOM(0x42);
LCD_OUTCOM(0x42);
}
//***************************************************************
//* Output command byte to LCD
//***************************************************************
void LCD_OUTCOM(unsigned char Ch)
{
//data bus configure as output always if you write data
//data bus configure as input if you need read data - then reconfigure as output
SymCD1; //form 1 on CD output - command byte
SymNWr0;
SymPrt = Ch; //prepare data on data bus
__disable_interrupt(); //ineterrupts disable
//SymNCE0;
__no_operation(); //check pulse width !!!
SymNWr1;
//SymNCE1;
__enable_interrupt();
__no_operation(); //why pause?
//èòîãî ïðè âõîäå óñòàíîâèëè CD=1, ïðè âûõîäå íå âåðíóëè êàê áûëî
}
// Output data byte to LCD
//***************************************************************
void LCD_OUTDAT(unsigned char Ch)
{
//data bus configure as output always if you write data
//data bus configure as input if you need read data - then reconfigure as output
SymCD0; //form 0 on CD output - data byte
SymNWr0;
SymPrt = Ch; //prepare data on data bus
__disable_interrupt(); //ineterrupts disable
//SymNCE0;
__no_operation(); //check pulse width !!!
SymNWr1;
//SymNCE1;
__enable_interrupt();
__no_operation(); //why pause!?
//èòîãî ïðè âõîäå óñòàíîâèëè CD=1, ïðè âûõîäå íå âåðíóëè êàê áûëî
}
// Output byte to LCD (type of byte defined by previous byte)
//***************************************************************
void LCD_OUTBYT(unsigned char Ch)
{
//data bus configure as output always if you write data
//data bus configure as input if you need read data - then reconfigure as output
SymNWr0;
SymPrt = Ch; //prepare data on data bus
__disable_interrupt(); //ineterrupts disable
//SymNCE0;
__no_operation(); //check pulse width !!!
SymNWr1;
//SymNCE1;
__enable_interrupt();
__no_operation(); //why pause!?
//èòîãî ïðè âõîäå óñòàíîâèëè CD=1, ïðè âûõîäå íå âåðíóëè êàê áûëî
}
// Configure LCD controller (SED1335)
//***************************************************************
void LCD_SYSTEM(void)
{
//LCD_OUTCOM(SystemSet); //command SYSTEM SET
LCD_OUTCOM(0x40); //command SYSTEM SET
LCD_OUTDAT(0x36); //parameters of command SYSTEM SET
LCD_OUTDAT(0x07);
LCD_OUTDAT(0x0f);
LCD_OUTDAT(39);
LCD_OUTDAT(43);
LCD_OUTDAT(239);
LCD_OUTDAT(40);
LCD_OUTDAT(0);
}
// Command LCD_SCROLL
//***************************************************************
void LCD_SCROLL(void)
{
LCD_OUTCOM(0x44); //scroll
LCD_OUTDAT(0x00); //text low 1
LCD_OUTDAT(0x00); //text high
LCD_OUTDAT(239); //text hight
LCD_OUTDAT(0x00); //grafic low
LCD_OUTDAT(0x10); //grafic high
LCD_OUTDAT(239); //grafic hight
LCD_OUTDAT(0x00); //grafic low
LCD_OUTDAT(0x04); //grafic high
}
// Command HDOT_SCR
//***************************************************************
void I_HDOT_SCR(void)
{
LCD_OUTCOM(0x5A); //shift to zero
LCD_OUTDAT(0x00);
}
// Command OVLAY
//***************************************************************/
void I_OVLAY(void)
{
LCD_OUTCOM(0x5b); //ovlay
LCD_OUTDAT(0x01); //exclusiv 2-laers text
}
// Command DISPL_OFF_ON
//***************************************************************/
void I_DISPL_OFF(void)
{
LCD_OUTCOM(0x58); //display off
LCD_OUTDAT(0x00); //cursor off
}
// Command CSR_RIGHT
//***************************************************************/
void I_CSR_RIGHT(void)
{
LCD_OUTCOM(0x4c); //CSRDIR right direction of cursor movement
}
//***************************************************************
// Command LCD_CSRW
// Set cursor position
//***************************************************************/
void LCD_CSRW(unsigned int I)
{
union
{
unsigned int i;
unsigned char c[2];
} YL_meadres2;
LCD_OUTDAT(YL_meadres2.c[1]); //low adres
LCD_OUTDAT(YL_meadres2.c[0]); //high adres
}
//* Clear LCD area
//**************************************************************
void I_CLRTXGR(unsigned char AddrH,unsigned char AddrL)
{//1
I_CSR_RIGHT();
x = 0xff;
LCD_OUTCOM(0x42); //mwrite
LCD_OUTDAT(AddrL); //probel
do
{
do
{
LCD_OUTDAT(AddrL); //probel
x--;
}
while (x>0);
AddrH--;
}
while (AddrH>0);
}
//* Fill 4*256 bytes from addr 0x0000 by ' ' value
//***************************************************************
void I_CLR_TXT0(void)
{
I_CLRTXGR(0x04,' '); //20
}
//* Fill 4*256 bytes from addr 0x0000 by 0x20 value
//**************************************************************
void I_CLR_TXT1(void)
{
I_CLRTXGR(0x04,0x20); //20
}
//* Fill 40*256 bytes from addr 0x1000 by 0x00 value
//**************************************************************
void I_CLRGRF0(void)
{
I_CLRTXGR(40,0x00);
}
//* Fill 40*256 bytes from addr 0x3800 by 0x00 value
//**************************************************************
void I_CLRGRF1(void)
{
I_CLRTXGR(40,0x00);
}
//* Command CGRAM
//***************************************************************
void I_CGRAM(void)
{
LCD_OUTCOM(0x5c);
LCD_OUTDAT(0x00);
LCD_OUTDAT(0x00);
}
//* Command CSRFORM
//* Cursor form
//***************************************************************
void I_CSRFORM(void)
{
LCD_OUTCOM(0x5d); //scroll
LCD_OUTDAT(0x04); //01.02
LCD_OUTDAT(0x86); //01.02
}
//* Command DISPL_ON_OFF
//* DISPLAY ON
//***************************************************************
void I_DISPL_ON(void)
{
LCD_OUTCOM(0x59); //display on
LCD_OUTDAT(0x17); //cursor
}
//***************************************************************
// Command CSR_LEFT
//***************************************************************
void I_CSR_LEFT(void)
{
LCD_OUTCOM(0x4d); //CSRDIR left direction of cursor movement
}
// Command CSR_DOWN
//***************************************************************
void I_CSR_DOWN(void)
{
LCD_OUTCOM(0x4f); //CSRDIR down direction of cursor movement
}
*
************************************************************** */
void I_CSR_UP(void)
{
LCD_OUTCOM(0x4e); //CSRDIR up direction of cursor movement
}
Ответы