Connect with us

knight rider code

Discussion in 'Microcontrollers, Programming and IoT' started by foTONICS, Jul 20, 2012.

  1. foTONICS

    foTONICS

    332
    9
    Sep 30, 2011
    so I'm writing some code to have a set of LED's flash in sequence like the knight rider. I tried turning on and flashing only 2 LED's and that worked, but when I added another 6 to make 8 total nothing turns on. I checked my circuit and everything seems okay so I was wondering if it's my code:


    ;**********************************************************************
    ; This file is a basic code template for object module code *
    ; generation on the PIC16F627A. This file contains the *
    ; basic code building blocks to build upon. As a project minimum *
    ; the 16F627A.lkr file will also be required for this file to *
    ; correctly build. The .lkr files are located in the MPLAB *
    ; directory. *
    ; *
    ; If interrupts are not used all code presented between the *
    ; code section "INT_VECTOR and code section "MAIN" can be removed. *
    ; In addition the variable assignments for 'w_temp' and *
    ; 'status_temp' can be removed. *
    ; *
    ; If interrupts are used, as in this template file, the 16F627A.lkr *
    ; file will need to be modified as follows: Remove the lines *
    ; CODEPAGE NAME=vectors START=0x0 END=0x4 PROTECTED *
    ; and *
    ; SECTION NAME=STARTUP ROM=vectors *
    ; and change the start address of the page0 section from 0x5 to 0x0 *
    ; *
    ; Refer to the MPASM User's Guide for additional information on *
    ; features of the assembler and linker (Document DS33014). *
    ; *
    ; Refer to the respective PIC data sheet for additional *
    ; information on the instruction set. *
    ; *
    ;**********************************************************************
    ; *
    ; Filename: test.asm *
    ; Date: 7/20/2012 *
    ; File Version: 0.1 *
    ; *
    ; Author: David Hogendoorn *
    ; Company: student *
    ; *
    ; *
    ;**********************************************************************
    ; *
    ; Files required: *
    ; 16F627A.lkr *
    ; *
    ; *
    ;**********************************************************************
    ; *
    ; Notes: this program is being used as a base to test upon *
    ; *
    ; *
    ; *
    ; *
    ;**********************************************************************

    list p=16F627A ; list directive to define processor
    #include <p16F627A.inc> ; processor specific variable definitions

    errorlevel -302 ; suppress message 302 from list file


    __CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT


    ; '__CONFIG' directive is used to embed configuration word within .asm file.
    ; The lables following the directive are located in the respective .inc file.
    ; See data sheet for additional information on configuration word settings.


    ;*****CONSTANT DEFINITIONS
    l1 EQU 0x00 ;RB0
    l2 EQU 0x01 ;RB1
    l3 EQU 0x02 ;RB2
    l4 EQU 0x03 ;RB3
    l5 EQU 0x04 ;RB4
    l6 EQU 0x05 ;RB5
    l7 EQU 0x06 ;RB6
    l8 EQU 0x07 ;RB7


    ;***** VARIABLE DEFINITIONS (examples)
    w_temp EQU 0x71 ;variable used for context saving
    status_temp EQU 0x72 ;variable used for context saving
    dc1 EQU 0x74
    dc2 EQU 0x75
    dc3 EQU 0x76

    ;************************************************************************

    ORG 0x000 ;processor reset vector
    goto MAIN ;go to beginning of program

    ORG 0x004 ;interrupt vector location
    movwf w_temp ;save off current W register contents
    movf STATUS,w ;move status register into W register
    movwf status_temp ;save off contents of STATUS register

    ;isr code can go here or be located as a call subroutine elsewhere

    movf status_temp,w ;retrieve copy of STATUS register
    movwf STATUS ;restore pre-isr W register contents
    retfile



    MAIN
    bcf STATUS,RP0 ;point at bank 0
    bcf STATUS,RP1
    movlw 0x07 ;turn comparators off
    movwf CMCON
    movlw 0x10 ;timer 1 uses int. clk and 2:1 prescale
    movwf T1CON
    bsf STATUS,RP0 ;now over to bank 1
    clrf TRISA ;port A as outputs
    clrf TRISB ;all of port B to outputs
    bcf STATUS,RP0 ;back to I/O bank 0
    clrf PORTB
    clrf PORTA


    start
    clrf PORTB
    bsf PORTB,l1
    movlw .20
    call delay10ms
    clrf PORTB
    bsf PORTB,l2
    movlw .20
    call delay10ms
    clrf PORTB
    bsf PORTB,l3
    movlw .20
    call delay10ms
    clrf PORTB
    bsf PORTB,l4
    movlw .20
    call delay10ms
    clrf PORTB
    bsf PORTB,l5
    movlw .20
    call delay10ms
    clrf PORTB
    bsf PORTB,l6
    movlw .20
    call delay10ms
    clrf PORTB
    bsf PORTB,l7

    goto start

    delay10ms ;this delay is a variable delay that is multiples of 10ms
    movwf dc3
    dly2 movlw .13
    movwf dc2
    clrf dc1
    dly1 decfsz dc1,f
    goto dly1
    decfsz dc2,f
    goto dly1
    decfsz dc3,f
    goto dly2
    return

    end
     
  2. foTONICS

    foTONICS

    332
    9
    Sep 30, 2011
    omg nevermind, just realized I had the Vdd in the ground bus (chalk one up to "There's nothing wrong with my circuit!")
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-