 |
:: عضو ذهبي ::
تاريخ التسجيل: Sep 2012
الدولة: العراق /البصره
المشاركات: 2,673
|
|
نشاط [ حسن هادي محمود ]
قوة السمعة:
|
|
28-07-2014, 04:00 PM
المشاركة 10
|
|
السلام عليكم انا كنت بستخدم الطريقة دة لمدة طويلة اختها من حضرتك والصراحة عجبتني اوي .بس دلوقتي في مشكلة وهيا اني بستخدم شاشة 16*4 الغريب بقا في الامر اني في السطر 3 والسطر 4 بجد الجملة كلها متشفتة نحوا اليمين 3 خانات ويبقا واجب عليا اني احط LCD_OUT (1,-3,"gf")g وهاكذا لا اعرف ما هوا السبب . دة المشكلة الاولي المشكلة الثانية .
اني لو بعرض اي كلام علي السطر الاول او الثاني بيظهر كلام في السطر الثالث والرابع كلام عشوائي مش عارف اية سببها .
دة كود انا شغال علية بستخدم اتنين PIC بستخدم واحدة منهم للعرض علي الشاشة والاخري هتكون ليها مهام خري .
كود:
//sbit lcd
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
////////////////////////////////////////////////////////////////////////////////
const char b[] =".....Welcome...." ;
const char e [] ="Running........." ;
const char l[] ="Error..........." ;
const char x13[] ="Finish.........." ;
const char x14[] ="Emergency......." ;
const char x15[] ="1-USB.......2-SD" ;
const char x16[] ="1RUN 2back 3main" ;
const char x17[] =".....waiting...." ;
const char x18[] ="....loading....." ;
const char x19[] ="enter_to_Back..." ;
////////////////////////////////////////////////////////////////////////////////
char mas,zz=1,yy=1,ii=1;int x;
char iitxt[7];
////////////////////////////////////////////////////////////////////////////////
void message(const char *pci,char zzz,char yyy)
{int x; char my_txt[16];
for(x=0;x<16;x++) my_txt[x]=pci[x];
lcd_out(zzz,yyy,my_txt);
}
////////////////////////////////////////////////////////////////////////////////
void show(char i){
if(zz==3||zz==4){yy=-3;}
else yy=1;
switch(i){
case 1 :message(b,zz,yy);break;
case 2 :message(e,zz,yy);break;
case 3 :message(l,zz,yy);break;
case 4 :message(x13,zz,yy);break;
case 5 :message(x14,zz,yy);break;
case 6 :message(x15,zz,yy);break;
case 7 :message(x16,zz,yy);break;
case 8 :message(x17,zz,yy);break;
case 9 :message(x18,zz,yy);break;
case 10:message(x19,zz,yy);break;
}
}
////////////////////////////////////////////////////////////////////////////////
void main() {
trisa=0; porta=0;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
uart1_init(9600);
while(1){
while(!UART1_Data_Ready()){}
ii = UART1_Read();
while(!UART1_Data_Ready()){}
zz = UART1_Read();
show(ii);
if(zz==4){delay_ms(20);Lcd_Cmd(_LCD_CLEAR);}
}}
[IMG] [/IMG]
|
السلام عليكم
في أحدى مواقع الاجنبيه قد سئلت عن هذه مشكله وقد حصلت على الحل لهذه مشكله
http://www.mikroe.com/forum/viewtopi...=59790#p237409
هذا هو الكود الي يجب التعامل معه مع الشاشات 4x16
كود:
const char facter=16;
كود:
void Lcd_Out20(char row, char col, char *txt) {
switch (row) {
case 1: Lcd_Cmd(128 + 0 + col - 1); break;
case 2: Lcd_Cmd(128 + 64 + col -1); break;
case 3: Lcd_Cmd(128 + facter + col - 1); break;
case 4: Lcd_Cmd(128 + 64+facter + col - 1); break;
default: return;
}
Lcd_Out_CP(txt);
}
شوف هذا الكود
كود:
//sbit lcd
sbit LCD_RS at LATB4_bit ;
sbit LCD_EN at LATB5_bit ;
sbit LCD_D4 at LATB0_bit ;
sbit LCD_D5 at LATB1_bit ;
sbit LCD_D6 at LATB2_bit ;
sbit LCD_D7 at LATB3_bit ;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
const char txt1[]="ramadan kareem ";
const char txt2[]="ramadan kareem ";
const char txt3[]="ramadan kareem ";
const char txt4[]="ramadan kareem ";
const char facter=16;
//********************************************//
void Lcd_Out20(char row, char col, char *txt) {
switch (row) {
case 1: Lcd_Cmd(128 + 0 + col - 1); break;
case 2: Lcd_Cmd(128 + 64 + col -1); break;
case 3: Lcd_Cmd(128 + facter + col - 1); break;
case 4: Lcd_Cmd(128 + 64+facter + col - 1); break;
default: return;
}
Lcd_Out_CP(txt);
}
////////////////////////////////////////////////////////////////////////////////
void message(const char *pci,short zzz,short yyy)
{int x; char my_txt[16];
for(x=0;x<16;x++) my_txt[x]=pci[x];
lcd_out20(zzz,yyy,my_txt);
}
void main()
{
anselb=0;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
message(txt1,1,1);
message(txt2,2,1);
message(txt3,3,1);
message(txt4,4,1);
}
|