EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / PIC Programming Help. Creating a counter but I have some errors in my code

PIC Programming Help. Creating a counter but I have some errors in my code

|

Microcontroller › PIC › PIC Programming Help. Creating a counter but I have some errors in my code

  • This topic has 0 replies, 1 voice, and was last updated 10 years, 6 months ago by Liam Porter.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • January 11, 2015 at 11:22 pm #3313
    Liam Porter
    Participant

    I am attempting to create a simple counter on a PIC16F628A board that will have two inputs, one to increase value, one to decrease and the values will be displayed on a 7 segment display. I have written my code but when I attempt to compile I get these error codes:

    Counter.asm:42:Error[118] Overwriting previous address contents: 0x0000 Counter.asm:63:Warning[202] Argument out of range. Least significant bits used. 35 <0x23>

    Can anyone help identify where the problem is?

     

    <code>LIST P=16f84A, R=Dec

    __FUSES _XT_OSC & _WDT_OFF & _CP_OFF & _PWRTE_ON
    include “P16f84A.inc”
     
    CBLOCK 0x20
    W_TEMP
    STATUS_TEMP
    COUNTER
    FLAGS
    FILTR1
    FILTR2
    ENDC
     
     
     
     
    #DEFINE ST_BT1 FLAGS,0
    #DEFINE ST_BT2 FLAGS,1
     
     
     
     
    MIN EQU .0 ;minimum counter value
    MAX EQU .15 ;maximum counter value
    T_FILTR EQU .255
     
     
    CMCON
    movlw 0x07
    movwf CMCON
     
     
     
     
     
    ;reset
    ORG 0x00
    GOTO start
     
     
     
     
     
     
     
    ORG 0x04
    RETFIE
     
     
     
     
     
     
     
    DISP7
    MOVF COUNTER,W
    ANDLW B’0001111′
     
    ADDWF PCL,FLAGS
     
    ;
    RETLW b’11101110′ ;digit 0
    RETLW b’00101000′ ;digit 1
    RETLW b’11001101′ ;digit 2
    RETLW b’01101101′ ;digit 3
    RETLW b’00101011′ ;digit 4
    RETLW b’01100111′ ;digit 5
    RETLW b’11100111′ ;digit 6
    RETLW b’00101100′ ;digit 7
    RETLW b’11101111′ ;digit 8
    RETLW b’00101111′ ;digit 9
    RETLW b’10101111′ ;A
    RETLW b’11100011′ ;B
    RETLW b’11000110′ ;C
    RETLW b’11101001′ ;D
    RETLW b’11000111′ ;E
    RETLW b’10000111′ ;F
     
     
     
     
     
    start
    BCF STATUS,RP0
    MOVLW B’00000111′
    MOVWF CMCON
     
    BSF STATUS,RP0
    MOVLW B’00000110′
    MOVWF TRISA
     
    MOVLW B’00000000′
    MOVWF TRISB
    MOVLW B’10000000′
    MOVWF OPTION_REG
     
     
    MOVLW B’00000000′
    MOVWF INTCON
    BCF STATUS,RP0
     
     
     
     
     
    CLRF PORTA
    CLRF PORTB
    CLRF FLAGS
    MOVLW MIN
    MOVWF COUNTER
    GOTO DISPUP
     
     
     
     
    MAIN
    MOVLW T_FILTR
    MOVWF FILTR1
    MOVWF FILTR2
     
    CHECK_BUTTON1
    BTFSC PORTA,1 ;is button 1 pressed
    GOTO BUTTON1_RELEASED
    ;yes
    DECFSZ FILTR1,F
     
    GOTO CHECK_BUTTON1
     
    BTFSS ST_BT1
    GOTO DEC
    GOTO CHECK_BUTTON2
     
    BUTTON1_RELEASED
    BCF ST_BT1
     
    CHECK_BUTTON2
    BTFSC PORTA,2
    GOTO BUTTON2_RELEASED
     
    DECFSZ FILTR2,F
     
    GOTO CHECK_BUTTON2
     
    BTFSS ST_BT2
    GOTO INC
    GOTO MAIN
     
    BUTTON2_RELEASED
    BCF ST_BT2
    GOTO MAIN
     
    DEC
    BSF ST_BT1
    MOVF COUNTER,W
    XORLW MIN
     
     
    BTFSC STATUS,Z
    GOTO MAIN
     
    DECF COUNTER,F
    GOTO DISPUP
     
    INC
    BSF ST_BT2
    MOVF COUNTER,W
    XORLW MAX
     
     
    BTFSC STATUS,Z
    GOTO MAIN
     
    INCF COUNTER,F
    GOTO DISPUP
     
    DISPUP
    CALL DISP7
     
    MOVWF PORTB
     
     
    GOTO MAIN
     
     
     
    END <code>
  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Raise your hand if your car had one of these: July 8, 2025
  • Simple LED Analog Clock Idea July 8, 2025
  • Kawai KDP 80 Electronic Piano Dead July 8, 2025
  • Tektronix 2235 channel 1 trace unstable July 8, 2025
  • How to make string LEDs? July 8, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise