CRTC Electronics

Click here to edit subtitle

Lesson 2

How to make loops

Objective / Assignment

;Objective know how to:
; crate and use variables, subroutines, loops
; use: decfsz, call, return

;Assignment:

;1 Create a new project called Lesson2

;2 Create two functions allOn and allOff ( call and return)

;3 Make a PauseLoop funtion (creat a varialbe,  use decfsz myVariable,1)

;4 Add your name and decription to the code

;5 Print and hand it in

Code

;*******************************************************************
;
;          Name______________________
;
;                            ___________
;        +      To positive     !Vdd   Vss!     To ground -
;                     button    !A5        A0!    
;                      speaker    !A4        A1!        
;                            !A3        A2!        
;                   YES        !C5        C0!  MAYBE            
;                    YES        !C4        C1!     MAYBE
;                    YES        !C3        C2!     MAYBE    
;                  TRYAGAIN    !C6        B4!  NO        
;                  TRYAGAIN    !C7        B5!     NO    
;                  TRYAGAIN    !B7        B6!     NO
;                            -----------
;
;
;*******************************************************************


;DESCRIPTION:



#include <p16F690.inc>
    __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
    org 0 ; reset vector

    ;Reserve our Regesters
    cblock        H'20'    
    ;***********************
    ;ADD VERIABLES HERE:


    

    ;**********************
    endc

    ;Bank 3
    BSF     STATUS,RP1
    BCF     STATUS,RP0
    CLRF     ANSEL ;digital I/O
    CLRF     ANSELH ;digital I/O
    
    ;Bank 2
    BCF     STATUS,RP1
    BSF     STATUS,RP0
    movlw     0x10 ;A2D clock
    movwf     ADCON1
    movlw     B'00000000' ; 0=out 1=in
    movwf     TRISC ; Set tristate mode
    movlw     B'00000000' ; 0=out 1=in
    movwf     TRISB ; Set tristate mode
    movlw     B'00000000' ; 0=out 1=in
    movwf     TRISA ; Set tristate mode

    ;Bank 1
    BCF     STATUS,RP1
    BCF     STATUS,RP0

    ;Clear registers


;*****************************************
;***     MAIN    *************************
;*****************************************
main


goto main


;**********************************
;**            Subroutines            **
;**********************************











END

Members Area

Recent Blog Entries

Upcoming Events

Recent Videos

Recent Photos

Recent Forum Posts