© AJH 2013, V2.0 Computer Programming Embedded Systems Programming Stand-alone code, system initialisation, operating systems. Low-level operations; port.

Slides:



Advertisements
Similar presentations
MICROPROCESSORS AND MICROCONTROLLERS
Advertisements

EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
Simple Microcontroller Programming with PIC16F88.
Introduction to Micro-controllers Anurag Dwivedi.
Chung-Ta King National Tsing Hua University
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Slides created by: Professor Ian G. Harris PIC Development Environment MPLAB IDE integrates all of the tools that we will use 1.Project Manager -Groups.
EE1A2 Microprocessor Systems & Digital Logic Part I Digital Electronic System Design Dr. T. Collins.
MICRO PROCESSER The micro processer is a multipurpose programmable, clock driven, register based, electronic integrated device that has computing and decision.
Programming the ATmega16
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ input/output and clock inputs Sequence of control signal combinations.
Railway Foundation Electronic, Electrical and Processor Engineering.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Railway Foundation Electronic, Electrical and Processor Engineering.
The 8051 Microcontroller Architecture
Microcontroller 8051.
Dr. Amr Talaat. #include ; /* this makes the header file for the PIC16f877 ready to be used in the C-class */ #define LED PORTC ; /* defines.
Engineering 1040: Mechanisms & Electric Circuits Fall 2011 Introduction to Embedded Systems.
Chapter 4 Starting to Program – an Introduction to Assembler The aims of this chapter are to introduce: the essentials of Assembler programming; the Microchip.
The 8051 Microcontroller architecture
Serial Communication ETEC 6416.
Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors.
Objectives How Microcontroller works
Microcontrollers Microcontroller (MCU) – An integrated electronic computing device that includes three major components on a single chip Microprocessor.
Parallel Ports, Power Supply and the Clock Oscillator Material to be covered  Parallel I/O ports  Interfacing external switches and LEDs  Clock Oscillator.
Embedded Systems. Today Introduction to Mechatronics Microcontroller –Input / Output Ports (I/O) –Memory –ADC –PWM.
Computer Fundamentals ELEC 330 Digital Systems Engineering Dr. Ron Hayne.
Microprocessors A practical approach Subjects Goals for this module Results Subjects of the module Plans Questions.
Microcontroller Presented by Hasnain Heickal (07), Sabbir Ahmed(08) and Zakia Afroze Abedin(19)
CPU Internal memory I/O interface circuit System bus
Eng.Samra Essalaimeh Philadelphia University 2013/ nd Semester PIC Microcontrollers.
Engineering 1040: Mechanisms & Electric Circuits Winter 2015 Introduction to C Programming.
Chapter 2 Introducing the PIC Mid-Range Family and the 16F84A The aims of this chapter are to introduce: The PIC mid-range family, in overview The overall.
ECS642U Embedded Systems Cyclic Execution and Polling William Marsh.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
Microcontrollers Class : 4th Semister E&C and EEE Subject Code: 06ES42
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
Saxion University of Applied Sciences Advanced Microcontrollers A practical approach.
MICROOCESSORS AND MICROCONTROLLER:
I NTRODUCTION TO PIC PROGRAMMING By : S HERIF H ARHASH.
Features of the PIC18 microcontroller - 8-bit CPU - 2 MB program memory space (internal 32KB to 128KB) bytes to 1KB of data EEPROM - Up to 4096 bytes.
Microcontrollers, Microcomputers, and Microprocessors
Chapter Microcontroller
Microcontroller based Traffic signal Umer Butt Amna Rashid Izza Rabbani Rozab Naveed Ramesha Akram.
MICROCONTROLLER INTERFACING WITH STEPPER MOTOR MADE BY: Pruthvirajsinh Jadeja ( ) COLLEGE:DIET BRANCH:EC.
Microcontrollers JULES CALELLA. Microcontrollers vs Microprocessors  Microprocessors – do not contain RAM, ROM, I/O  Microcontrollers – The whole package.
Microcontroller basics Embedded systems for mortals.
Programming PIC 16F84A in Assembly. PIC16F84 pin-out and required external components.
VEHICLE ACCIDENT PREVENTATION USING EYE BLINK SENSOR PRESENTED BY LAKSHMY PREMARAJAN ASHIKA K VARGHESE AKHILA S KUMAR.
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
Microprocessors A practical approach..
CEng3361 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2011 Recitation 06.
 Mini-Computer ◦ Microprocessor  The Brains  Arithmetic Logic Unit (ALU)  Control Unit  Program/ Data Storage  Peripherals (Input/Output)  Low-Cost.
Embedded Microcontroller Systems
The 8051 Microcontroller architecture
PROGRAMMABLE LOGIC CONTROLLERS SINGLE CHIP COMPUTER
Microprocessor and Microcontroller Fundamentals
Microprocessor and Microcontroller Fundamentals
Embedded Microcontroller Systems
Microcontroller basics
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
IPCOWALA INSTITUTE OF ENGINEERING & TECHNOLOGY-DHARMAJ
Introduction to Microprocessors and Microcontrollers
Figure 8-1. PIC18F458 Pin Diagram
פרטים נוספים בסילבוס של הקורס
Computer Electronic device Accepts data - input
Introducing the PIC Mid-Range Family and the 16F84A
Computer Electronic device Accepts data - input
8051 Micro Controller.
Bit Manipulations CS212.
Presentation transcript:

