![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | Thread Tools | Display Modes |
| | (permalink) |
| Experienced Member | I have made two programmers(JDM and P16PRO40) but both gave the same problem while programming pic 16F628A... I also bought a ICSP programmer given in following link: http://triindia.co.in/shop/product_i...products_id=93 All the 3 programmers give the same error while programming VERIFY FAILED AT ADDRESS 0000h I have used ic-prog and winpic800. But since all 3 are giving the same error, there might be some software error. By the way, I start MPLAB IDE ->and open the source file-> then click on quick built option...Is anything wrong in it?? I used the following code given by NIGEL: LIST p=16F628A ;tell assembler what chip we are using include "P16F628A.inc" ;include the defaults for the chip __config 0x3D18 ;sets the configuration settings (oscillator type etc.) cblock 0x20 ;start of general purpose registers count ;used in table read routine count1 ;used in delay routine count2 ;used in delay routine counta ;used in delay routine countb countc countd speed endc LEDPORT Equ PORTB ;set constant LEDPORT = 'PORTB' LEDTRIS Equ TRISB ;set constant for TRIS register SWPORT Equ PORTA SWTRIS Equ TRISA SW1 Equ 7 ;set constants for the switches SW2 Equ 6 SW3 Equ 5 SW4 Equ 4 LED1 Equ 3 ;and for the LED's LED2 Equ 2 LED3 Equ 1 LED4 Equ 0 SWDel Set Del50 org 0x0000 ;org sets the origin, 0x0000 for the 16F628, ;this is where the program starts running movlw 0x07 movwf CMCON ;turn comparators off (make it like a 16F84) bsf STATUS, RP0 ;select bank 1 movlw b'00000000' ;set PortB all outputs movwf LEDTRIS movlw b'11110000' ;set PortA 4 inputs, 4 outputs movwf SWTRIS bcf STATUS, RP0 ;select bank 0 clrf LEDPORT ;set all outputs low clrf SWPORT ;make sure all LED's are off bsf SWPORT, LED1 ;and turn initial LED on movlw d'250' movwf speed ;set initial speed Start clrf count ;set counter register to zero Read movf count, w ;put counter value in W btfsc SWPORT, LED1 ;check which LED is on call Table1 ;and call the associated table btfsc SWPORT, LED2 call Table2 btfsc SWPORT, LED3 call Table3 movwf LEDPORT call DelVar incf count, w xorlw d'14' ;check for last (14th) entry btfsc STATUS, Z goto Start ;if start from beginning incf count, f ;else do next goto Read Table1 ADDWF PCL, f ;data table for bit pattern retlw b'10000000' retlw b'01000000' retlw b'00100000' retlw b'00010000' retlw b'00001000' retlw b'00000100' retlw b'00000010' retlw b'00000001' retlw b'00000010' retlw b'00000100' retlw b'00001000' retlw b'00010000' retlw b'00100000' retlw b'01000000' Table2 ADDWF PCL, f ;data table for bit pattern retlw b'11000000' retlw b'01100000' retlw b'00110000' retlw b'00011000' retlw b'00001100' retlw b'00000110' retlw b'00000011' retlw b'00000011' retlw b'00000110' retlw b'00001100' retlw b'00011000' retlw b'00110000' retlw b'01100000' retlw b'11000000' Table3 ADDWF PCL, f ;data table for bit pattern retlw b'01111111' retlw b'10111111' retlw b'11011111' retlw b'11101111' retlw b'11110111' retlw b'11111011' retlw b'11111101' retlw b'11111110' retlw b'11111101' retlw b'11111011' retlw b'11110111' retlw b'11101111' retlw b'11011111' retlw b'10111111' ChkKeys btfss SWPORT, SW1 call Switch1 btfss SWPORT, SW2 call Switch2 btfss SWPORT, SW3 call Switch3 btfss SWPORT, SW4 call Switch4 retlw 0x00 Switch1 bcf SWPORT, LED2 ;turn unselected LED's off bcf SWPORT, LED3 ;turn unselected LED's off bsf SWPORT, LED1 ;turn LED1 on retlw 0x00 Switch2 bcf SWPORT, LED1 ;turn unselected LED's off bcf SWPORT, LED3 ;turn unselected LED's off bsf SWPORT, LED2 ;turn LED2 on retlw 0x00 Switch3 bcf SWPORT, LED1 ;turn unselected LED's off bcf SWPORT, LED2 ;turn unselected LED's off bsf SWPORT, LED3 ;turn LED3 on retlw 0x00 Switch4 call SWDel ;give switch time to stop bouncing btfsc SWPORT, SW4 ;check it's still pressed retlw 0x00 ;return is not btfss SWPORT, LED4 ;see if LED4 is already lit goto FASTON goto FASTOFF FASTON bsf SWPORT, LED4 ;turn LED4 on movlw d'80' movwf speed ;set fast speed call SWDel btfsc SWPORT, SW4 ;wait until button is released retlw 0x00 goto FASTON FASTOFF bcf SWPORT, LED4 ;turn LED4 on movlw d'250' movwf speed ;set slow speed call SWDel btfsc SWPORT, SW4 ;wait until button is released retlw 0x00 goto FASTOFF DelVar movfw speed ;delay set by Speed movwf count1 d1 call ChkKeys ;check the keys movlw 0xC7 ;delay 1mS movwf counta movlw 0x01 movwf countb Delay_0 decfsz counta, f goto $+2 decfsz countb, f goto Delay_0 decfsz count1 ,f goto d1 retlw 0x00 ;use separate delay routines, as Del50 is called from ChkKeys ;which is called from within DelVar Del50 movlw d'50' ;delay 50mS movwf count2 d3 movlw 0xC7 ;delay 1mS movwf countc movlw 0x01 movwf countd Delay_1 decfsz countc, f goto $+2 decfsz countd, f goto Delay_1 decfsz count2 ,f goto d3 retlw 0x00 end Th hex code generated by me: :020000040000FA :1000000007309F00831600308600F0308500831291 :10001000860185018515FA30A700A0012008851901 :100020001D2005192C2085183B2086007320200AEE :100030000E3A03190D28A00A0E2882078034403496 :1000400020341034083404340234013402340434CB :1000500008341034203440348207C03460343034E3 :1000600018340C3406340334033406340C34183496 :1000700030346034C03482077F34BF34DF34EF342F :10008000F734FB34FD34FE34FD34FB34F734EF3405 :10009000DF34BF34851F5320051F5720851E5B208A :1000A000051E5F200034051185108515003485116B :1000B0008510051500348511051185140034812043 :1000C000051A0034051C65286C2805145030A7005B :1000D0008120051A003465280510FA30A700812018 :1000E000051A00346C282708A1004A20C730A30055 :1000F0000130A400A30B7D28A40B7A28A10B75283E :1001000000343230A200C730A5000130A600A50B94 :0C0110008A28A60B8728A20B8328003445 :02400E00183D5B :00000001FF Plz anyone try using the code & hex code to program the pic16F628A and tell me the error as I must program my pic within 1 week... Pleaeez reply soon. |
| | |
| | (permalink) |
| Experienced Member | hi, Please repost your program listing, this time use the # option in the reply window menu, select all your code and 'Wrap [code] around selected text' This will retain the formatting of your list. Problem is your original post has no formatting.. I cannot just copy/paste to MPALB as it not formatted.
__________________ Eric "Good enough is Perfect" PIC tutorials: Nigel's: www.winpicprog.co.uk/ Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
| | |
| | (permalink) |
| Experienced Member | Code: LIST p=16F628A ;tell assembler what chip we are using
include "P16F628A.inc" ;include the defaults for the chip
__config 0x3D18 ;sets the configuration settings (oscillator type etc.)
cblock 0x20 ;start of general purpose registers
count ;used in table read routine
count1 ;used in delay routine
count2 ;used in delay routine
counta ;used in delay routine
countb
countc
countd
speed
endc
LEDPORT Equ PORTB ;set constant LEDPORT = 'PORTB'
LEDTRIS Equ TRISB ;set constant for TRIS register
SWPORT Equ PORTA
SWTRIS Equ TRISA
SW1 Equ 7 ;set constants for the switches
SW2 Equ 6
SW3 Equ 5
SW4 Equ 4
LED1 Equ 3 ;and for the LED's
LED2 Equ 2
LED3 Equ 1
LED4 Equ 0
SWDel Set Del50
org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
;this is where the program starts running
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)
bsf STATUS, RP0 ;select bank 1
movlw b'00000000' ;set PortB all outputs
movwf LEDTRIS
movlw b'11110000' ;set PortA 4 inputs, 4 outputs
movwf SWTRIS
bcf STATUS, RP0 ;select bank 0
clrf LEDPORT ;set all outputs low
clrf SWPORT ;make sure all LED's are off
bsf SWPORT, LED1 ;and turn initial LED on
movlw d'250'
movwf speed ;set initial speed
Start clrf count ;set counter register to zero
Read movf count, w ;put counter value in W
btfsc SWPORT, LED1 ;check which LED is on
call Table1 ;and call the associated table
btfsc SWPORT, LED2
call Table2
btfsc SWPORT, LED3
call Table3
movwf LEDPORT
call DelVar
incf count, w
xorlw d'14' ;check for last (14th) entry
btfsc STATUS, Z
goto Start ;if start from beginning
incf count, f ;else do next
goto Read
Table1 ADDWF PCL, f ;data table for bit pattern
retlw b'10000000'
retlw b'01000000'
retlw b'00100000'
retlw b'00010000'
retlw b'00001000'
retlw b'00000100'
retlw b'00000010'
retlw b'00000001'
retlw b'00000010'
retlw b'00000100'
retlw b'00001000'
retlw b'00010000'
retlw b'00100000'
retlw b'01000000'
Table2 ADDWF PCL, f ;data table for bit pattern
retlw b'11000000'
retlw b'01100000'
retlw b'00110000'
retlw b'00011000'
retlw b'00001100'
retlw b'00000110'
retlw b'00000011'
retlw b'00000011'
retlw b'00000110'
retlw b'00001100'
retlw b'00011000'
retlw b'00110000'
retlw b'01100000'
retlw b'11000000'
Table3 ADDWF PCL, f ;data table for bit pattern
retlw b'01111111'
retlw b'10111111'
retlw b'11011111'
retlw b'11101111'
retlw b'11110111'
retlw b'11111011'
retlw b'11111101'
retlw b'11111110'
retlw b'11111101'
retlw b'11111011'
retlw b'11110111'
retlw b'11101111'
retlw b'11011111'
retlw b'10111111'
ChkKeys btfss SWPORT, SW1
call Switch1
btfss SWPORT, SW2
call Switch2
btfss SWPORT, SW3
call Switch3
btfss SWPORT, SW4
call Switch4
retlw 0x00
Switch1 bcf SWPORT, LED2 ;turn unselected LED's off
bcf SWPORT, LED3 ;turn unselected LED's off
bsf SWPORT, LED1 ;turn LED1 on
retlw 0x00
Switch2 bcf SWPORT, LED1 ;turn unselected LED's off
bcf SWPORT, LED3 ;turn unselected LED's off
bsf SWPORT, LED2 ;turn LED2 on
retlw 0x00
Switch3 bcf SWPORT, LED1 ;turn unselected LED's off
bcf SWPORT, LED2 ;turn unselected LED's off
bsf SWPORT, LED3 ;turn LED3 on
retlw 0x00
Switch4 call SWDel ;give switch time to stop bouncing
btfsc SWPORT, SW4 ;check it's still pressed
retlw 0x00 ;return is not
btfss SWPORT, LED4 ;see if LED4 is already lit
goto FASTON
goto FASTOFF
FASTON bsf SWPORT, LED4 ;turn LED4 on
movlw d'80'
movwf speed ;set fast speed
call SWDel
btfsc SWPORT, SW4 ;wait until button is released
retlw 0x00
goto FASTON
FASTOFF bcf SWPORT, LED4 ;turn LED4 on
movlw d'250'
movwf speed ;set slow speed
call SWDel
btfsc SWPORT, SW4 ;wait until button is released
retlw 0x00
goto FASTOFF
DelVar movfw speed ;delay set by Speed
movwf count1
d1 call ChkKeys ;check the keys
movlw 0xC7 ;delay 1mS
movwf counta
movlw 0x01
movwf countb
Delay_0
decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0
decfsz count1 ,f
goto d1
retlw 0x00
;use separate delay routines, as Del50 is called from ChkKeys
;which is called from within DelVar
Del50 movlw d'50' ;delay 50mS
movwf count2
d3 movlw 0xC7 ;delay 1mS
movwf countc
movlw 0x01
movwf countd
Delay_1
decfsz countc, f
goto $+2
decfsz countd, f
goto Delay_1
decfsz count2 ,f
goto d3
retlw 0x00
end Plz help me out |
| | |
| | (permalink) |
| Experienced Member | Yes, Anurag, i too got the same hex on MPLAB 8.02
__________________ Regards, Sarma. |
| | |
| | (permalink) |
| Super Moderator | A problem in the source code wouldn't give that error anyway, it's a programmer error - most probably that the PIC isn't getting switched to program mode. It might even be something as simple as not connecting to the correct port?, it needs basic fault finding applying. |
| | |
| | (permalink) |
| Experienced Member | hi, Pasted your program into the Oshonsoft simulator, it runs ok, cycles thru the LED's OK. Used MPLAB V7.60, Project wizard, 16F628A, assembles OK, checked the program file looks OK. Programmed a PIC 16F628A using PIC Start+, programs and verifies OK. As stated, your problem lies elsewhere.. MPLAB View: :020000040000FA :1000000007309F00831600308600F0308500831291 :100010008601850185150130A700A00120088519FA :100020001D2005192C2085183B2086007320200AEE :100030000E3A03190D28A00A0E2882078034403496 :1000400020341034083404340234013402340434CB :1000500008341034203440348207C03460343034E3 :1000600018340C3406340334033406340C34183496 :1000700030346034C03482077F34BF34DF34EF342F :10008000F734FB34FD34FE34FD34FB34F734EF3405 :10009000DF34BF34851F5320051F5720851E5B208A :1000A000051E5F200034051185108515003485116B :1000B0008510051500348511051185140034812043 :1000C000051A0034051C65286C2805145030A7005B :1000D0008120051A003465280510FA30A700812018 :1000E000051A00346C280800A1004A20C730A3007C :1000F0000130A400A30B7D28A40B7A28A10B75283E :1001000000343230A200C730A5000130A600A50B94 :0C0110008A28A60B8728A20B8328003445 :02400E00183D5B :00000001FF
__________________ Eric "Good enough is Perfect" PIC tutorials: Nigel's: www.winpicprog.co.uk/ Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 11th April 2008 at 12:36 PM. |
| | |
| | (permalink) | |
| Experienced Member | Quote:
__________________ Regards, Sarma. | |
| | |
| | (permalink) |
| Experienced Member | As stated, sound like the programmer(s) and software. Do you have extra PIC chips, maybe the PIC chip is bad? |
| | |
| | (permalink) |
| Experienced Member | By the way, the pic reads 0000h at all place when read using ic-prog whereas it reads 3FFF when read using winpicpro. That could be the reason to say that the pic chip is faulty. @mvs_sarma I have made p16pro40 programmer as per nigel's schematic. But the same error. And it also used LPT port, so the port connection could not be wrong as I tried both serial & parallel port programmers. Last edited by Anurag_Singh; 11th April 2008 at 01:27 PM. |
| | |
| | (permalink) |
| Experienced Member | Could it also be beacause of faulty chip |
| | |
| | (permalink) |
| Experienced Member | It's more likely a faulty programmer, the JDM designs can be very unreliable on modern computers. PICs on the otherhand tend to be very robust. |
| | |
| | (permalink) | |
| Super Moderator | Quote:
| |
| | |
| | (permalink) |
| Experienced Member | Hai, Anurag, Three programmers and same result: Once you have selected, internal oscillator, you may not be able to stop it if powered, unless you have Vpp before Vdd. How many more you could manufacture? At least the PIC16PR40 is acclaimed. You first take it up and try to debug by testing various measurements on it and make it work, there after you can proceed further. Mean time, if you have the schematic of the TRI programmer in the manual you may send a copy so that I could analyse it. I feel, it is similar to Ashonsoft PIC programmer, by initial looks at the board photograph.
__________________ Regards, Sarma. |
| | |
| | (permalink) |
| Experienced Member | Hello everyone I got a new clue about my failure. All the 3 programmers read 0000h when the pic is inserted as well as when the pic chip is removed. That means the programmers are unable to find the presence of the pic chip. This might be the probable reason of programming error... Can anyone tell me what it is all about?? How is it possible that the existence of chip is not recognised by the programmer??? By the way, I think the programmer works well as all leds lit as per scheme. Plz tell me the probable reason of my prob and its solution. |
| | |
| | (permalink) | |
| Experienced Member | Quote:
Is it possible to try your programmers on a different PC.? Also what is the PC's operating program/system. eg: Win XP Win98se etc.?
__________________ Eric "Good enough is Perfect" PIC tutorials: Nigel's: www.winpicprog.co.uk/ Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 12th April 2008 at 08:20 AM. | |
| | |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Latest |
| plz help | s29 | Electronic Projects Design/Ideas/Reviews | 12 | 7th February 2008 07:40 PM |
| Pan and Tilt Platform with Memory! PLZ help:) | Cynergy | Micro Controllers | 3 | 31st October 2007 09:13 PM |
| small help plz | HKS | Electronic Projects Design/Ideas/Reviews | 1 | 16th October 2007 04:56 PM |
| plz help me with xenon strobe flashers. | swapitude | Electronic Projects Design/Ideas/Reviews | 5 | 29th September 2007 04:31 PM |
| Hey m Fial yr B.tech student can anybody plz suggest me any project for my final yr | vivekagarwal141 | Micro Controllers | 8 | 27th September 2007 05:09 AM |