100% found this document useful (1 vote)
130 views15 pages

Pic Microcontroller: Technological University of The Philippines

Instructions which make up the lower-level program language for PIC microcontrollers. Instruction Set in PIC16Cxx Microcontroller Family Complete set which includes 35 instructions. Instructions are well optimized considering speed of work, architectural simplicity and code compactness. Only drawback is that programmer is expected to master "uncomfortable" technique of using a reduced set of instructions.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
130 views15 pages

Pic Microcontroller: Technological University of The Philippines

Instructions which make up the lower-level program language for PIC microcontrollers. Instruction Set in PIC16Cxx Microcontroller Family Complete set which includes 35 instructions. Instructions are well optimized considering speed of work, architectural simplicity and code compactness. Only drawback is that programmer is expected to master "uncomfortable" technique of using a reduced set of instructions.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

TECHNOLOGICAL UNIVERSITY OF THE PHILIPPINES

Ermita, Manila

MICROPROCESSOR I/O SYSTEMS

PIC MICROCONTROLLER
HISTORY | INSTRUCTION SETS | ADDRESSING MODES | TRENDS AND ISSUES

Submitted By: CARL LOU ADAO ALBERT N. MINA APRIL JOHN VICTO RONNEL JOSEPH F. COOPER

Submitted To: Engr. Melbourne Maltezo

September 3, 2011

INSTRUCTION SET by Albert N. Mina


PIC16Cxx Microcontroller Instruction Set Introduction We have already mentioned that microcontroller is not like any other integrated circuit. When they come out of production most integrated circuits are ready to be built into a device which is not the case with microcontrollers. In order to "make" microcontroller perform a task, we have to tell it exactly what to do, or in other words we must write the program microcontroller will execute. We will describe in this chapter instructions which make up the assembler or lower-level program language for PIC microcontrollers. Instruction Set in PIC16Cxx Microcontroller Family Complete set which includes 35 instructions is given in the following table. A reason for such a small number of instructions lies primarily in the fact that we are talking about a RISC microcontroller whose instructions are well optimized considering the speed of work, architectural simplicity and code compactness. The only drawback is that programmer is expected to master "uncomfortable" technique of using a reduced set of 35 instructions. Data transfer Transfer of data in a microcontroller is done between work (W) register and an 'f' register that represents any location in internal RAM (regardless whether those are special or general purpose registers). Mnemonic MOVLW k MOVWF f MOVF CLR W CLRF SAWPF f, d f f, d Description Move constant to W Move W to f Move f Clear W Clear f Swap nibbles in f kW Wf fd 0W 0f f(7:4),(3:0) f(3:0),(7:4) Z Z Z Operation Flag Cycle 1 1 1 1 1 1 2 1,2 1, 2 Notes

First three instructions (look at the following table) provide for a constant being written in W register (MOVLW is short for MOVe Literal to W), and for data to be copied from W register onto RAM and data from RAM to be copied onto W register (or on the same RAM location, at which point only the

status of Z flag changes). Instruction CLRF writes constant 0 in 'f ' register, and CLRW writes constant 0 in register W. SWAPF instruction exchanges places of the 4-bit nibbles field inside a register.

Arithmetic and logic Of all arithmetic operations, PIC like most microcontrollers supports only subtraction and addition. Flags C, DC and Z are set depending on a result of addition or subtraction, but with one exception: since subtraction is performed like addition of a negative value, C flag is inverse following a subtraction. In other words, it is set if operation is possible, and reset if larger number was subtracted from a smaller one. Mnemonic ADDLW k ADDWF f, d SUBLW k SUBWF f, d ANDLW k ANDWF f, d IORLW k Description Add constant and W Add W and f Subtract W from constant Subtract W from 1 AND constant with W AND W with f OR constant with W OR W with f Exclusive OR constant with W Exclusive OR W with f Increment f Decrement f Rotate right f trough carry Rotate Left f trough carry Complement f Fd Operation W+1 W W+f d W-k W W-f d W .AND .k W W .AND .f d W .OR .k W W .OR .f d W .OR .k W W .XOR .f d F+1 f F-1 f Flag C,DC,Z C,DC,Z C,DC,Z C,DC,Z Z Z Z Z z Z Z Z Fd C Z Cycle 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1,2 1,2 1,2 1,2 1,2 1,2 1,2 1,2 1,2 1,2 Notes

