Question about variable definitions

Hi

I'm a VC++ programmer doing my first bit of embedded development in C for a 80C52 compatible chip. I have the use of some API's and included is an .h file containing the following typedefs:

typedef unsigned char data Ucd; typedef unsigned char idata Uci; typedef unsigned char pdata Ucp; typedef unsigned char xdata Ucx; typedef unsigned char code Ucr; typedef unsigned char Uc;

Code samples available to me use Ucr as a parameter type for a function if the data being passed is a "string" rather than a variable. I understand vaguely that different data may be stored in different memory spaces, but I guess I need to know the following:

1) Is there a good book, document, web-site, or what ever that will help me understand the basic concept of why these typedefs are needed and 2) Do I need to use these typedefs or can I simply use unsigned char? 3) If there is a choice as to whether or not these typedefs are required, what are the advantages/disadvantages, etc. of using them

Many thanks in advance for any help with this. Julia.

Reply to
Julia
Loading thread data ...

I hope that you'll find this link useful

formatting link
Peter

Reply to
moocowmoo

Hi, Julia.

I'd suggest you download .pdf datasheet of part you are using (ie. Atmel

80c52), from manufacturer's site and learn about memory organisation in microcontrollers.

Of course you can use unsigned char.

The only advantage of typedefs is you don't have to write "unsigned char data" which is 18 characters instead you write "Ucd" and that is 3 characters. When you have functions with a lot of arguments it becomes pretty large with unsigned char data ....

Reply to
MArk

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.