Lecture 3 1 2 Status Register The STATUS
- Slides: 29
Lecture 3 1
2
Status Register • The STATUS register contains – Arithmetic status of the ALU – RESET status – Bank select bit for data memory. • As with any register, the STATUS register can be the destination for any instruction. 3
4
Status Register • Z, DC, C, TO and PD bits are not writable. – These bits are set or cleared according to device logic. • For example, CLRF STATUS will clear the upper-three bits and set the Z bit. This leaves the STATUS register as 000 u u 1 uu (where u = unchanged). • Only the BCF, BSF, SWAPF and MOVWF instructions should be used to alter the STATUS register because these instructions do not affect any status bit. 5
PIC Instruction Set • The instruction set for the PIC 16 F 84 consists of 35 single word instructions • These are grouped into three major categories – Byte-oriented – Bit-oriented – Literal and control 6
7
List and Equates • Before writing your program, you need to describe the type of device that the program is to be burned to List p=16 F 84 • Equate – Similar to variable declaration in other programming languages. – Labels are assigned to addresses. Later, whenever that label is referred to in the program, the compiler looks up its address. • E. g. Assigns ‘port. B’ to the file register located at 0 x 06. Port B is always located at this file register. port. B equ 0 x 06 8
Sample Program LIST P=16 F 84 PORTB equ 0 x 06 TRISB equ 0 x 06 STATUS equ 0 x 03 RP 0 equ 0 x 05 org 0 movlw 0 x 0 FD movwf PORTB bsf STATUS, RP 0 bcf TRISB 0 x 080, 1 bcf TRISB 0 x 080, 2 movlw 0 x 07 F 9
• Each instruction is a 14 -bit word divided into: • An OPCODE which specifies the instruction type • One or more operands which further specify the operation of the instruction. 10
Field Description 11
CLRF 12
CLRW 13
ADDLW 14
ADDWF 15
MOVLW 16
MOVF 17
MOVWF 18
Exercise • Write a program to clear W and Port B, then add 0 x 0 A to 0 x 0 B and send it out thru Port B. 19
CALL 20
GOTO 21
Example for CALL and GOTO list p=16 F 84 goto Main ; Subroutine Delay movlw 0 xff movwf 0 x 0 c L 1 nop decfsz 0 x 0 c, 1 goto L 1 return ; Main program Main movlw 0 x 0 tris porta tris portb movlw 0 xff movwf portb call Delay 22
Exercise • Write a subroutine to clear Port. B and send data in W to Port. B • Write a program to add 0 x. A to 0 x. B and send it to Port. B (use the subroutine) 23
INCF 24
DECF 25
INCFSZ 26
DECFSZ 27
NOP 28
Exercise • Write a subroutine to delay for 1 msec, given that your input clock is 4 MHz 29
- 01:640:244 lecture notes - lecture 15: plat, idah, farad
- L "home" "user account" "register" inurl:register
- Miss status holding register
- Status register
- Current program status register
- Lời thề hippocrates
- Vẽ hình chiếu đứng bằng cạnh của vật thể
- Chụp tư thế worms-breton
- đại từ thay thế
- Quá trình desamine hóa có thể tạo ra
- Công của trọng lực
- Thế nào là mạng điện lắp đặt kiểu nổi
- Khi nào hổ mẹ dạy hổ con săn mồi
- Các loại đột biến cấu trúc nhiễm sắc thể
- Các châu lục và đại dương trên thế giới
- Biện pháp chống mỏi cơ
- Bổ thể
- độ dài liên kết
- Thiếu nhi thế giới liên hoan
- Chúa yêu trần thế alleluia
- điện thế nghỉ
- Một số thể thơ truyền thống
- Trời xanh đây là của chúng ta thể thơ
- Sơ đồ cơ thể người
- So nguyen to
- Tỉ lệ cơ thể trẻ em
- Vẽ hình chiếu vuông góc của vật thể sau
- đặc điểm cơ thể của người tối cổ
- Các châu lục và đại dương trên thế giới
- ưu thế lai là gì