This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Thursday, 14 March 2013

What Is Watchdog?

when micro controller hang up or gets crashed.To overcome these situation is to automatically reset the system.

Whenever Such a Situation Arises:-

The watchdog is a hardware or software generated timer interrupt which resets the system in the situation when system huge up . The watchdog timers are also used in case when you intentionally required the system without any physical interference.Watchdog is a special timer which can be enabled in any section of the code and when enable it ensurers that a certain number of instructions execute within a per-defined time frame.


Watch Dog Timer Control Register are:-

WDTOE( watch dog turn-off enable).

The watchdog timer is disabled by configuring WDTOE and WDE bits.

WDE(watch dog enable) -watchdog timer is enabled by writing 1 to WDE bit.

WDP(watch  dog prescal ) bits.

These three bits determine the watchdog time out condition.

Watchdog Timer Works:-

The watchdog timer starts when the WDE bit is enable and pres-cal bits are configured for time-out conditions.As watchdog timer reaches time-out condition, watchdog timer is reset and generate a pulse of one clock.Cycle with reset the program counter. when Watchdog timer resets the timer , the WDRF (watch dog reset Flag) bit in micro-controller register is set by the hardware to disable the watchdog timer.

1. Set the WDE and WDTOE bits in same clock cycle WDTCR register. The logic one must be written to WDE bit even though it is set to one already.

2. After four clock pulses. write logic 0 to the WDE bit. otherwise watchdog timer will not be Disable.

Wednesday, 13 March 2013

What Is Near Pointer?

The Pointer which can point only 64KB data segment or segment number 8 is known as near Pointer. That is near pointer cannot access beyond the data segment like graphics video memory, text video memory, etc. Size of near pointer is two bytes. With help keyword near, we can make any pointer as near Pointer.

Examples:


   #include<stdio.h>

          int main()
{

         int x=25;

         int near* ptr;

          ptr=&x;

         printf(“%d”,sizeof ptr);

         return 0;
}



Output: 2

(2)



#include<stdio.h>

int main()
{

  int near* near * ptr;

  printf(“%d”,sizeof(ptr),sizeof(*ptr));

  return 0;

}




 Output: 2 2


Explanation: Size of any type of near pointer is two bytes. Near pointer only hold 16 bit offset address. Offset address varies from 0000 to FFFF (in hexadecimal). In printf statement to print the offset address in hexadecimal, %p is used.
Example:


#include<stdio.h>

int main()
{

     int i=10;

     int *ptr=&i;

    printf("%p",ptr);

    return 0;

}




 Output: Offset address in the hexadecimal number format.

%p is also used to print any number in the hexadecimal number format.

Example:




#include<stdio.h>

int main()
{

   int a=12;

  printf("%p",a);

  return 0;

}




 Output: 000C

Explanation: Hexadecimal value of 12 is C.

Consider the following two c program and analyze its output:

(1)



#include<stdio.h>

int main()
{

     int near * ptr=( int *)0XFFFF;

     ptr++;

     ptr++;

    printf(“%p”,ptr);

   return 0;

}




Output: 0003


(2)



#include<stdio.h>

int main()
{

      int i;

      char near *ptr=(char *)0xFFFA;

      for(i=0;i<=10;i++){

      printf("%p \n",ptr);

      ptr++;

}

return 0;

}




Output:

FFFA   FFFB  FFFC  FFFD  FFFE   FFFF

0000    0001    0002    0003    0004


Explanation: When we  increment or decrement the offset address from maximum and minimum value respectively then it repeats the same value in cyclic order. This property is known as cyclic nature of offset address. Cyclic property of offset address. If you increment the near pointer variable, then moves clockwise direction If you decrement the near pointer, then moves anti clockwise direction


What is the default type of pointer in C?

Answer: It depends upon the memory model.

What Is Function Pointer


Function Pointer is a variable(a pointer) that holds the address  of another function. Function pointer is a pointer variable, just like a normal pointer. However, function pointer points to the address of the function. In C like all normal variables, functions also will be stored in the memory. So every function will have a valid address. Function pointer will point to this address.


Syntax:



DATA TYPE (*ptr) ();
DATA TYPE (*ptr) (Data Type);


