Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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.





List of 36 messages in thread
TopicAuthorDate
help is need            01/01/70 00:00      
   What do you want to solve?            01/01/70 00:00      
   What do you want to do is not clear            01/01/70 00:00      
      clarification of requirements            01/01/70 00:00      
         I am still confused...but here goes            01/01/70 00:00      
            printf writes data on serial port            01/01/70 00:00      
               Not necessarily            01/01/70 00:00      
            reply again.            01/01/70 00:00      
               Some more clarification..try this            01/01/70 00:00      
                  To kiran            01/01/70 00:00      
                     How did you do it?            01/01/70 00:00      
                        explanation            01/01/70 00:00      
                           How to post legible source code            01/01/70 00:00      
                           Please post your actual code.            01/01/70 00:00      
                              abt actual code            01/01/70 00:00      
                                 TC?            01/01/70 00:00      
                                    to andy..            01/01/70 00:00      
                                       Confusing!            01/01/70 00:00      
                                          not to miss            01/01/70 00:00      
                                             Oh no he didn't!            01/01/70 00:00      
                                 I think there is a confusion...            01/01/70 00:00      
                                    reply..            01/01/70 00:00      
                                       Got your point            01/01/70 00:00      
                                       a question and a comment            01/01/70 00:00      
                                          double = double precision float            01/01/70 00:00      
                                             not used it after seeing the effects, thus            01/01/70 00:00      
                                                Good incentive to look at fixed point            01/01/70 00:00      
                           Please explain            01/01/70 00:00      
               But Why Keil??            01/01/70 00:00      
         two dimensional input provided at the ports            01/01/70 00:00      
            simulate the data.            01/01/70 00:00      
               seems that not the real MCU            01/01/70 00:00      
                  to jacksonc ben            01/01/70 00:00      
                     The serial port don't need to know what you transfer            01/01/70 00:00      
   this is obviously not for an embedded app.            01/01/70 00:00      
      Clearly            01/01/70 00:00      

Back to Subject List