IORWF f, d XORLW k XORWF f, d INCF DECF f, d f, d

COMF f, d RLF f, d

COMF f, d

Logic unit of PIC has capability of performing operations AND, OR, EX-OR, complementing (COMF) and rotation (RLF and RRF).

Instructions which rotate the register contents move bits inside a register through flag C by one space to the left (toward bit 7), or to the right (toward bit 0). Bit which "comes out" of a register is written in flag C, and value of C flag is written in a bit on the "opposite side" of the register.

Bit operations Instructions BCF and BSF do setting or cleaning of one bit anywhere in the memory. Even though this seems like a simple operation, it is executed so that CPU first reads the whole byte, changes one bit in it and then writes in the entire byte at the same place. Mnemonic BCF BSF f, b f, b Description Bit Clear f Bit Set f Operation 0 f(b) 1 f(b) Flag 1 1 Cycle 1,2 1,2 Notes

Directing a program flow Instructions GOTO, CALL and RETURN are executed the same way as on all other microcontrollers, only stack is independent of internal RAM and limited to eight levels.

Mnemonic BTFSC BTFSS f, b f, d

Description Bit Test f, Skip if Clear Bit Test f, Skip if Set Decrement f, Skip if 0 Increment f, Skip if 0 Go to address Call subroutine Return with subroutine Return with constant in W Return from interrupt

Operation Jump if f(b)=0 Jump if f(b)=1 f-1 d, jump if Z=1 f-1 d, jump if Z=0 W .AND .k W W .AND .f d W .OR .k W W .OR .f d W .OR .k W

Flag

Cycle 1 (2) 1 (2) 1 (2) 1 (2) 2 2 2 2 2

Notes 3 3 1,2,3 1,2,3

DECFSZ f, d INCFSZ f, d GOTO CALL k k

RETURN RETLW K RETFILE k

'RETLW k' instruction is identical with RETURN instruction, except that before coming back from a subprogram a constant defined by instruction operand is written in W register. This instruction enables us to design easily the Look-up tables (lists). Mostly we use them by determining data position on our table adding it to the address at which the table begins, and then we read data from that location (which is usually found in program memory).

Table can be formed as a subprogram which consists of a series of 'RETLW k' instructions, where 'k' constants are members of the table.

We write the position of a member of our table in W register, and using CALL instruction we call a subprogram which creates the table. First subprogram line ADDWF PCL, f adds the position of a W register member to the starting address of our table, found in PCL register, and so we get the real data address in program memory. When returning from a subprogram we will have in W register the contents of an addressed table member. In a previous example, constant 'k2' will be in W register following a return from a subprogram. RETFIE (RETurn From Interrupt - Interrupt Enable) is a return from interrupt routine and differs from a RETURN only in that it automatically sets GIE (Global Interrupt Enable) bit. Upon an interrupt, this bit is automatically cleared. As interrupt begins, only the value of program counter is put at the top of a stack. No automatic storing of register values and status is provided. Conditional jumps are synthesized into two instructions: BTFSC and BTFSS. Depending on a bit status in 'f' register that is being tested, instructions skip or don't skip over the next program instruction. Instruction Execution Period All instructions are executed in one cycle except for conditional branch instructions if condition was true, or if the contents of program counter was changed by some instruction. In that case, execution requires two instruction cycles, and the second cycle is executed as NOP (No Operation). Four oscillator clocks make up one instruction cycle. If we are using an oscillator with 4MHz frequency, the normal time for executing an instruction is 1 s, and in case of conditional branching, execution period is 2 s. Mnemonic NOP Description No Operation Clear Watchdog Timer Go into standby mode Clear Watchdog Timer Go into standby mode 0 WDT, 1 TO, 1 PD 0 WDT, 1 TO, 0 PD 0 WDT, 1 TO, 1 PD 0 WDT, 1 TO, 0 PD TO, PD TO, PD TO, PD TO, PD Operation Flag Cycle 1 1 1 1 1 Notes

