Question about variable definitions

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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.

Re: Question about variable definitions
Quoted text here. Click to load it

I hope that you'll find this link useful
http://hercules.kar.elf.stuba.sk/predmety/mmp/pdf/an101.pdf
Peter



Re: Question about variable definitions
Hi, Julia.

Quoted text here. Click to load it

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.

Quoted text here. Click to load it

Of course you can use unsigned char.

Quoted text here. Click to load it

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




Site Timeline