??? 05/03/09 11:45 Read: times |
#165020 - I am still confused...but here goes Responding to: ???'s previous message |
Hi,
I am still confused, what do you want to do...So I assume some things and try to explain you...here goes: The code that you posted is (I believe) is not in Keil. Because the amount of variables you have defined inside main, is very large. Assumption what you want to do: You are having some variables in Memory in a 2-dimension array. And you want to send it on the Serial port. What I don't understand : What device have you connected at the Serial Port pins of MCS51? And how are you going to analyze it whether you have sent out the data properly or not ? Answer: Keil stores the data (char, int, long, double, float, etc.) as a series of bytes. For storing a "char" it takes one byte. For storing "int" it takes 2 bytes. Identify the sequence lower byte first or the higher byte first..this is for your homework. For storing "long" it takes 4 bytes. Identify the sequence of bytes..this is for your homework. How to find the sequence: 1. Open a project in Keil. Define the required variables such as : void main (void) { union { unsigned long A; unsigned char B[4]; }INT; unsigned char i,j,k,l; INT.A=0x12345678; i=INT.B[0]; j=INT.B[1]; k=INT.B[2]; l=INT.B[3]; ... ... 2. compile the code. 3. Start the Debugger. 4. Single step and wait after executing "l=INT.B[3];". 5. Add "i,j,k,l" to the watch window. and see its contents. You will see and understand the order of bytes. Comment: I could have answered it straight away, but I want you to do it and enjoy it, as you learn. I will help you how to walk properly so that next time you do not fall. What I have done here can be done for all the types of data types. Now comes the answer to your question: Once you know the pattern of data storage, try to extract each byte and probably show it on the display; and try to modify it. If you can extract and show it on the display, you can send it out on the port as you wish. If you want to send it on the serial port, then you have to perform the formalities of initializing MCS51 for the serial port, such as Baud Rate, Number of bits, the Interrupt Service Routine for handling the Serial Interrupts,etc.... Now, if you could extract and display each byte on the display, then you can send them on the serial port...very easy...isn't it? If you want to read the data from the port into the array, then you should read the sequence of bytes from the serial port, and write them into the array, similar to how you extracted and displayed them. In What sequence you want to send/recieve on the port is called the protocol. I will explain that later....but first tell me whether you digested the above information. From KiranVSutar, Mumbai, INDIA. |