Lecture 3
Download
1 / 29

Lecture 3 - PowerPoint PPT Presentation


  • 214 Views
  • Uploaded on

Lecture 3. 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. Status Register. Z, DC, C, TO and PD bits are not writable.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Lecture 3' - hisa


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Status register
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.


Status register1
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 000u u1uu (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.


Pic instruction set
PIC Instruction Set

  • The instruction set for the PIC16F84 consists of 35 single word instructions

  • These are grouped into three major categories

    • Byte-oriented

    • Bit-oriented

    • Literal and control


List and equates
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=16F84

  • 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 ‘portB’ to the file register located at 0x06. Port B is always located at this file register.

    portB equ 0x06


Sample program
Sample Program

LIST P=16F84

PORTB equ 0x06

TRISB equ 0x06

STATUS equ 0x03

RP0 equ 0x05

org 0

movlw 0x0FD

movwf PORTB

bsf STATUS, RP0

bcf TRISB 0x080, 1

bcf TRISB 0x080, 2

movlw 0x07F











Exercise
Exercise

  • Write a program to clear W and Port B, then add 0x0A to 0x0B and send it out thru Port B.




Example for call and goto
Example for CALL and GOTO

list p=16F84

goto Main

; Subroutine

Delay

movlw 0xff

movwf 0x0c

L1 nop

decfsz 0x0c,1

goto L1

return

; Main program

Main

movlw 0x0

tris porta

tris portb

movlw 0xff

movwf portb

call Delay


Exercise1
Exercise

  • Write a subroutine to clear PortB and send data in W to PortB

  • Write a program to add 0xA to 0xB and send it to PortB (use the subroutine)







Exercise2
Exercise

  • Write a subroutine to delay for 1 msec, given that your input clock is 4 MHz


ad