can any one give me the meaning of following line
#define COUNT 2000 #define KEY2 0x2F #define KEY1 0xF8
COUNT,KEY2,KEY1 are the name's given which we going to use next in the prog. but what is 2000,0x2F,0xF8 is address i.e memory location or simply just value.
"can any one give me the meaning of following line"
Other than the author or provider of the software, no.
"or simply just value."
As far as the snippet you've provided goes, they are just values. How they might subsequently be used (or abused) elsewhere is completely impossible to tell!
Today's lesson is: always fully comment all definitions!
The comments should answer your questions!
i have some sample prog. in that some are act like address while some are limit's value(higher and lower limit value) some number's are used twise or thrise that are definatly not addresses. they are also not a value. so what is that
or it's meaning is totally un explanable because it know's only by auther
#define COUNT 2000 it mean's when ever the COUNT appears replace it with 2000
Correct!
#define val 0x0f it mean's when ever the val appears goto the memory location 0x0f and pop-up the value
No!! It has exactly the same meaning as in the first example!
It means purely and simply that wherever val appears it will be replaced with 0x0f
eg,
#define val 0x0f int fred; int array[16]; fred = val; // assigns the value 15 to fred array[val] = 3; // assigns the value 3 to array[15] if( fred > val ) // Tests if the value of fred is greater than 15
Remember, 0x0F (hex) is 15 (decimal)
"its meaning is totally un explanable because it known only by author"
Absolutely - if the author is thoughtless enough to not provide any documentation (whether in the form of comments ot otherwise).
As you say this is "sample" code, you need to ask yourself whether your time is going to be better spent trying to understand the "sample", or if you'd be better off just writing it yourself from scratch!
do not waste time "asking yourself", you WILL "be better off just writing it yourself from scratch"
The only value of "sample" code I know of comes after you have written the code for what you want to do yourself. At such time you understand what it is all about and, at that time, sometimes - not always a look at "sample" code can give a hint to where the error in what you wrote is.
Erik
i have put one more question in forum can u answer that sinciarly i.e. truly
can u answer that sinciarly who would know if micro can asnwer but himself?
I think your time would be better spent in studying your 'C' textbook rather than worrying about Keil's internal policies!
http://www.keil.com/forum/docs/thread8516.asp
sorry but there is some thing that u don't know and on that thing u r working
y r u 2 la-z 2 rite "you" etc?
just in case, as so often it is, the poster can not understand "back at you" here it is spelled out
If you are too lazy to write you, why should we not be too lazy to answer?
"As you say this is "sample" code, you need to ask yourself whether your time is going to be better spent trying to understand the "sample", or if you'd be better off just writing it yourself from scratch!"
Then what will the other person do, sit jobless?
"Better off just writing it yourself from scratch!" Then i wonder what is there for the other person to do, to sit jobless?
"Then what will the other person do, sit jobless?"
What other person?
If you mean the one who provided the "sample", then they ought to be fired for writing such rubbish, and setting such a bad example!
"If you mean the one who provided the "sample", then they ought to be fired for writing such rubbish, and setting such a bad example!" Thats right, So, i'l fire the "sample program" for giving all the trouble ... why i never thought about it earlier...
Then i wonder what is there for the other person to do, to sit jobless ?
writing "sample code" and publishing it on the net so anyone can use it fro free is hardly a "job"
If, however YOU are "the other person" and will "sit jobless" unless there is code to copy beacuse you are incapable of writing it yourself --- tough luck,
You are the one person who's got an answer for every question on this forum
Not bad,
Trying to write working code on our part is not harmful, right,
And Trying with no result to show, equal to "sitting jobless" ?
Trying to write working code on our part Then show the code ans state the exact problem>
Trying to write working code on our part ... with no result to show,
How can you write something and have nothing to show?
"How can you write something and have nothing to show?"
Errr.... use invisible ink?! ;-)
" use invisible ink?! " ink, on PC or 8051 ...
i mean, output for the program,
i've been trying to write to an address location in serial flash and read it back, This program works for some addresses, not all, could you help me with what the problem is,
#include<reg51.h> #include<stdio.h> sbit si = P1^1; // bits of flash controlled thru Port1 pins of 8051 // SI= Serial IN sbit SCK = P1^3; // S clock sbit SO = P1^5; // Serial Out sbit ce = P1^0; // Chip Enable unsigned char Get_Byte(); void Send_Byte(unsigned char b_out); void E_WRSR(); // unsigned char Read_Status_Register(); void WREN(); void Byte_Program(); void Delay(); unsigned char Read_Func(); // unsigned char Read_ID(); unsigned char i, SR_byte, r_byte; void main(void){ ce = 1; SCK = 0; TMOD = 0x20; // timer 1,mod 2 TH1 = -3; // 9600 baud SCON = 0x50; TR1 = 1; TI = 1; Delay(); Byte_Program(); // Writes to flash ce = 0; Read_Func(); // reads from flash } unsigned char Get_Byte(){ // sending 8 bitword thru Single pin serially, unsigned char i=0, in=0, temp=0; for(i=0;i<8;i++){ in = (in << 1); temp = SO; SCK = 1; if (temp == 1){ in = in | 0x01; } SCK = 0; } return in; } void Send_Byte(unsigned char b_out){ for(i=0;i<8;i++){ if((b_out & 0x80) == 0x80) si = 1; else si = 0; SCK = 1; b_out = (b_out << 1); SCK = 0; } } void E_WRSR(){ ce = 0; Send_Byte(0x50); // enable Status Reg ce = 1; Delay(); ce = 0; Send_Byte(0x01); // select write to status register Send_Byte(0x00); // (BPL = 0, mode 00, None of memory protected) ce = 1; } void WREN(){ // Write Enable operation in stauts reg. ce = 0; Send_Byte(0x06); ce = 1; } unsigned char Read_Func(){ ce = 0; Send_Byte(0x03); // Read CMD Send_Byte(0x00); // Sending address bytes Send_Byte(0x21); Send_Byte(0x94); r_byte = Get_Byte(); SBUF = r_byte; P1 = r_byte; while(TI){ } TI = 0; ce = 1; return r_byte; } void Byte_Program(){ E_WRSR(); WREN(); ce = 0; Send_Byte(0x02); // Byte Program CMD Send_Byte(0x00); // sending 3 address bytes Send_Byte(0x21); Send_Byte(0x94); Send_Byte(0x05); // sending ONE databyte which is to be programmed Delay(); ce = 1; } void Delay(){ // gives approx 20 usecond delay for(i=0;i<2;i++){ } }
Thanks a ton,
It works!
Actually, it works for an address, when we write to the same location again, or write to the next location, the program does not work, Is there something more to be added,
When i write Auto address increment on the same lines, it does not write,
Would you please say wat could be the mistake,
in serial flash
1) I have no idea how this ended up in a thread about "#define COUNT 2000" why did you hijack thais thread instead of starting a new?
2) there is no such thing as general "serial flash", if you do not specify the chip (e.g. AT1234 serial flash) (and give a link to the datasheet) nobody can help you
Sorry, i didnt mean to hijack any thread,
shd have started a new one, ok
rgds, HannaH.
Sorry, for the long delay in replying, was into reviewing basics in C as Mr. Andy said, it took some delay to convey the same within a short time, Guess i am taking more time in a bid to being polite,
Hope its not being misunderstood,
Here are the details of the chip, Serial Flash SST25VF512 Datasheet at : www.sst.com/.../S71192.pdf
"I didnt mean to hijack any thread"
But you did!
"shd have started a new one"
No! Not another one!
You already have three threads running on exactly the same topic!
http://www.keil.com/forum/docs/thread8478.asp http://www.keil.com/forum/docs/thread8507.asp http://www.keil.com/forum/docs/thread8346.asp
What do you exactly mean by "hijacking" a thread? "HI-JACK" a THREAD, Pleeease,
All along have been working on the same project, so much for your research on the threads,
Did you happen to see that they were on different topics all related to the same thing?
For instance, http://www.keil.com/forum/docs/thread8507.asp was about 'Accessing absolute memory locations'
http://www.keil.com/forum/docs/thread8478.asp was as you see, what was wrong with the program, i was not getting the output, you guessed or suggested there could be a mismatch in speed of PC and chip,
Eric said rightly, "why did you hijack THIS thread instead of starting a new?"
While searching for answers from others i had totally overlooked the fact that it was started by somebody else,
Eric said rightly, "why did you hijack THIS thread instead of starting a new?" Agree with him, While searching for answers from other threads i had totally overlooked the fact that it was started by somebody else, so wrote in my program in Mr. Danish's thread on an impulse,
are you moderating for KEIL FORUM?
What do you exactly mean by "hijacking" a thread?
what does "i've been trying to write to an address location in serial flash and read it back," have to do with #define COUNT 2000
View all questions in Keil forum