PDA

View Full Version : 2 didit up down counter using 16F628A program errors



raybel
- 11th September 2020, 22:03
HI I have been trying for a long time now I have downloaded a program from a site years ago for a 2 digit up down counter they give several versions of the prg. But I cannot get any to work I keep getting(( label redefinition error) it wont go past that point has any body tried this prg it is still on the web but no help I hope someone can either figure it out or tell me what to do as I would really like to get this prg working I am going to try to upload it here Thanks for any help Ray PS if you would like to see the site go to 2digit updn counter with 7 segment display at talking electronics

richard
- 12th September 2020, 07:05
you realize thats assembler code not pbp code . it wont compile like that in pbp

raybel
- 12th September 2020, 18:44
Hi Thanks but it says in the instructions that it is programed with pick-2 which I have also I have mplab
it also gives me the same errors ,Can you lead me to how I can get the pic code version
I would like it for the micro studio programmer version As I would like to alter it to start counting at 15
I want to use it for my antenna tower counting how high the tower is as im raising it
Thanks for the info sure do apricate it Ray

richard
- 13th September 2020, 04:28
I have downloaded a program from a site years ago for a 2 digit up down counter they give several versions of the prg.

I would like it for the micro studio programmer version


you have downloaded the wrong version then , you have a {machine code } asm version


but it says in the instructions that it is programed with pick-2 which I have

all pic compilers will produce A HEX intel object code output file that programmers like a
pickit2 can use , that means nothing really


But I cannot get any to work I keep getting(( label redefinition error)
the code you have posted will build in mplabx 2.35 in a properly configured asm project
if you :-
fix the config section {needs to be uppercase}.
don't try to redefine cmcon and status.
refer to all registers using uppercase [CMCON,STATUS,OPTION_REG],mplabx in standard configuration is case sensitive

if you have a pbp version then post it

raybel
- 13th September 2020, 17:08
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

richard
- 14th September 2020, 03:50
I had a look a http://www.talkingelectronics.com/te_interactive_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


;************************************************* ***************;* 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 <P16F628a.inc> ;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

raybel
- 15th September 2020, 01:25
Richard
I tried yesterday and deleted all my old files from the talking electronics site then download a new ASM file and used the mplab ver8.9 wizard this time
and lo and behold it worked. But my biggest surprise is when I just logged on to this site I saw that you had also compiled the prg
then you also went ahead and pre set it for me Boy I don't know how to thank you enough Rich you made my day Thank you again and again Ray

richard
- 15th September 2020, 08:19
you made my day

ray if you're 92 and still doing this stuff then that's enough to make anybody's day
i'm glad to help

Ioannis
- 15th September 2020, 10:02
I am really happy and proud to have you Ray here on this forum. Hope I am still doing that stuff if I get on your age too!

Ioannis

raybel
- 18th September 2020, 01:57
Hi guys its me again thanks for all the kind words really apricate it I have been going nuts I cannot get the chip programmed I have 3 types of programmers pickit3 mplab ICD2 and melabs usb none of them want to program the chip

they all come up with device not found it says it dosent have power to the chip to be programed so I checked first with pickit3 yes no power at the connection site so I went into the programmer configure setup turned the power to device on checked voltage
I had 5 volts went to program again same message checked no voltage again then I tried mplab ICD2 same thing made sure jumper was at 5v target same massage trying to program my melabs will let me program if the file was in hex so went to mplabs to convert to hex
every time I try to build a file it gave me the message failed it said no source files present Im at wits end I was wondering if someone could supply me with a hex file of the program may be melabs will work if hex.
Sorry guys for the complaining

richard
- 18th September 2020, 05:01
I have 3 types of programmers pickit3 mplab ICD2 and melabs usb none of them want to program the chip they all come up with device not found

if none of your programmers can find the chip and its connected and powered correctly then that issue needs to be resolved before you can continue.
there is no way forward with a dud setup or chip.



Im at wits end I was wondering if someone could supply me with a hex file of the program
you said

used the mplab ver8.9 wizard this timeand lo and behold it worked.
the result of that process is a HEX intel object code output file , that's all you need for any of your programmers
you must have a hex file already , you just need to find and use it


trying to program my melabs will let me program if the file was in hex so went to mplabs to convert to hex
every time I try to build a file it gave me the message failed it said no source files present
quite correctly, there is no such process as to convert an asm file to hex with melabs anything . the melabs pbp compiler produces a intel hex object file from pbp code
of which you have none of. the melabs programmer is perfectly happy to use the hex files produced by mplab, mpasm, mpasmwin or mplabx

Ioannis
- 18th September 2020, 13:59
Ray,

you said that the hex file worked! Then you ask for a hex that works. You already have that hex file.

First you need to find why all three programmers will not connect to your chip.

1. Maybe the chip is fried?

2. Are you sure the connections are correct?

3. Are you sure you have the correct chip for the specific hex file?

Ioannis

raybel
- 26th September 2020, 18:25
Hi Guys I solved out a lot of the problems .But now I keep getting this out of date error so I downloaded the latest file of the inc files for the 16F628A chip
but I keep getting this error can either Loannis or Richard tell me what going on.????
I have downloaded the hex file from talking elect. and programed it to my pcb it works perfect all I need is the preset.

PS I also downloaded the asm file from talking elect and get the same error as I got with Richards asm file
I just cant seem to make the hex file needed to program the chip

Sorry but I tried everything so I would not have to bother you Thanks again for ANY help
Ray

tumbleweed
- 26th September 2020, 23:54
The simplest form of the mpasm 'include' directive has the form:


include p16f628a.inc

I think the angle brackets made part of the line drop out in richard's post, so if you try to copy that code you'll have to fix it.

Also, depending on which version of the code you're trying to assemble you may have to turn off the 'case-sensitive' option.
With case-sensitive on the 'config' statement has to match the settings in the .inc file exactly.
Your copy has mixed-case, but richard's copy has it all in caps (as in the .inc file)

And just a suggestion... if I were you I'd get rid off all the spaces in the path and filename. That just complicates things.

richard
- 27th September 2020, 00:57
I think the angle brackets made part of the line drop out in richard's post, so if you try to copy that code you'll have to fix it.
well spotted tumbleweed, i failed to notice that

raybel
- 27th September 2020, 15:30
I GOT IT thank to you guys everything is honky dory I thought all along it was the header then you confirmed it
I decided to work on it so I deleted the entire header section then I went to the16F628A inc file then copied
the entire header and config section then pasted it into the area where I had deleted the old one
then went to mplab when I ran the complier everything perfect with no problems
So then I programed it into the chip and it works great thanks to you guys
So thanks to Rich and Loannis for all the ideas you did a great job I am a happy forum member Thanks again Ray