Wednesday, 5 February 2014

Acessing EEPROM in PIC18f45k20 using Mickro C

EEPROM (also written E2PROM and pronounced "e-e-prom," "double-e prom," "e-squared," or simply "e-prom") stands for Electrically Erasable Programmable Read-Only Memory and is a type of non-volatile memory used in computers and other electronic devices to store small amounts of data that must be saved when power is removed, e.g., calibration tables or device configuration.
PIC microcontroller has inbuilt EEPROM, so here we have done the program to use inbuilt EEPROM of PIC, 

Saturday, 1 February 2014

Acessing EEPROM in PIC16f887 using Mickro C

             


EEPROM (also written E2PROM and pronounced "e-e-prom," "double-e prom," "e-squared," or simply "e-prom") stands for Electrically Erasable Programmable Read-Only Memory and is a type of non-volatile memory used in computers and other electronic devices to store small amounts of data that must be saved when power is removed, e.g., calibration tables or device configuration.

PIC microcontroller has inbuilt EEPROM, so here we have done the program to use inbuilt EEPROM of PIC, 


Friday, 31 January 2014

What is output of this program?




main()
{
float me =1.1;
double you=1.1;
if(me==you)
printf(“i love embedded c”);
else
printf(“i love embeddedgoogle”);
}
Ans
I love emeddedgoogle
Explanation:
For floating poit members (float, double, long double) the values  cannot predicted exactly, Depending on the number of bytes, the precession with of the represented varies,. Float takes bytes and long double takes 10 bytes, so float stores 0.9 with less than long double.
Rule of thumb;
Never compare or at-least be cautious when using floating point numbers with relational operators, (==,>,<,<=,>=,!+)

What is output of this program?
main()
{
int c[]={2,8,3,4,4,6,7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++)
{
printf(“%d”,*c);
++q;
}
for(j=0;j<5;j++)
          {
printf(“%d”,*p);
++p;
}

}

Ans
2 2 2 2 2 2 2 3 4 6 5
Explanation:
Initially pointer c Is assigned to both p and q. in the first loop, since only q is incremented and not c, the value 2 will ne printed 5 times, in second loop p itself is incremented . so the values 2 3 4 6 5 will be printed.

What is output of this program?


main()
{
char s[]=”man”;
int i;
for(i=0;s[i];i++)
printf(“\n%c%c%c%c,s[i],*(s+i),*(i+s),i[s]”);
}
Ans:
mmmm
aaaa
nnnn
Explanation:
S[i], ],*(s+i),*(i+s),i[s] are all different ways of expressing the same idea, Generally array name is the base address for that array. Here s is the base address. I is thee index number/displacement from the base address. So, indirecting it with * is same as s[i], i[s] may be surprising. But in the case of C, it is same as s[i].

Predict output or errrors in this program

void main()
{
 int const *p=5;
printf("%d",++(*P));
}


Ans,
Compiler error
Because see const keyword nearer to int, so can’t modify constant value,
See here Pointer is the constant pointer