9
ROBO INDIA presents Basics of Embedded ‘C’ Language Email : [email protected] Web : www.roboindia.com

Basics of Embedded C Languagae

Embed Size (px)

DESCRIPTION

Robo India presents the fundamentals of Embedded 'C' Language.Embedded C is very useful to make autonomous robots, embedded system projects, electronics projects, physical computing projects.If you have any query please share your query and views with us. we are found atwebsite: http://roboindia.commail: [email protected]

Citation preview

Slide 1

ROBO INDIApresentsBasics of Embedded C LanguageEmail : [email protected] : www.roboindia.comPhase 1 | Fundamentals of Embedded Cwww.roboindia.comBenefits of C language: Easier and less time consuming Easier to modify and update. Codes available in function libraries. Portable

Phase 1 | Fundamentals of Embedded Cwww.roboindia.com Variables unsigned int x;x = 10;

Data TypeSize in BitsData Range/ UsageUnsigned char8 - bit0 to 255Signed char8 - bit-128 to +127Unsigned int16 - bit0 to 65535Signed int16 - bit-32768 to 32767sbit1 - bitSFR bit addressable onlybit1 - bitRAM bit addressable onlysfr8 - bitRAM addresses 80- FFH onlyPhase 1 | Fundamentals of Embedded Cwww.roboindia.com Constant a=20;

#define delay_time 184

Bit Addressable I/O Programming

sbit mybit = P1^5;

Phase 1 | Fundamentals of Embedded Cwww.roboindia.com HEX Numbers in C

P1 = 0x10; (10 in HEX is 16 in decimal)

P2 = 0xFF; (Set all bits of port 2 to 11111111 or decimal 255)

Phase 1 | Fundamentals of Embedded Cwww.roboindia.com Bit-Wise Operations in 8051-C AND OREX-ORInverterA BA&BA|BA^BX=~B000001010110100111111100Phase 1 | Fundamentals of Embedded Cwww.roboindia.com Bit-Wise Logic Operators in C

P0 = 0x35 & 0x0F; // ANDing, now P0=0x05 P1 = 0x04 | 0x68; // ORing, now P1=0x6C

Bit-Wise Shift Operators in C1. shift right (>>)2. shift left ( 3; // shifting right 3 times, now P1=0x13 P2 = 0x77