8051 based project That can save up to 60 codes with max of 6 combination of numbers
And what do you mean by the note above, especially the second sentence?
Sir ExperimenterUK, I just wanna ask that, does atmel's 8051 can handle 35 codes (referring to what my example)?
yes can handle 35 codes store code in rom then it can handle
Note:
stockLevels are only bytes, and atol() returns a "long" value.
The compiler may need to be told to convert a "long" to a "uchar".
he said that may be compiler give u error when u use atoi () function
because it returns long data type
[ Edited Tue Dec 14 2010, 09:46 am ]
do concentrate on ur work and dnt worry about these hurdles it will come with respect to time ans will solved here
dnt worry
Sir ExperimenterUK, I just wanna ask that, does atmel's 8051 can handle 35 codes (referring to what my example)?
And what do you mean by the note above, especially the second sentence?onyot.josephian
Which 8051 device are you using ?
The original has limited rom and ram so may not be good enough for your task.
As majoka said atoi() and atol() return values larger that the 8 bit value I used to store the stock level.
We know this and are happy to just keep the 8 bit value,
but the compiler will usually warn of a problem.
To avoid the warning we tell the compiler what we want to do by using a "cast".
uchar result; result = atoi(keyBuffer); //compiler not happy result =(uchar) atoi(keyBuffer); //compiler happy
Obviously if your stock level is over 255 you need to use integers for storage.
//Create an array of stock codes in ROM/program memory.. 5 in this example. //and an array of storage bytes in Ram. long stockCodes[]={707021,345678,232345,334455,998877}; uchar stockLevels[]={0,0,0,0,0};
Micros treat rom/program storage differently to ram storage.
The compiler has to be told what is is is rom somehow.
I don't know yours well enough to give examples, so check it out for yourself
or your program will compile but not work.
I am using at89c2051...
Do you have any suggestion what microcontroller should I use?
Does the program above, should be in void main () or not?
What about if I use AT89S52? is it okay?
And what do you mean by the char index=0?
should I make index=1 in the next line?
does uchar stockLevels[]=(0,0,0); mean that every 0 will represent the numbers in long stockCodes, am I right?
[ Edited Thu Dec 16 2010, 08:45 am ]
does uchar stockLevels[]=(0,0,0); mean that every 0 will represent the numbers in long stockCodes, am I right?
yes, you store in the array every stockcodes you want..
in accessing the array, remember that you must always start to zero location of the array
[ Edited Thu Dec 16 2010, 09:46 am ]
it has 4k flash and 128 byte ram with 2 ports
Sir ExperimenterUK
I am using at89c2051...
Do you have any suggestion what microcontroller should I use?onyot.josephian
Anything but an 89c2051
An AT89S52 looks like a good choice, lots of ram and program space.
And what do you mean by the char index=0?
should I make index=1 in the next line?onyot.josephian
This is simply creating a variable called index with a starting value of 0.
You increment index as you compare the user input with stockCodes in a loop.
does uchar stockLevels[]=(0,0,0); mean that every 0 will represent the numbers in long stockCodesonyot.josephian
There is one "stockLevels" for each "stockCodes",initially 0.