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.
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.
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!
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
Erik
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