i need help. i get this source code
#include <at89x51.h> #include <delay.h> #define usi P3_2 // ultrasonic in #define uso P3_3 // ultrasonic out
unsigned char i; bit x;
at 0x90 sbit md1; // left at 0x91 sbit me1; // at 0x92 sbit md2; // right at 0x93 sbit me2; //
void cek_jarak() { TH0 = 0x00; TL0 = 0x00; TF0 = 0; TF1 = 0; usi = 1; TR1 = 1; while(!TF1); TR1 = 0; usi = 0; while(!uso); TR0 = 1; while(uso); TR0 = 0; }
void perjalanan(bit a, bit b, bit c, bit d) {me1= a; me2= b; md1= c; md2= d;}
void main() { TMOD = 0x21 ; TCON = 0x00 ; TH1 = 100; while(1) { cek_jarak(); if(TH0 > 0x00) perjalanan(0,0,1,1);// forward else { perjalanan(0,0,0,0);// backward for(i=0; i<100; i++)delay(6000); perjalanan(0,0,x,~x);// turn right/left for(i=0; i<100; i++)delay(6000); } x = ~x; } }
but i cannot compile it. can anybody help?
1) What compiler was the source written for? C Compiler it called microC for 8051
2) What compiler do you have access to? i dont understand the question.
3) What compiler errors do you get? first the library was missing and then i tried to googling the library and i got it but then i came to another error message:
32 399 ; expected, but '__at' found at89x51.h 32 399 ; expected, but '0x80' found at89x51.h 32 368 Specifier needed at89x51.h 32 393 Invalid declarator expected'(' or identifier at89x51.h
and keep looping.. the difference is only 0x80 turn to 0x81 and so on..
4) What linker errors do you get? i don't know what is linker errors
5) Have you looked in the manual what the errors mean? there's no manual for the errors, thats why i tried to goggling, but zero result
6) Have you tried to solve the errors? yes, i tried to modify the library, but it getting worst
7) Have you googled for the errors? sure, zero result, that's why i tried to ask the expert and hope somebody will help me.
i just try to learn about this. i'm so sorry because i know nothing about this stuff. thank you so much for the help.
The manual for the compiler you are using - Keil I pressume - does describe how you declare bit variables. That should help you to modify the code until it gets accepted by your compiler.
What do you call a library? A precompiled image linked with your application? In that case, it only works if you are using the same compiler as the library was built with.
Or do you talk about a source code package that you compile and link with your project? In that case, the source code will probably also contain declarations that needs to be modified to be compatible with the compiler you are using.
i'm so sorry.. it's not library that i mean.. it's the headers.. so sorry.. i'm new in this stuff, that's why i tried to learn.. i'm indonesian and in my area there's nobody studied about microcontroller and their stuff.. so i can't ask for advice anywhere here.. hope you don't mind sharing some of your knowledge..
Q: 1) What compiler was the source written for? A: C Compiler it called microC for 8051
That's not Keil's compiler, is it? Note that this forum is specifically for questions about Keil's products!
Q: 1) What compiler was the source written for? A: i dont understand the question.
In other words, what compiler are you actually using?
If the code was written for one compiler, but you're using a different compiler - then you must expect that changes will be necessary due to the differences between the two compilers!
The operation of adapting code from one compiler to another is callled "porting" - and it is not a novice task!
Q: 5) Have you looked in the manual what the errors mean? A: there's no manual for the errors, thats why i tried to goggling, but zero result
In that case, the compiler is rubbish and you should throw it away now! Good documentation is absolutely essential to a usable compiler!
Keil document the C51 error messages here: http://www.keil.com/support/man/docs/c51/c51_errors.htm
i just try to learn about this.
Actually, the trouble is that you are trying to jump straight in without first having taken the time to learn the basics.
Here are some reading suggestions: http://www.keil.com/books/
ah, you got that right.. i'm downloading this keil's compiler now.. it's a demo right? i'll read those books first then.. thanks.. hope you don't mind to help again one day..