CRTC Electronics

Click here to edit subtitle

Hello World

Light Up an LED!

Objective / Assignment

Know:

How to set up breadboard
How to set up a project
What are coments ";"
How to use; bsf, bcf, goto, lables, portABC,

Assignment:

Make a program that turns on 1 pin
Make a program that turns on all pins
Make a program that turns off all pins
Fix the coments at top (chip diagram)
Add a desription
Add student's name

Lesson

; -comments   are the part of your code the computer ignores, you add them to help make you code more understandable

bsf f,b  -Bit Set File-  f= file register,b=bit:This instruction turns ON bit 'b' of file register 'f'

bcf f,b -Bit Clear File- f= file register,b=bit:This instruction turns OFF bit 'b' of file register 'f'

goto L -tells the program to jump to label 'L'

labels are place makers in your code

PORTA -is the file register directly connected to input/output pins RA0-RA5

PORTB -is the file register directly connected to input/output pins RB4-RB7

PORTC -is the file register directly connected to input/output pins RC0-RC7

 

Code

;*******************************************************************
;                           Lesson_01.asm
;
;                            ___________
;        +      To positive     !Vdd   Vss!     To ground -
;                                !A5        A0!         
;                              !A4        A1!        
;                            !A3        A2!        
;                              !C5        C0!          
;                            !C4        C1!    
;                            !C3        C2!        
;                            !C6        B4!              
;                               !C7        B5!         
;                            !B7        B6!         
;                            -----------
;
;
;*******************************************************************

;Description:


;Name:



#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'    

    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     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
    clrf     PORTA
    clrf     PORTB
    clrf     PORTC



    ;fill varialbes

    ;Clear w register
    movlw     b'00000000'
    
;Objective:
;    Make your first program, "Hello World".  Make a program that will turn on and off LEDs.
;
; You will know:
;     how to set up breadboard and PIC
;     how to set up a project
;    what ports A B and C are
;
; New Code you will learn:
;     what coments ";" are
;    lables and goto
;     bsf, bcf
;
; Assingment:
;     make a program that turns on 1 pin
;     make a program that turns on all pins
;     make a program that turns off all pins
;     fix the coments at top (chip diagram)
;     add a description
;     add student's name


;*****************************************
;***     MAIN    *************************
;*****************************************















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









    
END

Members Area

Recent Blog Entries

Upcoming Events

Recent Videos

Recent Photos

Recent Forum Posts