I think Mikro C compiler have problem,
device: AT89C52;
prequency: 12MH;
When i write C code in Mikro C, it successful compile, but when i simulate on Proteus, it run but have wrong answer
:
program:
//khai bao cac bien toan cuc
sbit en at P3_5_bit;
sbit rw at P2_7_bit;
sbit rs at P2_6_bit;
sfr data1 at P0;
unsigned char code xau1[] = "truong dhhh vietnam";
unsigned char code xau2[] = "8051 visual lcd";
// khai bao cac ham
void ktht(void);
void delay(void);
void ktlcd(void);
void ghilenh(unsigned char lenh);
void ghidulieu(unsigned char dulieu);
void w2lcd(unsigned char x);
void guixau2lcd(unsigned char code *p);
void hienthi(void);
// dinh nghia cac ham
void delay(unsigned int n)
{
unsigned int i;
unsigned int j;
for(i = 0; i < n; i++)
{
for(j = 0; j <100;j++)
{
;// ngoi choi
}
}
}
void w2lcd(unsigned char x)
{
rw =0;
data1 = x;
en =1;
en = 0;
delay(100);
}
void ghilenh(unsigned char lenh)
{
rs = 0;
w2lcd(lenh);
}
void ghidulieu(unsigned char dulieu)
{
rs = 1;
w2lcd(dulieu);
}
void ktlcd(void)
{
ghilenh(0x30);
ghilenh(0x30);
ghilenh(0x30);
// 8 bit,2 dong, font 5x7
ghilenh(0x38);
// bat hien thi, an con tro
ghilenh(0x0C);
// xoa man hinh
ghilenh(0x01);
}
void ktht(void)
{
en = 0;
ktlcd();
}
void ghixau2lcd(unsigned char code *p)
{
unsigned char i = 0;
while( p != 0)
{
ghidulieu(p);
i++;
delay(200);
}
}
void hienthi(void)
{
// dich con tro den vi tri thu 2 hang thu nhat
ghilenh(0x81);
ghixau2lcd(xau1);
// dich con tro den dau dong thu 2
ghilenh(0xC0);
ghixau2lcd(xau2);
}
// chuong trinh chinh
void main(void)
{
ktht();
hienthi();
while(1);
}
but when i write same this code in keilC it run very well, I think your compiler have problem:
my program in Keil C:
#include <REGX52.H>
//khai bao cac bien toan cuc
//khai bao cac bien toan cuc
sbit en = P3^5;
sbit rw = P2^7;
sbit rs = P2^6;
sfr data1 = 0x80;
unsigned char code xau1[] = " truong dhhh vn";
unsigned char code xau2[] = "8051 visual lcd";
// khai bao cac ham
void ktht(void); // ham kiem tra he thong
void delay(void); // ham tao tre
void ktlcd(void); // ham kiem tra lcd
void ghilenh(unsigned char lenh); // ham ghi lenh
void ghidulieu(unsigned char dulieu); // ham ghi du lieu
void w2lcd(unsigned char x); // ham set rs, rw
void guixau2lcd(unsigned char code *p); // gui xau >> lcd
void hienthi(void); // hien thi
// dinh nghia cac ham
void delay1(unsigned int i)
{
for(i = 0; i < 10000;i++)
{
; // ngoi choi
}
}
void w2lcd(unsigned char x)
{
rw =0;
data1 = x;
en =1;
en = 0;
delay1(1000);
}
void ghilenh(unsigned char lenh)
{
rs = 0;
w2lcd(lenh);
}
void ghidulieu(unsigned char dulieu)
{
rs = 1;
w2lcd(dulieu);
}
void ktlcd(void)
{
ghilenh(0x30);
ghilenh(0x30);
ghilenh(0x30);
// 8 bit,2 dong, font 5x7
ghilenh(0x38);
// bat hien thi, an con tro
ghilenh(0x0C);
// xoa man hinh
ghilenh(0x01);
}
void ktht(void)
{
en = 0;
ktlcd();
}
void ghixau2lcd(unsigned char code *p)
{
unsigned char i = 0;
while( p != 0)
{
ghidulieu(p);
i++;
delay1(2000);
}
}
void hienthi(void)
{
// dich con tro den vi tri thu 2 hang thu nhat
ghilenh(0x81);
ghixau2lcd(xau1);
// dich con tro den dau dong thu 2
ghilenh(0xC0);
ghixau2lcd(xau2);
}
// chuong trinh chinh
void main(void)
{
while(1)
{
ktht();
hienthi();
delay1(100000);
}
}
and another problem: when I use MikroC's LCD library, but it not work when I simulate in Proteus., I asked my teacher, he tried 1 hour to wrote his code and conected with hardware but not work,
can anybody help?
problem, help ??
General discussion on mikroC PRO for 8051.
Author
Message
-
- Posts: 7
- Joined: 12 Sep 2012 13:55
Re: problem, help ??
#2 Post by filip » 14 Sep 2012 10:30
Hi,
I believe that you have the same conversation here :
http://www.mikroe.com/forum/viewtopic.p ... 01#p196301
Regards,
Filip.
I believe that you have the same conversation here :
http://www.mikroe.com/forum/viewtopic.p ... 01#p196301
Regards,
Filip.
-
- Posts: 7
- Joined: 12 Sep 2012 13:55
Re: problem, help ??
#3 Post by energetichiddenboy » 14 Sep 2012 16:40
yes, I'm a new member, I sent my post 2 times,
sorry, i will notice with my posts in future!
sorry, i will notice with my posts in future!
Return to “mikroC PRO for 8051 General”
Jump to
- NECTO Studio
- ↳ IDE
- ↳ IDE General
- ↳ IDE Beta Testing
- ↳ IDE Wish List
- ↳ ARM AI Compilers
- ↳ mikroC AI for ARM
- ↳ mikroC AI for ARM General
- ↳ mikroC AI for ARM Beta Testing
- ↳ mikroC AI for ARM Wish List
- ↳ PIC AI compilers
- ↳ mikroC AI for PIC
- ↳ mikroC AI for PIC General
- ↳ mikroC AI for PIC Beta Testing
- ↳ mikroC AI for PIC Wish List
- ↳ PIC32 AI Compilers
- ↳ mikroC AI for PIC32
- ↳ mikroC AI for PIC32 General
- ↳ mikroC AI for PIC32 Beta Testing
- ↳ mikroC AI for PIC32 Wish List
- ↳ dsPIC AI Compilers
- ↳ mikroC AI for dsPIC
- ↳ mikroC AI for dsPIC General
- ↳ mikroC AI for dsPIC Beta Testing
- ↳ mikroC AI for dsPIC Wish List
- ↳ AVR AI Compilers
- ↳ mikroC AI for AVR
- ↳ mikroC AI for AVR General
- ↳ mikroC AI for AVR Beta Testing
- ↳ mikroC AI for AVR Wish List
- ↳ Additional Software
- ↳ Visual TFT AI
- ↳ Visual TFT AI General
- ↳ Visual TFT AI Beta Testing
- ↳ Visual TFT AI Wish List
- PRO Compilers
- ↳ PIC PRO Compilers
- ↳ PIC Compilers General
- ↳ mikroC PRO for PIC
- ↳ mikroC PRO for PIC General
- ↳ mikroC PRO for PIC Beta Testing
- ↳ mikroC PRO for PIC Wish List
- ↳ mikroBasic PRO compiler for PIC
- ↳ mikroBasic PRO for PIC General
- ↳ mikroBasic PRO for PIC Beta Testing
- ↳ mikroBasic PRO for PIC Wish List
- ↳ mikroPascal PRO for PIC
- ↳ mikroPascal PRO for PIC General
- ↳ mikroPascal PRO for PIC Beta Testing
- ↳ mikroPascal PRO for PIC Wish List
- ↳ dsPIC PRO Compilers
- ↳ dsPIC Compilers General
- ↳ mikroC PRO for dsPIC30/33 and PIC24
- ↳ mikroC PRO for dsPIC30/33 and PIC24 General
- ↳ mikroC PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroC PRO for dsPIC30/33 and PIC24 Wish List
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 General
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 Wish List
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 General
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 Wish List
- ↳ PIC32 PRO Compilers
- ↳ PIC32 Compilers General
- ↳ mikroC PRO for PIC32
- ↳ mikroC PRO for PIC32 General
- ↳ mikroC PRO for PIC32 Beta Testing
- ↳ mikroC PRO for PIC32 Wish List
- ↳ mikroBasic PRO for PIC32
- ↳ mikroBasic PRO for PIC32 General
- ↳ mikroBasic PRO for PIC32 Beta Testing
- ↳ mikroBasic PRO for PIC32 Wish List
- ↳ mikroPascal PRO for PIC32
- ↳ mikroPascal PRO for PIC32 General
- ↳ mikroPascal PRO for PIC32 Beta Testing
- ↳ mikroPascal PRO for PIC32 Wish List
- ↳ AVR PRO Compilers
- ↳ AVR Compilers General
- ↳ mikroC PRO for AVR
- ↳ mikroC PRO for AVR General
- ↳ mikroC PRO for AVR Beta Testing
- ↳ mikroC PRO for AVR Wish List
- ↳ mikroBasic PRO compiler for AVR
- ↳ mikroBasic PRO for AVR General
- ↳ mikroBasic PRO for AVR Beta Testing
- ↳ mikroBasic PRO for AVR Wish List
- ↳ mikroPascal PRO for AVR
- ↳ mikroPascal PRO for AVR General
- ↳ mikroPascal PRO for AVR Beta Testing
- ↳ mikroPascal PRO for AVR Wish List
- ↳ FT90x PRO Compilers
- ↳ FT90x Compilers General
- ↳ mikroC PRO for FT90x
- ↳ mikroC PRO for FT90x General
- ↳ mikroC PRO for FT90x Beta Testing
- ↳ mikroC PRO for FT90x Wish List
- ↳ mikroBasic PRO compiler for FT90x
- ↳ mikroBasic PRO for FT90x General
- ↳ mikroBasic PRO for FT90x Beta Testing
- ↳ mikroBasic PRO for FT90x Wish List
- ↳ mikroPascal PRO for FT90x
- ↳ mikroPascal PRO for FT90x General
- ↳ mikroPascal PRO for FT90x Beta Testing
- ↳ mikroPascal PRO for FT90x Wish List
- ↳ 8051 PRO Compilers
- ↳ 8051 Compilers General
- ↳ mikroC PRO for 8051
- ↳ mikroC PRO for 8051 General
- ↳ mikroC PRO for 8051 Beta Testing
- ↳ mikroC PRO for 8051 Wish List
- ↳ mikroBasic PRO compiler for 8051
- ↳ mikroBasic PRO for 8051 General
- ↳ mikroBasic PRO for 8051 Beta Testing
- ↳ mikroBasic PRO for 8051 Wish List
- ↳ mikroPascal PRO for 8051
- ↳ mikroPascal PRO for 8051 General
- ↳ mikroPascal PRO for 8051 Beta Testing
- ↳ mikroPascal PRO for 8051 Wish List
- ↳ ARM PRO Compilers
- ↳ ARM Compilers General
- ↳ mikroC PRO for ARM
- ↳ mikroC PRO for ARM General
- ↳ mikroC PRO for ARM Beta Testing
- ↳ mikroC PRO for ARM Wish List
- ↳ mikroBasic PRO for ARM
- ↳ mikroBasic PRO for ARM General
- ↳ mikroBasic PRO for ARM Beta Testing
- ↳ mikroBasic PRO for ARM Wish List
- ↳ mikroPascal PRO for ARM
- ↳ mikroPascal PRO for ARM General
- ↳ mikroPascal PRO for ARM Beta Testing
- ↳ mikroPascal PRO for ARM Wish List
- ↳ Older versions of Compilers
- ↳ Older versions of mikroC Compilers
- ↳ mikroC for PIC
- ↳ mikroC General
- ↳ mikroC Beta Testing
- ↳ mikroC Wish List
- ↳ mikroC for dsPIC30/33 and PIC24
- ↳ mikroC for dsPIC30/33 and PIC24 General
- ↳ mikroC for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroC for dsPIC30/33 and PIC24 Wish List
- ↳ RSC-4x mikroC
- ↳ RSC-4x mikroC General
- ↳ RSC-4x mikroC Wish List
- ↳ mikroC Beta testing
- ↳ Older versions of mikroBasic Compilers
- ↳ mikroBasic compiler for PIC
- ↳ mikroBasic General
- ↳ mikroBasic Beta Testing
- ↳ mikroBasic Wish List
- ↳ mikroBasic compiler for dsPIC30/33 and PIC24
- ↳ mikroBasic for dsPIC30/33 and PIC24 General
- ↳ mikroBasic for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroBasic for dsPIC30/33 and PIC24 Wish List
- ↳ mikroBasic for dsPIC30/33 and PIC24 Bug List
- ↳ Obsolete Project: mikroBasic compiler for AVR
- ↳ mikroBasic for AVR General
- ↳ mikroBasic for AVR Wish List
- ↳ mikroBasic Beta testing
- ↳ Older versions of mikroPascal Compilers
- ↳ mikroPascal compiler for PIC
- ↳ mikroPascal FAQ
- ↳ mikroPascal General
- ↳ mikroPascal Beta Testing
- ↳ mikroPascal Wish List
- ↳ mikroPascal Bug List
- ↳ mikroPascal compiler for dsPIC30/33 and PIC24
- ↳ mikroPascal for dsPIC30/33 and PIC24 General
- ↳ mikroPascal for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroPascal for dsPIC30/33 and PIC24 Wish List
- ↳ mikroPascal for dsPIC30/33 and PIC24 Bug List
- ↳ Obsolete Project: mikroPascal compiler for AVR
- ↳ mikroPascal for AVR General
- ↳ mikroPascal for AVR Wish List
- ↳ mikroPascal Beta testing
- ↳ Library Development Discussion
- ↳ Code Requests
- Additional Software
- ↳ Visual TFT Software
- ↳ Visual TFT General
- ↳ Visual TFT Beta Testing
- ↳ Visual TFT Wish List
- ↳ Visual GLCD Software
- ↳ Visual GLCD General
- ↳ Visual GLCD Beta Testing
- ↳ Visual GLCD Wish List
- ↳ Package Manager Software
- ↳ Package Manager General
- ↳ Package Manager Beta Testing
- ↳ Package Manager Wishlist
- ↳ GLCD Font Creator Software
- ↳ SpeakUp Software
- ↳ Timer Calculator
- ↳ CAN Calculator
- ↳ mikroBootloader
- Hardware
- ↳ Development Boards
- ↳ CODEGRIP programmer and debugger
- ↳ Mikromedia
- ↳ mikroProg™ programmer and debugger
- ↳ Development Boards Wishlist
- ↳ Review
- ↳ Click Boards release
- ↳ Hexiwear
- Website & Forums
- ↳ Libstock Discussion
- ↳ Product Announcements
- ↳ Website & Forums General Discussion
- ↳ Website & Forums Wishlist
- ↳ User Projects