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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/05/09 11:54
Read: times


 
#165065 - Some more clarification..try this
Responding to: ???'s previous message
Rita Singh said:
....your program code helps me a lot to understd the array input at ports..but my problem is ..i cn't be able to convert the line below as a input at ports..as it is a two dimensional array..

double Input[NUMPAT+1][NUMIN+1] = { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1,0, 1, 1 };
double Target[NUMPAT+1][NUMOUT+1] = { 0, 0, 0, 0, 0, 1, 0, 1, 0, 0 };


I am assuming that you want to send this data (Input) on Port P1.
Use the following code:

#include <AT89X52.h>

#define	NUMPAT	8
#define	NUMIN		2
//double Input[NUMPAT+1][NUMIN+1] = { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1,0, 1, 1 };
double Input[NUMPAT+1][NUMIN+1] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,13, 14, 15 };

void main (void)
{
unsigned char i,j;

for (i=0; i<NUMPAT+1; i++)
	{
	for (j=0; j<NUMIN+1; j++)
		P1= Input[i][j];
	}
}

 


Compile the above code, Start the debugger, Monitor Peripherals->I/O Ports->P1, and start single stepping by pressing "F-10", and observe the signals on P1. You will see numbers 1,2...15.


Rita Singh said:

2.) sir as you told me that i have decleared a lots of variables in the main function...i dn't kw what effect they would have on my keil code..bt the code i had posted earlier is compiling succesfully without showing any error on keil..

If it compiles without Errors, then it is good, you don't have to worry.
My concern was: MCS51 has just 256 bytes of RAM. Out of which 128 will go for stack (by default). Rest is used for varaibles. So if you define a large number of variables, this 128 bytes of memory will be very short.
For Arrays, you have to be very careful, because, it might NOT give you errors during compiling, but might not work on the hardware. It depends upon the number of nested function calls, (which directly effects the stack size,) and hence might cause your product firmware to crash.

Bye from, Kiran V Sutar, 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