CLRWDT SLEEP -

CLRWDT SLEEP -

Word list f W b d label TOS [] <> any memory location in a microcontroller work register bit position in 'f' register destination bit group of eight characters which marks the beginning of a part of the program top of stack option bit position inside register

*1 If I/O port is source operand, status on microcontroller pins is read *2 If this instruction is executed on TMR register and if d=1, prescaler assigned to that timer will automatically be cleared *3 If PC was modified, or test result =1, instruction was executed in two cycles.

TRENDS & ISSUES by Ronnel Joseph F. Cooper

Besides the usual increase of on-chip, integrated memory, the last few years show two more main areas of microcontroller development. The first concern is the operating speed. Although countless circuits are still provided with a 4-MHz crystal, the product catalogues from the Microchip. Atmel and Motorola are full with ICs that will function at 16 or 20 MHz Not that it is not that straightforward to just compare clock speeds. An ATmega128 from the HCS12 family from Motorola runs at 25 MHz but requires multiple clock cycles per instruction. The second main trend concerns the specialization of the internal peripherals. The UART and SPI interfaces have been common in the higher-end microcontrollers from most manufacturers for many years. But now more specialized interfaces are being added. Virtually all manufacturers support the integrated Circuit bus. Sometimes the interface operates only in the simplest slave mode, but more often than not, in master mode as well.

The USB (Universal Serial Bus) interface, popular because of the PC-market trends, is quickly making its entry into the microcontroller world. Microchip has the 16C745, the 765 and the future 18F2455, 255, etc. Atmel offers the AT91RM3400 and even Motorola has adapted a version of the old 6805, such as the 68HC705JBx.

PERIPHERALS The PIC microcontroller has many built in peripherals and this can make using them quite intimidating at first. The best way to start is to learn about the main features of a chip and then begin to use each peripheral in a project.

