LHO 22 C and the 8051.  The Silicon Labs ISE uses the Keil C51 compiler.  The code size is limiter to 2K  C has replaced PL/M (the original Intel high.

Slides:



Advertisements
Similar presentations
C Language Programming
Advertisements

Programming the C8051F020 Using C Language
INSTRUCTION SET ARCHITECTURES
1 C and the 8051 EGRE Introduction The Silicon Labs ISE uses the Keil C51 compiler. The code size is limiter to 2K C has replaced PL/M (the original.
Machine Instructions Operations 1 ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-1.ppt Modification date: March 18, 2015.
Chung-Ta King National Tsing Hua University
Chapter 2 HARDWARE SUMMARY
8051 Core Specification.
Intel Computer Architecture Presented By Jessica Graziano.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
Bitwise Operators Pointers Functions Structs Interrupts (in C)
By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.
Programming the HC12 in C. Some Key Differences – Note that in C, the starting location of the program is defined when you compile the program, not in.
AVR Programming CS-212 Dick Steflik. ATmega328P I/O for our labs To get data into and out of our Arduino its a little trickier than using printf and.
Chapter 11-12, Appendix D C Programs Higher Level languages Compilers C programming Converting C to Machine Code C Compiler for LC-3.
Bit Operations C is well suited to system programming because it contains operators that can manipulate data at the bit level –Example: The Internet requires.
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
C Programming for Embedded Systems. fig_06_00 Computer Layers Low-level hardware to high-level software (4GL: “domain-specific”, report-driven, e.g.)
An Embedded C Program 1 Mainly from textbook: Embedded C Programming and the Atmel AVR 2 nd Edition Barnett, Cox and O’Cull.
Embedded ‘C’.  It is a ‘mid-level’, with ‘high-level’ features (such as support for functions and modules), and ‘low-level’ features (such as good access.
Unit-1 PREPARED BY: PROF. HARISH I RATHOD COMPUTER ENGINEERING DEPARTMENT GUJARAT POWER ENGINEERING & RESEARCH INSTITUTE Advance Processor.
Lecture 9 Timer Operations and Programming. 2  Introduction  Summary of timers  Timer programming sequence  Summary of timer SFRs  Timer 0: 8-bit.
The 8051 Microcontroller architecture
2015/8/221 Data Types & Operators Lecture from (Chapter 3,4)
Development. Development Environment Editor Assembler or compiler Embedded emulator/debugger IAR Embedded Workbench Kickstart Code Composer Essentials.
System Clock, Crossbar and GPIO
An Introduction to 8086 Microprocessor.
Chapter 2 A Loop in the Pattern Designing the Main Loop and Timing.
Directives, Memory, and Stack. Directives Special commands to the assembler May or may not generate machine code Categories by their function Programming.
Bits and Bytes. BITWISE OPERATORS Recall boolean logical operators in Java… boolean logical operators: &, |, ^ not: ! Show truth tables.
1 LHO 13 The 8051CF020 and the University Daughter Card.
FREQUENCY COUNTER USING Silicon Labs C8051F020 microcontroller
1 The /27/ Today over fifty companies produce variations of the Several of these companies have over fifty versions of the 8051.
8051 Micro controller. Architecture of 8051 Features of 8051.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
Intel 8051 Another family of microcontroller is the Intel 8051 family. The basic 8051 microcontroller has four parallel input/output ports, port 0, 1,
Operators in JAVA. Operator An operator is a symbol that operates on one or more arguments to produce a result. Java provides a rich set of operators.
The Silicon Laboratories C8051F020
Arduino Mega Arduino Mega 2560 Arduino Mega 2560.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
Chapter 7 Bit Manipulation. 7.1 Logical Operations.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
Memory in CSE Overview2 Program Memory Program and Data memory are separate Can be internal and/or external – 20K internal flash for the.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.
MODULE 5 INTEL TODAY WE ARE GOING TO DISCUSS ABOUT, FEATURES OF 8086 LOGICAL PIN DIAGRAM INTERNAL ARCHITECTURE REGISTERS AND FLAGS OPERATING MODES.
Chapter Microcontroller
8051 Micro Controller. Microcontroller versus general-purpose microprocessor.
Internal Programming Architecture or Model
Introduction 8051 Programming language options: Assembler or High Level Language(HLL). Among HLLs, ‘C’ is the choice. ‘C’ for 8051 is more than just ‘C’
MICROCONTROLLER INTERFACING WITH STEPPER MOTOR MADE BY: Pruthvirajsinh Jadeja ( ) COLLEGE:DIET BRANCH:EC.
Windows Programming Lecture 06. Data Types Classification Data types are classified in two categories that is, – those data types which stores decimal.
80C51 Block Diagram 1. 80C51 Memory Memory The data width is 8 bits Registers are 8 bits Addresses are 8 bits – i.e. addresses for only 256.
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
“ INSTRUCTIONS SET OF AVR MICROCONTROLLER ” SIGMA INSTITUTE OF ENGINEERING Prepared By: SR.NO NAME OF STUDENT ENROLLMENT 1 Abhishek Lakhara
CHAPTER ADDRESSING MODES.
80C51 Block Diagram ECE Overview.
Interrupt Source: under
ECE,JYOTHI ENGG COLLEGE
C Short Overview Lembit Jürimägi.
William Stallings Computer Organization and Architecture 8th Edition
8051 Programming in C rhussin.
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Important 8051 Features On chip oscillator 4K bytes ROM 128 bytes RAM
Homework Homework Continue Reading K&R Chapter 2 Questions?
Compiled by Dr. N.Shanmugasundaram, HOD, ECE Dept, SECE.
Operations and Arithmetic
8051 Development System Details
Presentation transcript:

LHO 22 C and the 8051

 The Silicon Labs ISE uses the Keil C51 compiler.  The code size is limiter to 2K  C has replaced PL/M (the original Intel high level language (HLL) for imbedded systems).  Versions of basic and a few other HLL such as FOUTH are available for the  The Keil C51 is a complete implementation of ANSI C with extensions. o The extensions support various features of the o See Chapter 3 of the C51 compiler manual. You can find this using the Help menu.

Assembly Code Object Code Assembler C Code Object Code Linker Machine Code Compiler Code Generation Flow for assembler and C.

Include c8051F020.h in each C file. c8051F020.h defines the special function registers (SFR) of the 8051F020. /* BYTE Registers */ sfr P0 = 0x80;/* PORT 0 */ sfr SP = 0x81;/* STACK POINTER */ sfr DPL = 0x82;/* DATA POINTER - LOW BYTE */ sfr DPH = 0x83;/* DATA POINTER - HIGH BYTE */ sfr P4 = 0x84; /* PORT 4 */ … /* BIT Registers */ /* TCON 0x88 */ sbit TF1 = TCON ^ 7; /* TIMER 1 OVERFLOW FLAG */ sbit TR1 = TCON ^ 6; /* TIMER 1 ON/OFF CONTROL */

uni.c ;Version /29/07 #include // SFR declarations #include // // Init - Configure UDC // Returns : None // Parameters : None // void init_crossbar(void); void init_ports(void); void init_osc(void);

void Init (void) { // Disable interrupts EA = 0; // Disable watchdog timer WDTCN = 0xde; WDTCN = 0xad; init_osc(); // Enable crossbar switch init_crossbar(); // Set up ports init_ports(); }

// // rd_buttons - Configure IO ports // Returns : Value of buttons connected to P5.3 - P5.0. // Pressing a button // sets bit to a '1'. // Parameters : None // unsigned char rd_buttons(void) { unsigned char btns; btns = (~P5) & 0x0f; return(btns); }

// // wr_leds - Outsput to led's // Returns : None // Parameters : leds // void wr_leds(unsigned char leds) { P5 = (leds << 4) | 0x0f; }

// // init_ports - Configure IO ports // Returns : None // Parameters : None // void init_ports(void) { P0MDOUT = 0x00; P1MDOUT = 0x00; P2MDOUT = 0x00; P3MDOUT = 0x00; P5 = 0x0f; //TURN ON LEDS P74OUT = 0x08; // SET PORT 5 OUT AS PUSH PULL P4 = 0xff; ; }

// // Init_crosbar - Configure crossbar switch // Returns : None // Parameters : None // void init_crossbar (void) { XBR0 = 0x0; XBR1 = 0x0; XBR2 = 0x48; // Enable cross bar }

// // init_osc - Use external XTAL as clock // Returns : None // Parameters : None // void init_osc (void) { OSCXCN = 0x67; //enable MHz XTAL OSC while ((OSCXCN & 0x80) == 0); // Wait till XTLVLD // pin is set See Fig 14.3 OSCICN = 0x88; //config internal oscillator }

// // delay - delay for visiable blink // Returns : None // Parameters : None // void delay(void) { unsigned int x; unsigned char y; while(x++) { y = 10; while(y--); }

 External data memory, up to 64 kB, can be read from and written to and is physically located externally from the CPU  Access to external data in XDATA space is very slow when compared to access to internal data  This is because external data memory is accessed indirectly through the data pointer register (DPTR) which must be loaded with a 16-bit address before accessing the external memory  There are two different data types in Cx51 used to access external data: xdata and pdata  The xdata memory specifier refers to any location in the 64 kB address space of external data memory (default for LARGE memory model)  The pdata memory type specifier refers to only 1 page or 256 bytes of external data memory (default for COMPACT memory model)  The pdata area is accessed using registers R0 and R1 indirectly instead of the DPTR so accessing pdata is slightly faster than xdata. This is also what limits pdata to 256 bytes (R0 and R1 are 8 bits).

 Arithmetic operators perform basic arithmetic operations  All arithmetic operators except the negation (–) operator have two operands.  The negation (unary minus) operator returns the 2’s complement value of the operand  This is especially useful to specify a count that will be counted up rather than counted down  Example: unsigned int count = 0x0F; // TMR2RL gets 0xFFFF-0x0F+1 = 0xFFF1 TMR2RL = -count; OperatorDescription +Add –Subtract *Multiply /Divide %Modulo (remainder of division) –Negation (unary minus)

 Relational operators compare data and the outcome is either True or False  if statements, for loops and while loops often make use of relational operators OperatorDescription ==Equal to !=Not Equal to <Less than >Greater than <=Less than or equal to >=Greater than or equal to

 Logical operators operate on Boolean data (True and False values) and the outcome is also Boolean OperatorDescription &&Logical AND ||Logical OR !Logical NOT

 The C language also has several bitwise operators  Bitwise operators affect a variable on a bit-by-bit basis  Example: Result = Value1 & Value2;  If Value1 = b and Value2 = b, the result of Value1 & Value2 is: b & b = b OperatorDescription &Bitwise AND |Bitwise OR ~Bitwise NOT (1’s Compliment) ^Bitwise Exclusive OR <<Shift Left >>Shift Right

 Turning Bits On  Turn on a particular bit by ORing with a 1  Turning Bits Off  Turn off a particular bit by ANDing with a 0  Toggling Bits  Turning a bit from off to on or on to off by EXCLUSIVELY ORing with a 1 Bit wise Operators