We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
code is:
#include <AT89X52.H> #include "system.h" #include "displej.h"
const uchar brojevi[] = {63, 6, 91, 79, 102, 109, 125, 39, 127, 111}; ispisuje odredjeni broj
extern uchar vreme[6];
void prikazi_vreme(char ofset) { uchar vert=P1; uchar broj; char pom=0;
P2=0x00; if(vert&0x01) pom=1; vert<<=1; vert=vert|0x02; if(!(vert&0x80)) vert=0xfc; vert&=0xfe; switch(vert) { case 0xfc: broj=vreme[ofset]/10; broj=brojevi[broj]; break; case 0xfa: broj=vreme[ofset]%10; broj=brojevi[broj]; break; case 0xf6: broj=vreme[ofset+1]/10; broj=brojevi[broj]; break; case 0xee: broj=vreme[ofset]%10; broj=brojevi[broj]; break; case 0xde: broj=vreme[ofset+2]/10; broj=brojevi[broj]; break; case 0xbe: broj=vreme[ofset]%10; broj=brojevi[broj]; break; default: break; } if(pom) vert|=0x01; P1=vert; P2=broj; }
void displej_handler(char v_d) { switch(v_d) { case 0: prikaz_vremena(0); break; case 1: prikaz_vremena(3); default:; } }
error while compiling:
compiling Display.c... DISPLAY.C(5): error C244: 'brojevi': can't initialize, bad type or class DISPLAY.C(5): error C132: 'brojevi': not in formal parameter list DISPLAY.C(7): error C127: 'vreme': invalid storage class DISPLAY.C(10): error C132: '_prikazi_vreme': not in formal parameter list DISPLAY.C(10): error C141: syntax error near '{' DISPLAY.C(11): error C136: 'vert': 'void' on variable DISPLAY.C(11): error C244: 'vert': can't initialize, bad type or class DISPLAY.C(11): error C136: 'vert': 'void' on variable DISPLAY.C(11): error C132: 'vert': not in formal parameter list DISPLAY.C(12): error C132: 'broj': not in formal parameter list DISPLAY.C(13): error C244: 'pom': can't initialize, bad type or class DISPLAY.C(13): error C132: 'pom': not in formal parameter list DISPLAY.C(15): error C244: 'P2': can't initialize, bad type or class DISPLAY.C(15): error C132: 'P2': not in formal parameter list DISPLAY.C(16): error C141: syntax error near 'if' DISPLAY.C(16): error C141: syntax error near '&', expected ')' DISPLAY.C(17): error C129: missing ';' before '<<='
question is: "What is wrong here?" Why compiler thinks that "brojevi" is function? If anyone know the answer please help! Thanks.
A couple of things are immediately obvious:
You haven't given your post a meaningful title;
You didn't follow the clearly-stated instructions on how to post source code:
www.danlhenry.com/.../keil_code.png
Note that all C51 are described in the manual; eg,
http://www.keil.com/support/man/docs/c51/c51_c244.htm
What type of variable is this?
uchar
If this is a type of you have defined (I suggest something like uint8_t or UINT8 instead but that's my preference), you probably should include the header file it's defined in with the file.
ditto also this does not allocate storage for vreme extern indicates to the compiler that in some other module vreme was defined. It's much better to include a header for that module in the module you are using it in, that does the above definition than to do so within the code module itself. Unless of course you intended vreme to be local to this module and then you do not need the extern at all.
Also Keil forum's, clearly has in every message you are about to post a thing titled Summary: and beneath that it has a NOTE: which has a little list of each tag they suggest you use for various things. It just takes a bit longer to enter your message, but it makes it much easier for people to read.
The Preview button is very handy to use with these tags.
"...uKeil can't recognize some of basic "c" operators like "<<=" or "&"."
That's news to me.
Did you read the description of error C244?
What did it tell you?
#define uchar unsigned char
Why are you using #define rather than typedef?
"I think that code is great but uKeil can't recognize some of basic 'c' operators like '<<=' or '&'"
No, C51 understands them perfectly!
"There must be some file problem."
Indeed - but it is impossible for anyone else to say what it might be without seeing your files!
Always some zero problems.I thought that problem is with ANSI hehe
But edification is,when problem is in 1. variable of code look in h file. (Hehe I know that and before... :) what a day...