Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help for Embedded C concepts

Status
Not open for further replies.

scorrpeio

Full Member level 5
Joined
Dec 26, 2006
Messages
286
Helped
10
Reputation
20
Reaction score
9
Trophy points
1,298
Activity points
3,496
embedded c concepts

Hi guys,
I am new to the embedded C environment. Please clear my following concepts with respect to the embedded C......

volatile & const variable......practically where & why we use it in embedded prog......:cry:
void pointer, bit field....practical use

where we use simultanous use of volatile & const to same variable?

Please give me the link to understand these concepts.

Thank you in advance:|:|
 

good c concepts

volatile is used for a variable that could be changed by an outside event, such as the state of an input port. Volatile instructs the compiler to always read the variable value before using it and not optimise it to a register and assume it hasnt changed.

const is used for a constant. It instructs the compiler that the value could be stored in program memory and not use valuable ram space as it will not change throughout the program.

Using both volatile and const on a variable doesnt make sense, you cant have a volatile constant!

bit field's are very useful in embedded systems.

void pointers and bit fields are described in any good book on the C programming language. There is no difference to the language just because the word embedded preceeds it.
 

embedded concepts in advance

btbass said:
bit field's are very useful in embedded systems.

void pointers and bit fields are described in any good book on the C programming language. There is no difference to the language just because the word embedded preceeds it.

Thank you for the valuable information! :|

Please provide me the link of book where I can clear concept of bit field.
 

embeded c concepts

Bitfields are used in structures and unions.
Bitfields are useful to use as flags. Here is a bitfield that takes a byte of memory but defines 4 flags and a 0 - f counter.

Code:
typedef struct
  {
  unsigned error_flag:1;
  unsigned overheating:1;
  unsigned about_to_blow:1;
  unsigned run_for_cover:1;
  unsigned counter:4;
  }BOILER;

volatile BOILER Boiler;

void main(void)
  {
   if(Boiler.overheating == True){
     Boiler.about_to_blow = True;
     Boiler.run_for_cover = True;
     }
  else{
    Boiler.about_to_blow = False;
    Boiler.run_for_cover = False;
    }

  Boiler.counter++;

  if(Boiler.counter == 15){
    Boiler.counter = 0;
    }
  }

The bible for the c programming language is

'The C Programming Language
Brian W. Kernighan, Dennis M. Ritchie'

These are the guys that wrote the language.
 

embedded c

emededd c has not that much difference with ordinay c language . u can find the answers of above questions in any of good c books
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top