Note: These are some of the main features (some chips have all of these and THE USE OF MICROCONTROLLERS IN CARS BECOMING INCREASINGLY IMPORTANTsome don't). In AUTOMOTIVE Electronic systems have made a significant impact on the performance of the automobile. The demands of our global automotive customers create new challenges and opportunities for innovation. With many years of delivering embedded solutions to automotive customers globally, the innovative products from Microchip Technology enable solutions that are helping the automotive OEM deliver vehicles that have reduced fuel consumption with lower emissions and are safer and more comfortable. The products and processes of Microchip Technology are designed to support the precise requirements of the automotive customer.

SOME APPS OF PIC MICROCONTROLLER

IN HOME APPLIANCES INTELLIGENT POWER SUPPLY DESIGN Today, power supply designers must create power conversion products that offer greater efficiency, higher power density, higher reliability, advanced communications and advanced control features. And as always these products need to be developed and marketed quickly and at lower costs. Microchip offers a comprehensive set of Intelligent Power Supply solutions enabling designers to meet these challenges.

LIGHTING APPLICATION Many lighting applications require some form of communication for remote control but also for diagnostic purposes.

MEDICAL DESIGN CENTER The pace of innovation in the development of electronic medical devices is nothing short of revolutionary. Microchips products and experience have helped hundreds of the worlds top medical device companies take their ideas from future vision to market reality.

MOTOR CONTROL DESIGN

They are also used for : UTILITY METERING (for GAS, HEAT, WATER & ELECTRICITY), WIRED CONNECTIVITY (USB, Ethernet) and WIRELESS Connectivity (Radio Frequency, Infrared and Security and Authentication), MechaTronics

ADD VOICE OR AUDIO FEATURES IN YOUR APPS Human Interfacing Voice continues to be a popular and natural medium of communication and human interface. Interfacing embedded applications using voice in local languages can help cater products to regional needs. Audio can also help interfacing electronics to the visually impaired.

ISSUES REGARDING PIC MICRO Microchip Technology Jumps to Number One in Worldwide 8-bit Microcontroller Shipments PIC microcontroller shipments grow 30 percent despite industry downturn CHANDLER, Ariz., July 7, 2003 Microchip Technology (Nasdaq: MCHP) has secured the number one position in worldwide 8-bit microcontroller unit shipments, according to industry analyst Gartner Dataquests recently released 2002 Microcontroller Market Share and Unit Shipments report. From 2001 to 2002, unit sales for Microchips PIC microcontrollers grew 30 percent, despite challenging business conditions, to attain the number one ranking. Todays announcement demonstrates the dramatic growth and market acceptance Microchips proprietary PIC microcontroller architecture has achieved since the companys inception in 1989. According to the yearly Gartner Dataquest rankings, Microchip placed 20th in worldwide unit shipments in 1990, rising steadily to eighth in 1993, fifth in 1996, second in

1997 through 2001 and now number one in 2002. Today Microchip serves more than 40,000 customers in the consumer, automotive, industrial control, office automation and communications market. The PIC microcontroller architecture is driven by a modified Harvard RISC (Reduced Instruction Set Computing) instruction set that provides an easy migration path from 8- to 84pins and from 1K byte to 128K bytes of program data memory. Today, Microchip offers more than 180 PIC devices in reprogrammable (Flash), one-time-programmable (OTP), and read-only memory (ROM) program memory configurations, featuring numerous on-chip peripherals. Microchip became number one by pioneering the field programmable segment of the 8-bit microcontroller market with one-time-programmable (OTP) and Flash microcontrollers leadership," said Microchips CEO and President, Steve Sanghi. "Leading engineers worldwide continue to use the PIC microcontroller architecture because we provide a competitive advantage to their own businesses with faster time to market, lower total system cost and lowrisk product development." Mitch Little, vice president of Worldwide Sales at Microchip Technology said, This ranking is the result of the sustained focus we bring to embedded control applications, the superb execution over many years by the worldwide Microchip team, and the continued endorsement of our PIC microcontroller by our customers. Our unique corporate culture brings business values such as high quality, consistent on-time delivery, comprehensive technical support and a competitive price make up the core foundation of our business. Our deepest gratitude to our worldwide customers and distribution partners for enabling this number one ranking to occur. Microchip provides world-class easy-to-use development tools, allowing engineers to design quickly and efficiently with PIC microcontrollers. Microchip features a broad portfolio of easy-to-learn development tools to support its PIC microcontrollers: programmers, in-circuit emulators, C compilers, in-circuit debuggers, assemblers, editors, linkers, simulators, librarians and more. Engineers can manage all related Microchip development tools from the single MPLAB Integrated Development Environment (IDE) platform. With a common core of development tools, Microchip customers can easily transition to new microcontrollers without having to purchase and learn new development tools.

MICROCHIP TECHNOLOGY AND ON SEMICONDUCTOR PROPOSE TO ACQUIRE ATMEL FOR $5.00 PER SHARE IN CASH Provides Premium of 52.4% and Values Atmel at $2.3 Billion Chandler and Phoenix, Arizona, October 2, 2008 Microchip Technology Incorporated (NASDAQ: MCHP) and ON Semiconductor Corporation (NASDAQ: ONNN) today announced that they have sent a proposal to the Board of Directors of Atmel Corporation (NASDAQ: ATML) to acquire Atmel for $5.00 per share in cash. The proposal, which is being led by Microchip, provides a premium of 52.4% to Atmels closing price of $3.28 on October 1, 2008, and values Atmel at $2.3 billion. The proposal, which is being led by Microchip, provides a premium of 52.4% to Atmels closing price of $3.28 on October 1, 2008, and values Atmel at $2.3 billion.

About Microchip Technology Microchip Technology Incorporated (NASDAQ: MCHP) is a leading provider of microcontroller and analog semiconductors, providing low-risk product development, lower total system cost and faster time to market for thousands of diverse customer applications worldwide. Headquartered in Chandler, Ariz., Microchip offers outstanding technical support along with dependable delivery and quality. For more information, visit the Microchips website at www.microchip.com. About ON Semiconductor With its global logistics network and strong product portfolio, ON Semiconductor Corporation (NASDAQ: ONNN) is a preferred supplier of high performance, energy efficient, silicon solutions to customers in the power supply, automotive, communication, computer, consumer, medical, industrial, mobile phone, and military/aerospace markets. The companys broad portfolio includes power, analog, DSP, mixed-signal, advance logic, clock management and standard component devices. Global corporate headquarters are located in Phoenix, Arizona. The company operates a network of manufacturing facilities, sales offices and design centers in key markets throughout North America, Europe, and the Asia Pacific regions. For more information, visit http://www.onsemi.com.

MICROCHIP ENDS ATTEMPTS TO ACQUIRE ATMEL Microchip launched its bid for Atmel valued at $2.3 billion in early October 2008, with its partner in the proposal, ON Semiconductor, signed on to buy Atmels nonvolatile memory and RF and automotive businesses. Atmel rejected the bid in late October, claiming that the $5 per share bid undervalued its future potential and noting its transformation plan, which includes fab closures and other cost-cutting measures. In November, as the full weight of the global financial crisis became more evident, ON Semi backed out of the proposal. Microchip at that time said it would consult with its board and advisors to determine their next steps in due course. In this most recent move, Microchip has also withdrawn the slate of directors it had nominated previously for election at Atmels next annual meeting of shareholders. The global economy and the semiconductor business environment have deteriorated significantly since Microchip first made an offer of $5 per share on October 1, 2008," said Steve Sanghi, president, CEO, and chairman of Microchip, in a statement. "In light of the economic uncertainty and the lack of visibility that continues to exist with respect to Atmels business, Microchip is no longer able to put a value on Atmel. Microchip will therefore terminate consideration of a potential acquisition of Atmel. Atmel said with Microchip's withdrawal it will focus exclusively on its transformation plan. "Atmels substantial microcontroller revenue growth, market share gains and gross profit improvement demonstrate the significant progress we are making on this plan," the company said in a statement. "As announced on February 4, Atmels microcontroller revenues grew 14% in 2008 and full-year gross profit margins reached the highest level since 2000. As we enter the next phase of Atmels transformation plan, we remain confident that we are on the right track to further enhance shareholder value."

MICROCHIP TECHNOLOGY TO PRESENT AT THE MORGAN KEEGAN & COMPANY 2011 TECH CONFERENCE CHANDLER, Arizona August 8, 2011 -- (NASDAQ:MCHP) Microchip Technology Incorporated, a leading provider of microcontroller, analog and Flash-IP solutions, announced today that the Company will present at the Morgan Keegan 2011 Tech Conference on Tuesday, August 9, 2011 at 11:10 a.m.

(Eastern Time). Presenting for the Company will be Mr. Gordon Parnell, Vice President, Business Development & Investor Relations. A live webcast of the presentation will be made available by Morgan Keegan, and can be accessed on the Microchip website at www.microchip.com.

MICROCHIP LAUNCHES PIC32 BOARD FOR GUI DEVELOPMENT WITHOUT AN EXTERNAL GRAPHICS CONTROLLER Low-Cost, Controller less Graphics Board Enables 65K (16-bit-per-pixel)-Color Graphical User Interfaces CHANDLER, Ariz., Aug. 8, 2011 [NASDAQ: MCHP] Microchip Technology Inc., a leading provider of microcontroller, analog and Flash-IP solutions, today announced the Low-Cost Controllerless (LCC) Graphics PICtail Plus Daughter Board (part # AC164144), which enables the development of graphics applications without an external graphics controller. Low-Cost, Controller less Graphics Board Enables Developers to Directly Drive 65K (16-bit-per-pixel)-Color Graphical User Interfaces CHANDLER, Ariz., Aug. 8, 2011 [NASDAQ: MCHP] Microchip Technology Inc., a leading provider of microcontroller, analog and Flash-IP solutions, today announced the Low-Cost Controllerless (LCC) Graphics PICtail Plus Daughter Board (part # AC164144), which enables the development of graphics applications without an external graphics controller. Developers to Directly Drive

You might also like