PROGRAMMING AND CUSTOMIZING THE PIC MICROCONTROLLER 3rd phần 3 ppsx

130 416 0
PROGRAMMING AND CUSTOMIZING THE PIC MICROCONTROLLER 3rd phần 3 ppsx

Đ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 EMU-II 233 Msg3 ; Introductory Message dw 0x02280,0x03A6E,0x03965,0x013A0,0x013C8,0x03320,0x0396F,0x021A0 dw 0x036EF,0x030ED,0x0326E,0x06F3,0x0A Msg4 ; “Help” Message dw 0x03454,0x01065,0x037C3,0x036ED,0x03761,0x039E4,0x030A0,0x032F2 dw 0x06BA dw 0x0100A,0x01048,0x0102D,0x032C8,0x0386C,0x050D dw 0x02220,0x016A0,0x02220,0x03BEF,0x0366E,0x030EF,0x01064,0x03841 dw 0x03670,0x031E9,0x03A61,0x037E9,0x06EE dw 0x0100A,0x01021,0x0225B,0x020FC,0x0105D,0x0102D,0x032D2,0x032F3 dw 0x01074,0x03474,0x01065,0x036C5,0x03675,0x03A61,0x03265,0x02820 dw 0x037F2,0x032E3,0x039F3,0x0396F,0x029AF,0x03A65,0x03A20,0x032E8 dw 0x02820,0x0294F,0x020D4,0x02A20,0x03879,0x06E5 dw 0x0100A,0x018DB,0x02DA0,0x03241,0x03964,0x039E5,0x02EF3,0x0105D dw 0x0102D,0x034D3,0x033EE,0x032EC,0x029A0,0x032F4,0x01070,0x03966 dw 0x036EF,0x03A20,0x032E8,0x021A0,0x03975,0x032F2,0x03A6E,0x02820 dw 0x01043,0x03241,0x03964,0x039E5,0x01073,0x0396F,0x029A0,0x032F0 dw 0x034E3,0x034E6,0x03265,0x020A0,0x03264,0x032F2,0x039F3,0x050D dw 0x02520,0x02DA0,0x03241,0x03964,0x039E5,0x02EF3,0x016A0,0x029A0 dw 0x03769,0x03667,0x01065,0x03A53,0x03865,0x0252F,0x036F5,0x01070 dw 0x03B4F,0x03965,0x021A0,0x03661,0x0106C,0x03A53,0x03A61,0x036E5 dw 0x03765,0x06F4 dw 0x0100A,0x01047,0x020DB,0x03264,0x032F2,0x039F3,0x0105D,0x0102D dw 0x03A53,0x03961,0x01074,0x03841,0x03670,0x031E9,0x03A61,0x037E9 dw 0x0106E,0x03C45,0x031E5,0x03A75,0x03769,0x06E7 dw 0x0100A,0x01049,0x03241,0x03964,0x039E5,0x01073,0x0102D,0x032D3 dw 0x01074,0x03474,0x01065,0x03749,0x03A73,0x03AF2,0x03A63,0x037E9 dw 0x0106E,0x037D0,0x03769,0x032F4,0x01072,0x050D dw 0x02920,0x016A0,0x02220,0x039E9,0x03670,0x03CE1,0x03A20,0x032E8 dw 0x02820,0x034F2,0x030ED,0x03CF2,0x029A0,0x032F0,0x034E3,0x03661 dw 0x02320,0x03775,0x03A63,0x037E9,0x0106E,0x032D2,0x034E7,0x03A73 dw 0x03965,0x06F3 dw 0x0100A,0x01053,0x032D2,0x020E7,0x03264,0x032F2,0x039F3,0x016A0 dw 0x029A0,0x037E8,0x01077,0x037C3,0x03A6E,0x03765,0x039F4,0x037A0 dw 0x01066,0x01B31,0x02920,0x033E5,0x039E9,0x032F4,0x039F2,0x029A0 dw 0x030F4,0x03A72,0x03769,0x01067,0x03A61,0x03A20,0x032E8,0x029A0 dw 0x032F0,0x034E3,0x034E6,0x03265,0x020A0,0x03264,0x032F2,0x039F3 dw 0x050D dw 0x022A0,0x02920,0x033E5,0x03241,0x03964,0x039E5,0x01073,0x0102D dw 0x037CC,0x03261,0x03A20,0x032E8,0x02920,0x033E5,0x039E9,0x032F4 dw 0x01072,0x034F7,0x03474,0x03720,0x03BE5,0x02220,0x03A61,0x06E1 dw 0x0100A,0x01042,0x020DB,0x03264,0x032F2,0x039F3,0x0105D,0x0102D dw 0x037D4,0x033E7,0x032EC,0x03A20,0x032E8,0x02120,0x032F2,0x035E1 dw 0x037F0,0x03769,0x01074,0x03241,0x03964,0x039E5,0x06F3 dw 0x0100A,0x01043,0x0102D,0x03643,0x030E5,0x01072,0x03661,0x0106C dw 0x03474,0x01065,0x03942,0x030E5,0x0386B,0x034EF,0x03A6E,0x06F3 dw 0x0100A,0x01055,0x020DB,0x03264,0x032F2,0x039F3,0x0105D,0x0102D dw 0x034C4,0x03873,0x030EC,0x01079,0x01A32,0x02620,0x03769,0x039E5 dw 0x037A0,0x01066,0x03749,0x03A73,0x03AF2,0x03A63,0x037E9,0x039EE Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 234 EMULATORS AND DEBUGGERS dw 0x050D dw 0x015AA,0x02DA0,0x03241,0x03964,0x039E5,0x02EF3,0x016A0,0x020A0 dw 0x03264,0x024A0,0x039EE,0x03974,0x031F5,0x034F4,0x0376F,0x01073 dw 0x037F4,0x03A20,0x032E8,0x02820,0x037F2,0x03967,0x036E1,0x026A0 dw 0x036E5,0x0396F,0x06F9 dw 0x0150A,0x01050,0x022DB,0x0237C,0x0105D,0x0102D,0x03950,0x033EF dw 0x030F2,0x0106D,0x022C5,0x02950,0x026CF,0x037A0,0x01072,0x03646 dw 0x039E1,0x01068,0x024D0,0x036C3,0x031E9,0x037F2,0x026A0,0x02AC3 dw 0x050D dw 0x02B2A,0x016A0,0x02B20,0x03965,0x03369,0x01079,0x03474,0x01065 dw 0x037C3,0x03A6E,0x03765,0x039F4,0x037A0,0x01066,0x03474,0x01065 dw 0x024D0,0x036C3,0x031E9,0x037F2,0x026A0,0x02AC3,0x050D dw 0x00 ;#CompStart Admittedly, this is a lot harder to understand than the ASCII text above (especially with the high order byte having to be shifted down by seven to read it), but it cuts the instruction requirements in half for the application text files. DT Compress is a Windows GUI application that simply allows a user to select an assembler (.asm) file and then converts it into a compressed include (.inc) file. Depending on the amount of text to compress, the application may take a few seconds to run (it takes five seconds to do the EMU-II compress.asm file on my 300 MHz Pentium-II PC). To read and output the compressed file, I created the subroutine: SendMsg ; Call Here for sending a specific ; message string to the Serial port. ; The Message Number is in “w” movwf MsgTemp ^ 0x0100 ; Save the Message Number clrf MsgOffset ^ 0x0100 ; Reset the clrf (MsgOffset + 1) ^ 0x0100 clrf SMCount ^ 0x0100 ; Clear Count of Output Bytes MT_Loop1 ; Loop Here Until “MsgTemp” is == 0 movf MsgTemp ^ 0x0100, f ; Is “MsgTemp” Equal to Zero? btfsc STATUS, Z goto MT_Loop2 ; Yes, Start Displaying Data bcf STATUS, C ; Calculate Address of Next Word to rrf (MsgOffset + 1) ^ 0x0100, w ; Display addlw HIGH MsgTable movwf EEADRH ^ 0x0100 rrf (MsgOffset + 1) ^ 0x0100, w ; Setup Carry Correctly for rrf MsgOffset ^ 0x0100, w ; Increment addlw LOW MsgTable movwf EEADR ^ 0x0100 btfsc STATUS, C incf EEADRH ^ 0x0100, f ; If Carry Set, Increment to Next Page EEPReadMacro ; Now, Do the Program Memory Read Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com THE EMU-II 235 rlf EEDATA ^ 0x0100, w ; Start with the Odd Byte rlf EEDATH ^ 0x0100, w btfss MsgOffset ^ 0x0100, 0 ; Odd or Even Byte? movf EEDATA ^ 0x0100, w ; Even Byte andlw 0x07F ; Convert to ASCII 7 Bits btfsc STATUS, Z decf MsgTemp ^ 0x0100, f ; Decrement the Value Count incf MsgOffset ^ 0x0100, f ; Point to the Next Byte in the String btfsc STATUS, Z incf (MsgOffset + 1) ^ 0x0100, f goto MT_Loop1 MT_Loop2 ; Have Correct Offset, Now, Display the ; Message bcf STATUS, C ; Calculate Address of Next Word to rrf (MsgOffset + 1) ^ 0x0100, w ; Display addlw HIGH MsgTable movwf EEADRH ^ 0x0100 rrf (MsgOffset + 1) ^ 0x0100, w ; Setup Carry Correctly for rrf MsgOffset ^ 0x0100, w ; Increment addlw LOW MsgTable movwf EEADR ^ 0x0100 btfsc STATUS, C incf EEADRH ^ 0x0100, f ; If Carry Set, Increment to Next Page EEPReadMacro ; Now, Do the Program Memory Read rlf EEDATA ^ 0x0100, w ; Start with the Odd Byte rlf EEDATH ^ 0x0100, w btfss MsgOffset ^ 0x0100, 0 ; Odd or Even Byte? movf EEDATA ^ 0x0100, w ; Even Byte andlw 0x07F ; Convert to ASCII 7 Bits btfsc STATUS, Z goto MT_End ; Zero, Yes SendCharMacro incf MsgOffset ^ 0x0100, f ; Point to the Next Byte in the String btfsc STATUS, Z incf (MsgOffset + 1) ^ 0x0100, f incf SMCount ^ 0x0100, f goto MT_Loop2 MT_End ; Finished sending out the Table Data movf SMCount ^ 0x0100, w ; Return the Number of Bytes Sent EmuReturn In this code there are three macros. The EEPReadMacro (along with the EEPWriteMacro) is used to access the Flash program memory of the PIC16F87x. SendCharMacro is used to poll the UART transmit holding register empty interrupt request flag (TXIF of PIR1) and send the byte when the holding register is open. The macro code is: Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 236 EMULATORS AND DEBUGGERS SendCharMacro Macro bcf STATUS, RP1 ifndef Debug btfss PIR1, TXIF goto $ - 1 else goto $ + 3 ; Put in a Skip over the “nop” to save nop ; a Mouse Click endif movwf TXREG ; Send the Byte bcf PIR1, TXIF ; Reset the Interrupt Request Flag bsf STATUS, RP1 endm and it should be noted that if the label Debug is defined, the polling loop is ignored because in MPLAB, the USART hardware is not simulated and execution will never fall out of this loop. There are two other things to notice about this macro. The first is in the code that exe- cutes when the Debug label is defined. I kept two instructions to match the btfss/goto instructions of the polling loop, but I jump over the second one to save a mouse click when I’m single-stepping through the application. This might seem like a petty place to save a mouse click or two, but SendCharMacro is used a lot in this application, and when single-stepping through the application, skipping over the instructions seems to reduce the number of mouse clicks significantly. The second point to notice about this macro is that it changes the operating bank from 2 to 0 and then back to 2. The EMU-II application has all its variables in Banks 2 and 3 of the PIC microcontroller. This allows the user to access almost all the registers (except for the USART specific ones) in Banks 0 and 1 without affecting the operation of the EMU-II in any way. Instead of using the call and return instructions in the EMU-II, I used two macros, EmuCall and EmuReturn, which I wrote to implement a subroutine call that does not access the built-in program counter stack. The reason for writing these sub- routines was to avoid the possibility that the subroutine calls in the EMU-II application code would affect the emulated application. The EmuCall and EmuReturn macros are: EmuCall Macro Address ; Stackless Emulator Call local ReturnAddr movwf tempw ^ 0x0100 ; Save the Call Value in “w” incf FSR, f movlw LOW ReturnAddr ; Setup the Return Address movwf INDF incf FSR, f movlw HIGH ReturnAddr movwf INDF movlw HIGH Address ; Jump to the Specified Address movwf PCLATH Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com THE EMU-II 237 movf tempw ^ 0x0100, w ; Restore “w” before doing it goto (Address & 0x07FF) | ($ & 0x01800) ReturnAddr movf tempw ^ 0x0100, w ; restore the “w” from the Subroutine endm EmuReturn Macro ; Return from the Macro Call movwf tempw ^ 0x0100 ; Save the Temporary “w” Register movf INDF, w ; Get the Pointer to the Return Address movwf PCLATH decf FSR, f ; Point to the Low Byte of the ; Return Address movf INDF, w decf FSR, f movwf PCL ; Jump to the Return Address endm This will save the return address in a data stack implemented with the FSR register. This address is then used to return to the calling section of code. These macros are reasonably efficient, but it should be noted that they do affect the state of the zero flag in the STATUS register and they do take up a number of instruc- tions. The number of instructions taken up by the subroutine calls is why I created other macros, like EEPReadMacro and SendCharMacro, which actually require fewer instructions to implement the required function than the EmuCall macro. The last aspect of the application that I would like to bring to your attention is how I implemented the breakpoints for application single-stepping and breakpoints. As I pointed out above, if I were to use multiple instructions for breakpoints, then code like: btfss PIR1, TXIF ; Poll until USART Free to Send a goto $ - 1 ; Character movwf TXREG ; Output the character in “w” will not be able to be stepped through. The approach I took was to create a single-step (and breakpoint) mechanism that would not have problems with these situations. By limiting application size to one page, I can use a single goto instruction for implementing the return to the EMU-II application code. For example, if I was single-stepping at the btfss instruction in the example above, the EMU-II code would put in the breakpoints shown below: btfss PIR1, TXIF ; Poll until USART Free to Send a goto NextStep ; Was “goto $ - 1” goto SecondStep ; Was “movwf TXREG” Now, depending on the value of TXIF, execution will return to the EMU-II code via the goto NextStep or goto SecondStep, which in either case is located in the instruction code area 0x700 to 0x7FF. NextStep and SecondStep are separate Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 238 EMULATORS AND DEBUGGERS from each other in order for the correct new program counter value to be noted and recorded by the EMU-II application. The NextStep, SecondStep, and breakpoint code is similarly designed and uses the following instructions: Step # ; “#” is from 0 to 8 for Breakpoints movwf _w ; Save the “w” Register movf STATUS, w ; Save STATUS and Change to Bank 2 bsf STATUS, RP1 ; Execute from Page 2 in EMU-II bcf STATUS, RP0 movwf _status ^ 0x100 movf PCLATH, w ; Save the PCLATH Registers movwf _pclath ^ 0x100 movlw # * 2 ; Save the Breakpoint Number gotom StopPoint AddressIns # dw 0x3FFF ; Address of the Breakpoint/Single Step dw 0x3FFF ; Instruction at Breakpoint/Single Step The two words at the end of the breakpoint are used to save the address where the breakpoint was stored and the original instruction. The breakpoint address is used to update the EMU-II’s program counter along with replacing the goto Step # instruction with the application’s original instruction. Before any type of execution, all the enabled breakpoints are put into the application pro- gram memory. Upon completion of execution, the application program memory is scrubbed for all cases of breakpoint gotos and they are restored with the original instructions. Note that when setting up single-step breakpoints, the next instruction or destination of a goto or call is given the goto NextStep and goto SecondStep break- points. This is possible for all instructions instead of return, retlw, and retfie. The reason for these three instructions to get an error message during single-stepping is that the destination cannot be taken from the processor stack. Instead of putting a break- point at potentially every address in the application, I decided to simply prevent single- stepping at these instructions. As applications may be halted by pressing the Reset button in the application, when the EMU-II first boots up, the scrub operation takes place to ensure that there are not any invalid gotos left in the application. There are a few things to watch out for with breakpoints and interrupts. For most appli- cation debugging, I do not recommend setting breakpoints within the interrupt handler. The reason for this is to avoid any missed interrupt requests or having multiple requests queued up in such a way that the application’s mainline never returns. I originally thought that this was a limitation of the EMU-II, but I tried some experiments with MPLAB-ICD and found that it also has similar issues. Interrupt handlers should always be debugged as thoroughly as possible using a simulator so as to not miss or overflow on any interrupt events and requests. This is not to say that simple applications (such as just waiting for a TMR0 overflow) cannot be used with the EMU-II. In testing out the application, I did work through a Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com THE EMU-II 239 number of experiments with interrupt handlers without problems. There is one point I should make clear to you: breakpoints should never be enabled in both an interrupt handler and mainline code. If an interrupt breakpoint is executed while a mainline breakpoint is being handled by the EMU-II, the mainline breakpoint context registers will be changed to the values of the interrupt handler. The execution of the application may also become erratic. If you are debugging an application that requires breakpoints in both the interrupt han- dler and mainline code, I recommend setting only one at a time and using the C (break- point all clear) command before setting the next breakpoint. The Emu-II includes a simple disassembler for reviewing the source code. A typical unassembled application is shown in Fig. 5.15, and there are two things I want to point out about the disassembled function. The first point to make about the disassembled code is the lack of useful labels. If you were to look at the disassembled code you would see that constant and variable names are not output which makes it much more difficult to read. movlw 0x0FF movwf PORTB ; Turn off all the LED’s clrf PORTA ; Use PORTA as the Input bsf STATUS, RP0 ; Have to go to Page 0 to set Port ; Direction Note “TMR0” - Should be “OPTION_REG” Figure 5.15 EMU-II unassembly display showing how a Bank 1 register is displayed with a Bank 0 label. Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 240 EMULATORS AND DEBUGGERS clrf TRISB & 0x07F ; Set all the PORTB bits to Output movlw 0x0D2 ; Setup the Timer to fast count ; Put in Divide by 8 Prescaler for 4x movwf OPTION_REG & 0x07F ; Clock bcf STATUS, RP0 ; Go back to Page 0 movlw TRISA ; Have to Set/Read PORTA.0 movwf FSR Loop: bsf PORTA, 0 ; Charge Cap on PORTA.0 bcf INDF, 0 ; Make PORTA.0 an Output movlw 0x0100 - 10 ; Charge the Cap clrf TMR0 ; Now, Wait for the Cap to Charge Sub_Loop1: ; Wait for the Timer to Reach 10 movf TMR0, w ; Get the Timer Value btfss STATUS, Z ; Has the Timer Overflowed? goto Sub_Loop1 ; No, Loop Around again bsf INDF, 0 ; Now, Wait for the Cap to Discharge clrf TMR0 ; and Time it. Sub_Loop2: ; Just wait for PORTA.1 to go Low btfsc PORTA, 0 goto Sub_Loop2 comf TMR0, w ; Get the Timer Value This is an excellent example of why I prefer only using source code enabled develop- ment tools. Trying to get the function of the application from Fig. 5.15 is just about impos- sible, but when you look at the source, the function that it implements—potentiometer measuring code with an RC delay circuit—is quite obvious. The second problem with what is pointed out in Fig. 5.15 is that the disassembler doesn’t know what bank is currently executing. In Fig. 5.15, you should see that the TRISB register, when it is enabled for all output, is referenced as PORTB (line 5 of the code). This is not a big problem and one that I can usually work my way through without any problems. What I find to be very confusing in Fig. 5.15 is the identification of TMR0 when I want OPTION_REG (or OPTION as it is displayed by the EMU-II). As you step through the application, you will discover that the instruction on the prompt line will display the instruction based on the state of the RP0 bit of the emulated device’s STATUS register. While application code can be downloaded to the Emu-II, it cannot be uploaded into a PC. This was specifically not implemented to discourage the practice of modifying an application in the emulator and then uploading the hex file into the host PC and repli- cating the application from this source. This is a very dangerous practice and should be avoided at all costs to prevent the proliferation of executable code without supporting application code. Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com OTHER EMULATORS 241 The Emu-II is probably the most involved application that you will find in this book. I am pleased with the way it came out and it is a very interesting project and tool to have while learning about the PIC microcontroller. I don’t think that it is adequate as a pro- fessional development tool due to the lack of a source code interface, but for very simple applications this emulator can be an invaluable tool for you to learn about the PIC microcontroller. Other Emulators While there are a number of very good PIC microcontroller emulators designed and mar- keted by third parties, there hasn’t been the same explosion of designs as with PIC micro- controller programmers by hobbyists. The reason for this really comes down to the complexity of work required to develop an emulator circuit along with the difficulty of developing a user interface for them. The Emu-II is a very simple example of how an emulator could work with a very basic user interface that does not contain many of the features I would consider critical for using an emulator in a professional environment. A professional product would require a bondout chip and a source/listing file interface for the user to use it effectively. Other features would include providing a high-speed interface to avoid the time required to download application hex files into the Emu-II. If you are interested in designing your own full emulator, you will have to talk to your local Microchip representative to find out about entering into a nondisclosure agreement (NDA) with them to learn more about the options Microchip has for developing emu- lators for their products. Microchip does make bondout chips available for all of the PIC microcontroller part numbers, but technical information about them is considered pro- prietary and not for general release. Partial emulators (like the Emu-II) are still a lot of work to get running, but designing them gives you a much better appreciation of how the PIC microcontroller works. If you are interested in designing your own, please take a look at the code in the Emu-II to see how the various issues of executing an application from within a PIC microcontroller monitor are handled. Having said there are few commercial emulators available, I should point out that there are a number of products you can buy. These commercial emulators provide wide ranges of services and can be bought for a few hundred dollars up to $1,000 or more for a full bondout chip-based complete system. Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com This page intentionally left blank Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com [...]... it is the Index When specifying the array variable and element in the PIC microcontroller, the offset to the start of the array variable has to be added to the element number to get the register address within the PIC microcontroller Thus, to carry out the array increment operation shown above in the PIC microcontroller, the following steps would have to be taken: w = Index; w = w + Array; // The Element... processor into the program counter In Fig 6.15, the addwf PCL, f instruction, which adds the current value in PCL to the contents of the w register and puts the result back into the program counter, is shown In the diagram, you can see that the PCLATH bits are combined with the data coming out of the ALU after the addition operation and then are passed back to the 13- bit counter (the actual PIC microcontroller. .. sleep _MCLR is the PIC microcontroller s negatively active master clear or reset pin Negatively active means that when the pin is pulled to ground, it makes the reset circuit active, stops the internal PIC microcontroller oscillator, reinitializes the PIC microcontroller hardware, and holds the PIC microcontroller in an inactive state until the _MCLR line goes high again The typical PIC microcontroller. .. chapter The program counter maintains the current program instruction address in the program memory (which contains the instructions for the PIC microcontroller processor, each one of which is read out in sequence and stored in the instruction reg and then decoded by the instruction decode and control circuitry The program memory contains the code that is executed as the PIC microcontroller application The. .. register in the PIC1 7 and PIC1 8 devices Every arithmetic operation that takes place in the PIC microcontroller uses the w register If you want to add the contents of two registers together, you would first move the contents of one register into the w register and then add the contents of the second to it The PIC microcontroller architecture is very powerful from the perspective that the result of this operation... understand when they first start working with PIC microcontrollers is the register banks used in the different PIC microcontroller architectures The number of registers available for direct addressing in the PIC microcontroller is limited to the number of address bits in the instruction that are devoted to specifying register access In low-end PIC microcontrollers there are only 5 bits (for a total of 32 ... gotos or writes to the PIC microcontroller s program counter except that before the program counter is updated, it is pushed into the stack The value pushed onto the stack is not the address of the call instruction but the address of the instruction after the call—which is the return address for the subroutine In virtually all processors (the PIC microcontroller included), as soon as the instruction is... different in each of the PIC microcontroller architectures, but they all have the same 3 bits of data after arithmetic and bitwise operations The 3 bits (or flags) that are set or reset depending on the result of the arithmetic or bitwise operation are the carry, digit carry, and zero bits These bits are often referred to as the execution status flags (Z, DC, and C) The zero flag (Z) is set when the result of... address as the source is used for the destination This capability gives you the option of performing an operation without changing the value saved in either the w register or the source register The obvious use of this feature is to subtract two values without saving the result and to place the important parts of the result (the arithmetic flag registers) into the STATUS bits and ignore the result of the subtraction... as the destination, then the result is stored in the w register If f (or 1) is specified, then the result of the addition instruction is stored in register This is one of the most confusing and powerful concepts of the PIC microcontroller and can be a problem for many new PIC microcontroller programmers The ability to immediately store an arithmetic operation’s result is unusual in 8-bit processors and . 0x0102D,0x 034 D3,0x 033 EE,0x 032 EC,0x029A0,0x 032 F4,0x01070,0x 039 66 dw 0x 036 EF,0x03A20,0x 032 E8,0x021A0,0x 039 75,0x 032 F2,0x03A6E,0x02820 dw 0x010 43, 0x 032 41,0x 039 64,0x 039 E5,0x010 73, 0x 039 6F,0x029A0,0x 032 F0 dw 0x 034 E3,0x 034 E6,0x 032 65,0x020A0,0x 032 64,0x 032 F2,0x 039 F3,0x050D dw. 0x0 232 0,0x 037 75,0x03A 63, 0x 037 E9,0x0106E,0x 032 D2,0x 034 E7,0x03A 73 dw 0x 039 65,0x06F3 dw 0x0100A,0x010 53, 0x 032 D2,0x020E7,0x 032 64,0x 032 F2,0x 039 F3,0x016A0 dw 0x029A0,0x 037 E8,0x01077,0x 037 C3,0x03A6E,0x 037 65,0x 039 F4,0x 037 A0 dw 0x01066,0x01B31,0x02920,0x 033 E5,0x 039 E9,0x 032 F4,0x 039 F2,0x029A0 dw. 0x01066,0x01B31,0x02920,0x 033 E5,0x 039 E9,0x 032 F4,0x 039 F2,0x029A0 dw 0x 030 F4,0x03A72,0x 037 69,0x01067,0x03A61,0x03A20,0x 032 E8,0x029A0 dw 0x 032 F0,0x 034 E3,0x 034 E6,0x 032 65,0x020A0,0x 032 64,0x 032 F2,0x 039 F3 dw 0x050D dw

Ngày đăng: 12/08/2014, 23:21

Từ khóa liên quan

Mục lục

  • Contents

  • Introduction

  • Acknowledgments

  • Chapter 1 Embedded Microcontrollers

    • Microcontroller Types

    • Internal Hardware

    • Applications

    • Processor Architectures

    • Instructions and Software

    • Peripheral Functions

    • Memory Types

    • Microcontroller Communication

    • Device Packaging

    • Application Development Tools

    • Chapter 2 The Microchip PIC Microcontroller

      • Accessing the Microchip Web Site

      • PIC Microcontroller Feature Summary

      • Features Unique to the PIC Microcontroller

      • PIC Microcontroller Families

      • Chapter 3 Software Development Tools

        • Tools Overview

        • High Level Languages

        • Microchip MPLAB IDE

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

Tài liệu liên quan