When declaring a function pointer you must declaration the function's return type and the function's parameter type. Example supposes we had two functions.


Void read_emp (emp*e);
  and
Void print_emp(emp*e);


We can declare a variable that could pointer to either of these functions as follows:


void(*func_ptr) (emp*e);


(*func_ptr)  Is the name to the variable, void' is actual variable declaration void(*func-ptr) (emp*e); ,(*func-ptr)  is variable declaration, void * func-ptr(emp*e);


 Upper syntax it will return a void pointer


 (void * func-ptr(emp*e); is the function prototype)

Suppose  you to have third function;

Void print_integer (int x);

It would not be possible to assign func_ptr to pointer to print_integer as they are  different  function types   parameter is  different types.Using the example for the previous.

void(*func_ptr) (emp*e);,we could assign func_ptr to pointer to read_emp as follows,

 Func_ptr=read_emp,note that no  &  is required, note (extremely important) that,Func_ptrr=ead_emp is very different from,Func_ptr=read_emp();

(Func_ptr=read_emp; take  the function  pointer an address and assign to func_ptr variable)

(Func_ptr=read_emp(); is read_emp() run the program and return value is assigned  to func_ptr).Once func_ptr has been initialized.

Func_ptr=read_emp;


We can call the function read_emp via func_ptr, as follows.


  emp e;


 Func_ptr(&e);



  Example



 static int add(int a,int b)
               {
                           return a+b;
                }



 static int sub(int x,int y)
             {
                         return a-b;
             }



   main()
              
         {

                    int x,y;

                    int temp;

                    int result;

                    int(*func_ptr) (int,int);   // function pointer

                    printf("please enter the first number");

                   scanf("%d",&x);

                    printf("please enter the second number");

                   scanf("%d",&y);

                   printf("you want to Add or Subb y/n");

                  scanf("%c",temp);

                  if(temp=='y')||(get char()=='a')

                  func_ptr=int add; // pointing to function

                  else

                  func_ptr=int subb; // pointing to function

                 return=func_ptr(x,y);

                 printf("%d\n",result);

}


Example 2




int fun ptr()

{
            static int s=10;
              ++s;
             Returns;
}


void main()
{
       int r;

       int(*ptr) ();  // function pointer

       ptr=funptr;

      r=ptr();   //r=funptr();    //r=funptr()

      printf("\n valu=%d",r);

}

Wednesday, 27 February 2013

What Is Micro Substitution

The #define directive is the most common processor directive, which tell the Processor to replace every occurrence of a particular character string ( that is, a macro name ) with a specified value ( that is, macro body).

The syntax for the #define directive is:

 #define Macro_name macro_body


Here macro name is an identifier that can contain letters, numerals, or underscores. Macro_body may be a string  or a data item, which is used to substitute each macro_name found in the program. As mentioned earlier, the operation to replace occurrences of the macro_ name with the value specified by the macro_ body is known as macro substitution or macro expansion. The value in the macro body specified by a #define directive can be any.character string or number.

Example: #define NAME  "to more"

Here NAME will be replaced by "to more." .

Other examples:

#define MUX  (8*8)

On the other hand, we can use #undef directive to remove the definition of a macro name who has been previously defined.

Syntax:

 #undef macro_name

Here macro_name is an identifier that has been previously defined by a #define directive.The #undef directive "undefined" a macro name.For instance the following segment of code.



#define NAME "author"

printf(" I am of %s.\n ",NAME);
  
#undef NAME 

