PIC in Practice potx

320 797 0
PIC in Practice potx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... the PIC Microcontroller uses 35 words (instructions) 10 Introduction to the PIC microcontroller in its vocabulary A few more instructions are used in the bigger microcontrollers In order to communicate with the microcontroller we need to know what these 35 instructions are and how to use them Not all 35 instructions are used in this book In fact you can write meaningful programs using only 5 or 6 instructions... logic0, in hardware terms this means pin6 in Figure 2.1 is at 0v turning the LED off  Line4 CALL DELAYP5 is the same as Line2  Line5 GOTO BEGIN sends the program back to the label BEGIN to repeat the process of flashing the LED on and off Any of the 8 outputs can be turned ON and OFF using the 2 instructions BSF and BCF for example: BSF PORTB,3 makes PORTB,3 (pin9) 5v BCF PORTB,7 makes PORTB,7 (pin13)... instruction set In order to write a program we need to understand what these words mean and how we can combine them 2 Introduction to the PIC microcontroller The complete instruction set is shown in Chapter 19 Instruction Set, Files and Registers All of the programs illustrated in the book are available from: http://books.elsevier.com/uk//newnes/uk/subindex.asp?maintarget¼ companions/defaultindividual.asp&isbn¼0750648120... connected using the internal pull up Micro 0v Figure 1.8 Connecting a switch using an internal pull up Connecting outputs to the microcontroller The microcontroller is capable of supplying approximately 20–25mA to an output pin So loads such as LEDs or small relays can be driven directly Larger loads require interfacing via a transistor, for dc or a triac, for ac Opto-coupled devices provide an isolated interface... shown in Figure 2.6 Figure 2.6 Compiling FLASHER.ASM to FLASHER.HEX If the program has compiled without any errors then MPLAB will return with a message Build Succeeded as indicated in Figure 2.7 There may be some warnings and messages but do not worry about them, the compiler has seen something it wasn’t expecting Incidently, I always have line numbers on my code to find my way around, especially in. .. alternately The idea being, when you have understood my code you can then modify it for your own program, thus understanding better Once you have written your first program you are then off and running The book then continues with further applications such as traffic lights and disco lights to introduce more of the instructions increasing your microcontroller vocabulary Instructions used in this chapter:... accept this as 37 in decimal (note the is not a decimal point) or as 25H in hex or B’00100101’ in binary 181 decimal would be entered as 181 in decimal, 0B5H in hex or B’10110101’ in binary NB If a hex number starts with a letter it must be prefixed with a 0, i.e 0B5H not B5H NB The default radix for the assembler MPASM is hex Appendix C illustrates how to change between Decimal, Binary and Hexadecimal... program working  BEGIN is a label A label is used as a location for the program to go to  Line1 the instruction BSF and its data PORTB,0 is shorthand for Bit Set in File, which means Set the Bit in the File PORTB, where bit0 is the designated bit This will cause PORTB,0 to be Set to a logic1, in hardware terms this means pin6 in Figure 2.1 is at 5v turning the LED on Programming the 16F84 microcontroller... 19 NB There must not be any spaces in a label, an instruction or its data I keep the program tidy by using the TAB key on the keyboard  Line2 CALL DELAYP5 causes the program to wait 0.5 seconds while the subroutine DELAYP5 in the header is executed  Line3 BCF PORTB,0 is the opposite of Line1, this code is shorthand for Bit Clear in File, which means Clear the Bit in the File PORTB, where bit0 is the... control circuits using devices such as switches, keypads, analogue sensors, LEDs, buzzers, 7 segment displays, alpha-numeric displays, radio transmitters etc This is done by introducing graded examples, starting off with only a few instructions and gradually increasing the number of instructions as the complexity of the examples increases Each chapter clearly identifies the new instructions added to .

Ngày đăng: 16/03/2014, 09:20

Từ khóa liên quan

Mục lục

  • PIC in Practice

    • PIC in Practice

      • Contents

      • Introduction

      • 1 Introduction to the PIC microcontroller

        • The aim of the book

        • Program memory

        • Microcontroller clock

        • The microcontroller system

        • Types of microcontroller

        • Microcontroller specification

        • Using the microcontroller

        • 1 Microcontroller hardware

        • 2 Programming the microcontroller

        • 2 Programming the 16F84 microcontroller

          • Microcontroller inputs and outputs (I/O)

          • Timing with the microcontroller

          • Programming the microcontroller

          • Entering data

          • The Header for the 16F84, HEADER84.ASM

          • Program example

          • Saving and assembling the code

          • PICSTART PLUS programmer

          • Programming flowchart

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan