Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Issue writing to PIC16F627 with Progpic2

Status
Not open for further replies.

nomdomokunnom

New Member
Hi guys,

I'm new to PIC programming and to Assembly so bear with me please; I recently bought a kit from Maplin which comprised a Velleman VM111 programmer and P16F627 and tried one of the demo applications which came with the software, and a couple of simple programs I adapted from online to learn assembly, which worked fine. I then adapted a sample program from Nigel Goodwin's beginning , assembled it with MPASM and wrote it to the microcontroller with Progpic2, and it worked... but somehow progpic2 can no longer communicate with the μc, so I can't change the program, or even remove the program from the device. I'm totally stumped as to why, as I've also double-checked the configuration in progpic2. Any ideas?

The code I used (slightly modified from Nigel Goodwin's tutorial since I'm using a different chip):

Code:
;Hello chip program, adapted from http://www.winpicprog.co.uk/pic_tutorial1.htm.

	LIST	p=16F627		;tell assembler what chip we are using
	include "P16F627.inc"		;include the defaults for the chip
	__config _BODEN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _XT_OSC

	cblock 	0x20 			;start of general purpose registers
		count1 			;used in delay routine
		counta 			;used in delay routine 
		countb 			;used in delay routine
	endc
	
	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 	TRISB
	movwf	TRISA			;set PortA all outputs
	bcf	STATUS,		RP0	;select bank 0

Loop	
	movlw	0xff
	movwf	PORTA			;set all bits on
	movwf	PORTB
	nop				;the nop's make up the time taken by the goto
	nop				;giving a square wave output
	call	Delay			;this waits for a while!
	movlw	0x00
	movwf	PORTA
	movwf	PORTB			;set all bits off
	call	Delay
	goto	Loop			;go back and do it again

Delay	movlw	d'250'			;delay 250 ms (4 MHz clock)
	movwf	count1
d1	movlw	0xC7
	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

	end

The error I keep receiving:

Code:
NO PIC ON BOARD, PROGRAMMER MUST BE SET TO PGM MODE, PIC TYPE MISMATCHED WITH SOFTWARE,...

Naturally I've made sure the programmer's set to program mode, the PIC is securely in place, and I used a program which previously worked fine (and made sure the config settings in progpic2 were correct).

Any help solving this problem would be greatly appreciated.
 
Last edited:
Hi,

Your code and actions seems ok and cannot offer any direct assistance as I'm not familiar with that board or program.

It just might be worth removing and then reloading the software in case you have inadvertently changed some of the default programmer paramenters.

A quick as simple way to help locate the problem would be to pop in another pic and see if that works.

If you are near to a Maplin branch you can pick up another 627 or better and cheaper the 628
 
I would have tried reinstalling the software already, but it wasn't actually installed in the first place, just extracted. I also checked the manual and confirmed all the config settings; I'll see if I can pick up another PIC soon but I won't be able to for a few days, maybe I'll have a solution by then.

Edit: I just tried searching the registry for config settings and then wiping the directory and re-extracting the files, but there were no registry entries I could see, and the problem hasn't changed.
 
Last edited:
If you've set the PIC to use the internal oscillator (as most of my tutorials do), then some poorly designed programmers can't enter program mode afterwards.
 
Nigel Goodwin said:
If you've set the PIC to use the internal oscillator (as most of my tutorials do), then some poorly designed programmers can't enter program mode afterwards.

...is there a solution for that? I'm starting to regret buying the maplin programmer now, I got lazy and bought it from Maplin instead of ordering a slightly cheaper and better-looking one online.
 
...is there a solution for that? I'm starting to regret buying the maplin programmer now, I got lazy and bought it from Maplin instead of ordering a slightly cheaper and better-looking one online.

Assuming the Velleman programmer can't do it?, then you need a different programmer to turn off the internal oscillator.
 
Looks like I'd better see if I can return this programmer then... might I suggest you add a warning to your tutorial if this is a known issue with some programmers? This has rather abruptly cut short my first experimentation with PICs and I wouldn't like to see anyone else have the same problem.
 
Hi,

I'm sure Nigels right, though your code example shows you are using an external crystal in XT mode.

Maplin also sell a Microchip Pickit1 starter kit, but suggest you avoid that as its really old stuff - get a full refund if possible or a credit note rather than an exchange.

Your best bet for a good and relativley cheap starter system is the ready made Microchip Pickit2 Starter or Debugger packages - well recommended on this forum. About £30 from RS or Farnells.
 
your code example shows you are using an external crystal in XT mode

Indeed; I originally left the config setting from his tutorial as-is, then I realised the settings would probably be different for the slightly different chip and replaced the config line with the one from the demo apps provided on the CD; that didn't work for obvious reasons.
 
I've gotten a refund on the programmer; I had a look at a different programmer online recently which I was considering purchasing before getting the last one; any idea if this one will support the internal oscillator? **broken link removed**.

If not, can anyone suggest a decent (and fairly cheap one) which can be bought online? USB interface would be preferred.

Thanks for the help guys.
 
Hi,

As I metioned earlier and Nigel has just confirmed, the genuine Microchip USB PicKit2 is the one to buy.

It comes either one its own, with a little Starter board or a little Debugger board

You can buy them online or some over the counter from places like Farnells, RS, Rapid and Microchip Direct.

None of the above have a Zif socket, but you can buy one and easily make up your own if you want one.

There are lots of Pickit2 clones around, mainly far east which are best avoided.
However look at the Junebug from Blueroom which might neet your needs ? - that is a good Pickit2 clone; built to allow many extras to be added.
 
Thanks for the advice guys, I'll probably get the PICkit2 starter kit as that seems useful for starting to work with PICs and the price is pretty reasonable. Hopefully I'll be able to get off to a better start with it this time.

Edit: By the way, sorry for making you repeat yourself wp100, I hadn't noticed your previous message where you already mentioned a couple of options.

Thanks again.
 
Last edited:
nomdomokunnom

By the way, sorry for making you repeat yourself wp100, I hadn't noticed your previous message where you already mentioned a couple of options.

No problem, just wanted to reinforce things to ensure you got the right thing this time.
 
Hi,

Have just resurrected your orignal thread as I wanted to leave your Junebug enquiry for just that.

Bit surprised by your comments about buying the Pickit2 Start Kit ...? - more detail would be interesting ..

Assume you are talking about buying from Microchip Direct ? - their carriage costs are a bit steep, but not aware of any other catches, quiet the reverse as buying from them or a main dealer like Farnell is good insurance as any real fault with the unit and you will get a replacement.

Ther DV164120 PK2 Starter Kit is in stock at both Farnells and RS from whom you can buy online, the carriage was about £5 last time I ordered online. ( I'm close to Leeds so normally collect from the trade counter )

Don't want to put you off the Junebug in any way, but still think you cannot beat the Pickit2 as the ideal Starter system.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top