2 didit up down counter using 16F628A program errors


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Location
    florida
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Re: 2 didit up down counter using 16F628A program errors

    Thanks Richard I have tried the prg in mplab it gave me errors I,ll go over the files like you said I did get one of them to work in mplab the one with the dice but I don't want that one
    Here is a copy of the pbp version as you requested thank you for the help you are giving me
    I don't know anything about machine code also my age is a factor im currently 92 yrs old
    cant do the things I used to Ray
    I had to zip the file I wont let me up load the pnp file
    Attached Files Attached Files

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: 2 didit up down counter using 16F628A program errors

    I had a look a http://www.talkingelectronics.com/te...ive_index.html
    where it seems you got the code from. there is no pbp version its all asm. puting a pbp extension on a asm file will not convert asm code to pbp code

    this compiles for me with mpasm 5.36 , i have preloaded counter to 15

    Code:
    ;****************************************************************;* 2 Digit UP / Down Counter    17/6/2009	
    ;Port B drives two 7 segment displays
    ;Up Sw on RA2   Down Sw on RA3
    ;"Units" drive on RA0   "Tens" drive on RA1					*
    ;* 								*
    ;****************************************************************
    
    
    	list P = 16F628A		;microcontroller 
    	include 	;registers for F628A
    
    
    
    
    	__CONFIG 	_CP_OFF & _LVP_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF
    	
    ;code protection - off
    ;low-voltage programming - off
    ;power-up timer -  on
    ;watchdog timer - off
    ;use internal RC for 4MHz - all pins for in-out
    
    
    
    
    ;****************************************************************
    ; variables - names and files
    ;****************************************************************
    
    
    
    
    		;Files for F628A start at 20h 
     
    						 			
    temp1		equ 20h	;for delay
    temp2		equ 21h	;for delay
    SwUp		equ 22h	;
    SwDwn		equ	23h	;
    units		equ	24h	;
    tens		equ	25h	;
    Sw_Flag		equ	26h	;
    
    
    
    
    ;****************************************************************
    ;Equates
    ;****************************************************************
    status		equ	0x03
    cmcon		equ	0x1F
    rp1			equ	0x06
    rp0			equ	0x05
    
    
    ;****************************************************************
    ;Beginning of program
    ;****************************************************************
    reset	org		00				;reset vector address	
    		goto	SetUp			;goto SetUp
    			
    
    
    table	addwf   PCL,F           ;02h,1  add W to program counter 
            retlw   b'00111111'     ; "0"   -|F|E|D|C|B|A
            retlw   b'00000110'     ; "1"   -|-|-|-|C|B|-
            retlw   b'01011011'     ; "2"   G|-|E|D|-|B|A
            retlw   b'01001111'     ; "3"   G|-|-|D|C|B|A 
            retlw   b'01100110'     ; "4"   G|F|-|-|C|B|-
            retlw   b'01101101'     ; "5"   G|F|-|D|C|-|A
            retlw   b'01111101'     ; "6"   G|F|E|D|C|-|A
            retlw   b'00000111'     ; "7"   -|-|-|-|C|B|A
            retlw   b'01111111'     ; "8"   G|F|E|D|C|B|A
            retlw   b'01101111'     ; "9"   G|F|-|D|C|B|A
    
    
    
    
    ;****************************************************************
    ;* port A and B initialisation					*
    ;****************************************************************
    
    
    SetUp	bsf		status,rp0	
    		movlw	b'00001100'		;Make RA0,1 out   RA2,3 in
    		movwf	05h			
    		clrf	06h				;Make all RB output
    		bcf		status,rp0		;select programming area - bank0 
    		movlw	b'10000000'		;Turn off T0CKI
    		movwf	OPTION_REG		
    		clrf 	06h				;Clear Port B of junk 
    		movlw   5        ; preload count to 15
                    movwf   units
                    movlw   1
                    movwf   tens		 		
    		clrf	Sw_Flag
    		movlw	07h				;turn comparators off and enable
    		movwf	cmcon			;    pins for I/O functions						
    		goto 	Main						
    					
    
    
    
    
       ;Delay 10mS 		10 x 1,000uS
    			
    
    
    D_10mS	movlw	0Ah
    		movwf	temp2
    D_a		nop
    		decfsz temp1,1
    		goto D_a
    		decfsz temp2,1
    		goto D_a	
    		retlw 00
    		
    		
    Up		btfsc	Sw_Flag,2
    		retlw	00
    		bsf		Sw_Flag,2
    		incf	units,1
    		movlw	0Ah			;put 10 into w
    		xorwf	units,0		;compare units file with 10
    		btfss	03,2	;zero flag in status file. Will be set if units is 10
    		retlw	00
    		clrf	units
    		incf	tens,1
    		movlw	0Ah			;put 10 into w
    		xorwf	tens,0		;compare units file with 10
    		btfsc	03,2	;zero flag in status file. Will be set if tens is 10
    		clrf	tens				
    		retlw	00			;display passes 99 but not below 0
    		
    		
    		
    Dwn		btfsc	Sw_Flag,3
    		retlw	00
    		bsf		Sw_Flag,3
    		decf	units,1
    		movlw	0FFh		;put FFh into w
    		xorwf	units,0		;compare units file with FFh
    		btfss	03,2	;zero flag in status file. Will be set if units is 10
    		retlw	00
    		movlw	09
    		movwf	units		;put 9 into units file
    		decf	tens,1
    		movlw	0FFh		;put 0FFh into w
    		xorwf	tens,0		;compare tens file with 0FFh
    		btfsc	03,2	;zero flag in status file. Will be set if tens is 0FFh
    		goto	$+2			;tens file is 0FFh    Jump down 2 instructions
    		retlw	00						
    		clrf	tens
    		clrf	units
    		retlw	00			;display  not below 0		
    							
    
    
    
    
    Main	btfss	05,2			;test switch-press for UP
    		call	Up				;UP switch pressed
    		btfss	05,3			;test switch-press for Down
    		call	Dwn				;Down switch pressed
    		movlw	b'00000001'		;Make RA0 HIGH for units drive 	
    		movwf	05h	
    		movf	units,0			;copy unit value into w
    		call	table			;unit display value will return in w
    		movwf	06h				;output units value
    		call	D_10mS			;call delay
    		clrf	06h				;clear display
    		movlw	b'00000010'		;Make RA1 HIGH for tens drive 	
    		movwf	05h			
    		movf	tens,0			;copy tens value into w		
    		call	table			;tens display value will return in w
    		movwf	06h				;output tens value
    		call	D_10mS			;call delay
    		clrf	06h				;clear display
    		btfsc	05,2			;bit will be zero when sw is pressed
    		bcf		Sw_Flag,2
    		btfsc	05,3			;bit will be zero when sw is pressed
    		bcf		Sw_Flag,3				
    		goto	Main		
    		
    		END
    Warning I'm not a teacher

Similar Threads

  1. Replies: 12
    Last Post: - 4th October 2011, 00:59
  2. Replies: 1
    Last Post: - 23rd May 2009, 09:22
  3. Replies: 1
    Last Post: - 27th September 2007, 19:15
  4. Program Code and Program Memory
    By DenFrod in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th February 2007, 14:51
  5. Compiler Errors
    By Conspiracy Bro in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 1st November 2004, 16:57

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts