Chapter 7 Summary Microcontroller Programming and Interfacing

Similar documents
Section 29. Instruction Set

PIC Programming in Assembly. (

10-bit Σ ADC from a PIC16F84

AN727. Credit Card Reader Using a PIC12C509 DATA ENCODING INTRODUCTION FIGURE 1: POSITION OF ISO TRACKS 1, 2 AND 3. Andrew M Errington

SPI. Overview and Use of the PICmicro Serial Peripheral Interface. Getting Started: SPI

Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II

MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence :

BASIC for PIC microcontrollers

Using The PIC I/O Ports

Small Hardware Development and Prototyping Board for the SX28

c0003 A Simple PIC Application CHAPTER 3

8051 MICROCONTROLLER COURSE

Chapter 13. PIC Family Microcontroller

Web Site: Forums: forums.parallax.com Sales: Technical:

How To Program A Microcontroller With Memory On A Microchip Microcontroller

B Robo Claw 2 Channel 5A Motor Controller Data Sheet

Analog-to-Digital Converters

BASIC for PIC microcontrollers

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

MICROCONTROLLER INTERFACING CIRCUITS

Section 28. In-Circuit Serial Programming (ICSP )

I 2 C Master Mode Overview and Use of the PICmicro MSSP I 2 C Interface with a 24xx01x EEPROM

Timer A (0 and 1) and PWM EE3376

Contents. revolution MICROCONTROLLER INTERFACING CIRCUITS. 1 Section 3

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

PICAXE X2 Product Briefing (updated Dec 10).

Accurate Measurement of the Mains Electricity Frequency

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

Special Lecture. Basic Stamp 2 Programming. (Presented on popular demand)

Lab Experiment 1: The LPC 2148 Education Board

Four-Channel Digital Voltmeter with Display and Keyboard. 8 x 220W RB0 RB1 RB2 RB3 RB4 RB5 RB6 RB7 RA0 RA1 RA2 RA3 PIC16C71

Simple Alarm System WIRELESS AND REMOTE CONTROLLED PERSONAL APPLIANCE CODE WORD ORGANIZATION TRANSMISSION FORMAT

Section 9. I/O Ports

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

Design and Construction of Variable DC Source for Laboratory Using Solar Energy

PIC in Practice. A Project-Based Approach. D. W. Smith

PICAXE RF CONNECT KIT (AXE213)

POCKET SCOPE 2. The idea 2. Design criteria 3

Chapter 4: Pulse Width Modulation

Section 8. Interrupts

Real-Time Clock. * Real-Time Computing, edited by Duncan A. Mellichamp, Van Nostrand Reinhold

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

1. The demonstration code is sending garbage to my terminal program. What are the recommended settings?

Introduction to Microcontrollers

Microcontrollers in Practice

PIC Application Notes

Debouncing Switches. Mechanical switches are one of the most common interfaces to a uc.

Microtronics technologies Mobile:

PART B QUESTIONS AND ANSWERS UNIT I

EMBEDDED SYSTEMS PROGRAMMING WITH THE PIC16F877

An Introduction to MPLAB Integrated Development Environment

Section 14. Compare/Capture/PWM (CCP)

Fondamenti su strumenti di sviluppo per microcontrollori PIC

AN880. Converting from 8051 to Microchip Assembler: A Quick Reference INTRODUCTION

CoE3DJ4 Digital Systems Design. Chapter 4: Timer operation

Embedded C Programming

AN857. Brushless DC Motor Control Made Easy INTRODUCTION S 001 B. Anatomy of a BLDC SIMPLIFIED BLDC MOTOR DIAGRAMS. Microchip Technology Inc.

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

Microcontrollers for Ham Radio Part 1 - BASIC Stamp

8031AH 8051AH 8032AH 8052AH NMOS SINGLE-CHIP 8-BIT MICROCONTROLLERS

Getting Graphic: Defining Custom LCD Characters

Quick Reference. B.5 12-Bit Core Instruction Set APPENDICES

Peak Power Tracker Circuit Description (from

Tutorial for MPLAB Starter Kit for PIC18F

ServoPAL (#28824): Servo Pulser and Timer

Section 19. Voltage Reference

MICROPROCESSOR AND MICROCOMPUTER BASICS

A Lesson on Digital Clocks, One Shots and Counters

A PIC16F628 controlled FLL (Frequency Locked Loop) VFO for HF

AN857. Brushless DC Motor Control Made Easy INTRODUCTION S 001 B. Anatomy of a BLDC SIMPLIFIED BLDC MOTOR DIAGRAMS

Chapter 2: Assembly Language Programming. The PIC18 Microcontroller. Han-Way Huang

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Design and Construction of Microcontroller Based Charge Controller for Photovoltaic Application

Palaparthi.Jagadeesh Chand. Associate Professor in ECE Department, Nimra Institute of Science & Technology, Vijayawada, A.P.

LADDER LOGIC/ FLOWCHART PROGRAMMING DIFFERENCES AND EXAMPLES

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

MX PIC24F Educational Module User Manual

Experiment #26: Stepper Motor Control

MACHINE ARCHITECTURE & LANGUAGE

EasyPIC4 User s Manual

Measuring Resistance Using Digital I/O

A Lesson on Digital Clocks, One Shots and Counters

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

Display Message on Notice Board using GSM

Ultrasonic Distance Measurement Module

Display Board Pulse Width Modulation (PWM) Power/Speed Controller Module

HT46R14A Single Phase AC Induction Motor Frequency Converter Application

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

Serial Communications

PIC16F84A. 18-pin Enhanced Flash/EEPROM 8-Bit Microcontroller. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features:

ETEC Digital Controls PIC Lab 10 Pulse Width Modulation

[F/T] [5] [KHz] [AMP] [3] [V] 4 ) To set DC offset to -2.5V press the following keys [OFS] [+/-] [2] [.] [5] [V]

71M6521 Energy Meter IC. Real Time Clock Compensation. The Challenge. The RTC in the 71M6521D/F. Theory of Operation APPLICATION NOTE

DESIGN OF OPEN ARCHITECTURE SHIP ALARM, MONITORING AND CONTROL SYSTEM

PIC16F8X. 18-pin Flash/EEPROM 8-Bit Microcontrollers. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features:

PIC12F508/509/16F505 Data Sheet

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

HT9170 DTMF Receiver. Features. General Description. Selection Table

Transcription:

Chapter 7 Summary Microcontroller Programming and Interfacing PIC16F84 1 RA2 RA1 18 2 RA3 RA0 17 1 k 3 4 5 RA4 MCLR Vss OSC1 OSC2 Vdd 16 15 14 4 MHz 22 pf 22 pf 6 RB0 RB7 13 7 RB1 RB6 12 8 RB2 RB5 11 9 10 RB3 RB4 0.1 F PIC16F84 pin-out and required external components PIC16F84 instruction set Mnemonic and Operands ADDLW k ADDWF f, d ANDLW k ANDWF f, d BCF f, b BSF f, b BTFSC f, b BTFSS f, b CALL k CLRF f CLRW CLRWDT add literal and W add W and f AND literal with W AND W with f bit clear f bit set f bit test f, skip if clear bit test f, skip if set call subroutine clear f clear W clear Watchdog Timer

Mnemonic and Operands COMF f, d complement f DECF f, d decrement f DECFSZ f, d decrement f, Skip if 0 GOTO k go to address INCF f, d increment f INCFSZ f, d increment f, skip if 0 IORLW k inclusive OR literal with W IORWF f, d inclusive OR W with f MOVF f, d move f MOVLW k move literal to W MOVWF f move W to f NOP no operation RETFIE return from interrupt RETLW k return with literal in W RETURN return from subroutine RLF f, d rotate f left 1 bit RRF f, d rotate f right 1 bit SLEEP go into standby mode SUBLW k subtract W from literal SUBWF f, d subtract W from f SWAPF f, d Swap nibbles in f XORLW k Exclusive OR literal with W XORWF f, d Exclusive OR W with f Selected PicBasic Pro math operators and functions math operator or function description A + B add A and B A B A * B A / B subtract B from A multiply A and B divide A by B

math operator or function description A << n shift A n bits to the left A >> n shift A n bits to the right COS A return the cosine of A A MAX B return the maximum of A and B A MIN B return the minimum of A and B SIN A return the sine of A SQR A return the square root of A A & B return the bitwise AND of A and B A B return the bitwise OR of A and B A ^ B return the bitwise exclusive OR of A and B ~A return the bitwise NOT of A PicBasic Pro logical comparison operators operator description = or == equal <> or!= not equal < less than > greater than <= less than or equal to >= greater than or equal to @ assembly statement ADCIN channel, var ASM... ENDASM PicBasic Pro statement summary BRANCH index, [label1{, label2,...}] insert one line of assembly language code read the on-chip analog to digital converter (if there is one) insert an assembly language code section consisting of one or more statements computed GOTO that jumps to a label based on index

BRANCHL index, [label1{, label2,...}] BUTTON pin, down_state, auto_repeat_delay, auto_repeat_rate, countdown_variable, action_state, label CALL assembly_label CLEAR CLEARWDT COUNT pin, period, var DATA {@ location,} constant1{, constant2,...} DEBUG item1{, item2,...} DEBUGIN {timeout, label,} [item1{,{item2,...}] DISABLE DISABLE DEBUG DISABLE INTERRUPT DTMFOUT pin, {on_ms, off_ms,} [tone1{, tone2,...}] {EEPROM {@ location,} constant1{, constant2,...}} ENABLE ENABLE DEBUG ENABLE INTERRUPT END BRANCH to a label that can be outside of the current page of code memory (for PICs with more than 2k of program ROM) read the state of a pin and perform debounce (by use of a delay) and autorepeat (if used within a loop) call an assembly language subroutine zero all variables clear the Watchdog Timer count the number of pulses occurring on a pin during a period define initial contents of the on-chip EEPROM (same as the EEPROM statement) asynchronous serial output to a pin at a fixed baud rate asynchronous serial input from a pin at a fixed baud rate disable ON INTERRUPT and ON DEBUG processing disable ON DEBUG processing disable ON INTERRUPT processing produce touch-tones on a pin define initial contents of on-chip EEPROM (same as DATA statement) enable ON INTERRUPT and ON DEBUG processing enable ON DEBUG processing enable ON INTERRUPT processing stop execution and enter low power mode

FOR count = start TO end {STEP {-} inc} {body statements} NEXT {count} FREQOUT pin, on_ms, freq1{, freq2} GOSUB label GOTO label HIGH pin HSERIN {parity_label,} {time_out, label,} [item1{, item2,...}] HSEROUT [item1{, item2,...}] I2CREAD data_pin, clock_pin, control,{ address,} [var1{, var2,...}]{, label} I2CWRITE data_pin, clock_pin, control,{ address,} [var1{, var2,...}]{, label} IF log_comp THEN label IF log_comp THEN true_statements ELSE false_statements ENDIF INPUT pin LCDIN {address,} [var1{, var2,...}] LCDOUT item1{, item2,...} {LET} var = value LOOKDOWN value, [const1{, const2,...}], var LOOKDOWN2 value,{ test} [value1{, value2,...}], var repeatedly execute statements as count goes from start to end in fixed increment produce up to two frequencies on a pin call a PicBasic subroutine at the specified label continue execution at the specified label make pin output high hardware asynchronous serial input (if there is a hardware serial port) hardware asynchronous serial output (if there is a hardware serial port) read bytes from an external I 2 C serial EEPROM device write bytes to an external I 2 C serial EEPROM device conditionally jump to a label conditional execution of statements make pin an input read RAM on a liquid crystal display (LCD) display characters on a liquid crystal display (LCD) assignment statement (assigns a value to a variable) search constant table for a value search constant / variable table for a value

LOOKUP index, [const1{, const2,...}], var LOOKUP2 index, [value1{, value2,...}], var LOW pin NAP period ON DEBUG GOTO label ON INTERRUPT GOTO label OUTPUT pin PAUSE period PAUSEUS period {PEEK address, var} {POKE address, var} POT pin, scale, var PULSIN pin, state, var PULSOUT pin, period PWM pin, duty, cycles RANDOM var RCTIME pin, state, var READ address, var READCODE address, var RESUME {label} RETURN REVERSE pin fetch constant value from a table fetch constant / variable value from a table make pin output low power down processor for a selected period of time execute PicBasic debug subroutine at label after every statement if debug is enabled execute PicBasic subroutine at label when an interrupt is detected make pin an output delay a given number of milliseconds delay a given number of microseconds read byte from a register write byte to a register read resistance of a potentiometer, or other variable resistance device, connected to a pin with a series capacitor to ground measure the width of a pulse on a pin generate a pulse on a pin output a pulse width modulated (PWM) pulse train to pin generate a pseudo-random number measure pulse width on a pin read a byte from on-chip EEPROM read a word from code memory continue execution after interrupt handling continue execution at the statement following last executed GOSUB make output pin an input or an input pin an output

SERIN pin, mode,{ timeout, label,} {[qual1, qual2,...],}{ item1{, item2,...}} SERIN2 data_pin{\flow_pin}, mode, {parity_label,} {timeout, label,} [item1{, item2,...}] SEROUT pin, mode, [ item1{, item2,...}] SEROUT2 data_pin{\flow_pin}, mode, {pace,} {timeout, label,} [item1{, item2,...}] SHIFTIN data_pin, clock_pin, mode, [var1{\bits1}{, var2{\bits2},...}] SHIFTOUT data_pin, clock_pin, mode, [var1{\bits1}{, var2{\bits2},...}] SLEEP period SOUND pin, [note1, duration1{, note2, duration2,...}] STOP SWAP var1, var2 TOGGLE pin WHILE logical_comp statements WEND WRITE address, value WRITECODE address, value XIN data_pin, zero_pin, {timeout, label,} [var1{, var2,...}]] XOUT data_pin, zero_pin, [house_code1\key_code1{\repeat1}{, house_code2\key_code2{\repeat2,...}] asynchronous serial input (Basic Stamp 1 style) asynchronous serial input (Basic Stamp 2 style) asynchronous serial output (Basic Stamp 1 style) asynchronous serial output (Basic Stamp 2 style) synchronous serial input synchronous serial output power down the processor for a given number of seconds generate a tone or white-noise on a specified pin stop program execution exchange the values of two variables change the state of an output pin execute code while condition is true write a byte to on-chip EEPROM write a word to code memory receive data from an external X-10 type device send data to an external X-10 type device

input device PIC input pin TTL () RA0 through RA4 or RB0 through RB7 TTL buffers open collectro TTL or open drain switch RB0 through RB7 weak pull-up slowly changing and/or noisy digital signal RA4 Schmitt trigger buffer Interface circuits for input devices

PIC output pin output device RA0 through RA3 RB0 through RB7 TTL TTL TTL RA0 through RA3 or RB0 through RB7 buffer multiple RA4 open drain small current load V supply Vss V supply RA0 through RA3 or RB0 through RB7 load BJT power transistor load V supply load V supply power relay n-channel enhancement power MOSFET RA0 through RA3 or RB0 through RB7 D/A amplifier load Interface circuits for output devices Method to Design a Microcontroller-based System: 1. define the problem 2. select an appropriate microcontroller model 3. identify necessary interface circuits 4. decide on a programming language 5. draw the schematic 6. draw a program flowchart 7. write the code 8. build and test the system