© AJH 2013, V2.0 Computer Programming Embedded Systems Programming Stand-alone code, system initialisation, operating systems. Low-level operations; port access, bitwise manipulation. Hexadecimal, Binary, two’s complement representation and arithmetic. Computer Programming1

© AJH 2013, V2.0 What is … ? … an Embedded System?  An electronic system that contains an integral processor, programmed to perform a dedicated task … Real Time Software?  Correct operation depends not only on logical correctness of computation but also time at which result is produced … a microcontroller?  A complete processor on a single IC, containing CPU, RAM, ROM and Input/Output Computer Programming2

© AJH 2013, V2.0TIC-PIC Application Trainer3

© AJH 2013, V2.0TIC-PIC Application Trainer4 TIC-PIC Block Diagram B5 B4 B3 B2 B1 B0 C4 C3 C5 C1 C0 C2 A4 A5 +5V Reset PIC18F MHz Osc2 Osc1 MAX 232A C7/Rx C6/Tx RS-232 A3 A2 A1 A0 x8 D7 D0 dp g +5V CC AN7 Temp +5V AN6 LDR +5V AN5 Pot

© AJH 2013, V2.0TIC-PIC Application Trainer5 PIC Port Connections RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0 PORTC

© AJH 2013, V2.0TIC-PIC Application Trainer6 “Hello World” Write a C program that prints “Hello World” on the screen #include // header defining printf( ) etc int main(void) // main returns successful code to OS { printf(“Hello World\n”); return 0; // return “success” to OS }

© AJH 2013, V2.0TIC-PIC Application Trainer7 Embedded “Hello World” #include // Processor specific header #pragma config OSC=HS,PWRT=ON,WDT=OFF,LVP=OFF,PBADEN=OFF,DEBUG=ON void main(void) // note void parameter/return { TRISC=0b ; // program port as output while(1){ // infinite loop PORTC=0b ; // alternate LEDs on PORTC=0b ; // swap over (only 6 LSB available) } // note non-standard binary notation }

© AJH 2013, V2.0TIC-PIC Application Trainer8 #include defines port and other identifiers related to the PIC architecture (e.g. PORTC) library not usually relevant to embedded applications

© AJH 2013, V2.0TIC-PIC Application Trainer9 #pragma config... Initialises processor configuration fuses –OSC=HShigh speed crystal oscillator –PWRT=ONpower up timer on –WDT=OFFwatchdog timer off –LVP=OFFlow voltage programming off –PBADEN=OFFport B analog enable off –DEBUG=ONdebugging enabled (PICkit2)

© AJH 2013, V2.0TIC-PIC Application Trainer10 void main(void) In an embedded application there is no Operating System to which a value can be returned. As a result main( ) returns void.

© AJH 2013, V2.0TIC-PIC Application Trainer11 while(1) Embedded program ‘has no end’ While(1)produces an infinite loop which repeats the statements between { and } indefinitely. Alternative is while(TRUE) or for(;;)

© AJH 2013, V2.0TIC-PIC Application Trainer12 PORTC = 0b ; Ports are ‘memory mapped’ Ports are treated like variables PORTC = 0b ; // output data x = PORTB; // input data PORTC = x; // output variable

© AJH 2013, V2.0TIC-PIC Application Trainer13 TRISC = 0b ; DDRC = 0b ; Ports are programmable and must be configured before use. TRIS registers control tristate output buffers (also called DDR) A 1 in TRIS programs port bit as Input A 0 in TRIS programs port bit as Output Non ANSI-standard binary constants

© AJH 2013, V2.0TIC-PIC Application Trainer14 I/O Port Block Diagram - Output

© AJH 2013, V2.0TIC-PIC Application Trainer15 I/O Port Block Diagram - Input

© AJH 2013, V2.0TIC-PIC Application Trainer16 Configuring ports Write down the statements to configure: –Port A, 6 LSB = inputs TRISA = 0b ; –Port B, 6 LSB = outputs TRISB = 0; or TRISB = 0b ; –Port C, 4 LSB = outputs, 4 MSB = inputs TRISC = 0b ;

© AJH 2013, V2.0TIC-PIC Application Trainer17 Time Delays A delay is produced by ‘doing nothing’ a large number of times, using an empty for loop void delay(void) { unsigned int d; for(d=10000;d>0;d--); // empty loop } // creates a delay

© AJH 2013, V2.0TIC-PIC Application Trainer18 Final Program including Delay #include // Processor specific header #pragma config OSC=HS,PWRT=ON,WDT=OFF,LVP=OFF,PBADEN=OFF,DEBUG=ON void delay(void); // function prototype void main(void) // note void parameter { TRISC=0b ; // program port as output for(;;) // infinite loop { PORTC=0b ; // alternate LEDs on delay(); PORTC=0b ; // swap over (only 6 LSB available) delay(); } // note non-standard binary notation } void delay(void) { unsigned int d; for(d=10000;d>0;d--); // empty loop creates a delay }