It defines the macro name NAME first, and uses the macro name for the print( function  then it removes the macro name.

Defining the macro with arguments:
You can specify one or more arguments to a macro name defined by the #define directive, so that the macro name can be treated like a simple function that accepts arguments.

 #define MUL(val1,val2) ((val1)*(val2))

When the following statement.

 A result= MUL(2,3)+10;

The  preprocessor substitute the expression 2 for val1 and 3 for val2  and the produces the following statement.

 result=((2)*(3))+10;

/*Program to understand macros with arguments*/




#include <studio.h>
#define SUM(x,y) ((x)+(y))
#define PROD(x,y) ((x)+(y))
main()
{

     int l,m,i,j,a=5,b=3;
     float p,q;
     l=SUM(4,6)
     m=PROD(a,b)
     i=SUM(4,6)
     j=PROD(4,6)
     p=SUM(2.2,3.4);
    q=PROD(2.2,3.4);
    printf("i=%d,m=%d,i=%d,j=%d,p=%0.1f,q=%0.1f\n",I,m,I,j,p,q); 

}


Output :



l=8,m=15,i=10,j=24,p=5.6,q=7.5

What Is C Processor?

If there is a constant appearing in several places in your program.it's a good idea to associate a symbolic name for the constant, and then use the symbolic name to replace the constant throughout the program. There are two advantages in doing so. First, the program will be more readable. Second, Easier to maintain.

program.  For instance, the value of the constant needs to be changed, Find the statement that associates the constant with the symbolic name and replaces the constant with the new one. Without using the symbolic name, you have to look everywhere in your program to replace the Constant.

C has a special program called to C processor who allows the programmer to define and associate symbolic names with constant. In fact, the C Processor uses the Terminology macro names and macro body to refer to the symbolic names and the constant. The C Coprocessor runs before the compiler. During Prepossessing, the operation to replace a macro name with its associated macro body is called macro substitution or macro expansion.

 In addition, the C Processor gives you the ability to include other source files. For instance, We've been using the preprocessor directive #include to include C header files. such as studio.h ,studio.h and string.h in the Programs  also, the C Preprocessor enables to compile different sections of the program under specified conditions.

                                                                  (OR)

 Preprocessor is a Programe which executed automatically before passing source program to the compiler Processioning is under control of Processor directives.



Preprocessor directives are classified into four types :

1. Micro Substitution Directives
    Example  #define.

2. File Inclution Directives
    Example  #include

3. Conditional Directives
     Example #if, #else, #else if, #end if, #ifdef, # ifindef, #undef

 4. Misslenious  Directives
     Example #error, #line, #progma



Friday, 22 February 2013

What Is C Plus Plus

C++ is an object oriental programing language (oop's)

OOPs are mainly the collection of eight principles. If any programing language supported all the oops principle except Inheritance and polymorphism known as oxide based programing language.

Example: 

java script, Vb-script, small talk, talk, etc.

If any programing language supported all the oops principle known as oxide oriental programing language.
Example: C++, Java, Net, php, etc.

C++ is not completely an oxide oriented programing language because C++ can  be developed   by using oops concept or without using the oops concept. So that it is known as Semi-structure programing language or partial oxide  oriental programing language  C++ is also known as the compiler based programing language.


Compiler is a special programing, which will convert high level language into the low-level language(or) source code into object code the process of convention is known as compilation .C++ is very rich in its predefined function, predefined class and predefined.

What Is Embedded System?

embedded
Embedded System is combination of software and hardware and Designed to Perform Specific task.

In general embedded system is not an exactly define term,as many systems have some element of Programmability. For example handheld
computers share some elements with embedded sytem-Such as the operating systems and microprocessors which power them-but are not truly embedded system because they allow different application to be loaded and peripherals to be connected.
An embedded system is a specific-purpose computer system designed to perform one or a few dedicated function, sometimes with real-time computing constraints.It is usually embedded as part of a complete device including hardware and mechanical parts.In contrast a general-purpose computer such as a personal computer can do  many tasks depending on programing Embedded system have become very important today as they control many of the common devices we use.


Since the Embedded system is dedicated to specific tasks,design engineers can optimize it ,reducing the size and cost of the product,or increasing the reliability and performance.Some embedded system are mass-produced,benefiting from economies of scale.

Physically,Embedded system range from portable devices such as digital watches and mp3 players ,to large stationary installations like traffic lights, factory controllers,or the system controlling nuclear power plants complexity varies from low,with a single networks mounted inside a large chassis or enclosure.

Certain operating system or language platforms are tailored for the Embedded market,such as Embedded Java and windows XP embedded. However some low-end consumer products use very.

Operating system both part of a single program,with the application and operating system both part of a single program. The program is written permanently into the system memory in this case ,rather than being loaded into RAM as programs on a personal computer.

Twitter Delicious Facebook Digg Stumbleupon Favorites More