Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 3rd August 2004, 04:19 PM   (permalink)
Default Testing a PIC controller

Hi,
As some of you may be aware, I am trying to get a 16F627 working in a Velleman kit. I have very limited exposure to this coding, and not having a working application is not assisting matters...
(see http://www.electro-tech-online.com/v...ic.php?t=10570 also)

I have been able to confirm that the PIC is processing some instructions, but it appears to be sticking on some code:

Here is a sub procedure in the code:

Code:
DELAY		MOVLW   D'150'          ;*	;Put 150 decimal in the 'TIMER1' register.
                MOVWF   TIMER1          ;*
                ;
DELAY2		MOVLW	D'150'			;Put 150 decimal in the 'TIMER2' register.
	MOVWF	TIMER2
	DECFSZ  TIMER2,F        ;*	;Timer2 = Timer2 -1, skip next instruction if Timer2 = 0.
                GOTO    $-1             ;*	;Jump back 1 instruction.
                
	DECFSZ	TIMER1,F		;Timer1 = Timer1 - 1, skip next instruction if Timer1 = 0
	GOTO	DELAY2			;Jump to 'DELAY2' routine	
	RETLW   0			;Return (jump back to main) and load W-reg with 0.

The PIC seems to get stuck at the point where the first DECFSZ appears.
I was able to confirm this by doing a MOVWF PORTB to change LED's in sequence, incrementing the LED count per line.

Question #1 is: Is there an element in this code that is not supported on the 16F627 chip?

Question #2 is: Does anybody have a small piece of code that will serve to prove the operation of my Velleman circuit board... A simple LED on/off example would do.

Thoughts on the matter shall be considered and appreciated... :-)
Attached Files
File Type: txt f84demo1.txt (7.2 KB, 42 views)
McGuinn is offline  
Old 3rd August 2004, 04:30 PM   (permalink)
Default

Check my tutorials, the 627 is just the smaller memory version of the 628 used in my tutorials - there's plenty of test examples there, starting with flashing LED examples.

For generating delays it's simpler to use a software loop rather than get involved with the timers, this is what my tutorials do - you can generate code for delays using an online generator on the PICList.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 3rd August 2004, 04:49 PM   (permalink)
Default

Nigel, the code is using a simple software loop, the author just named his variables 'timer1' and 'timer2' (its not TMR1 and TMR2)...

the problem is that this example was written for a pic16f84A. the data memory adress for the timer1 and timer2 variables are starting at position 0x0C, wich is where the f'84 ram starts...

on the 'f627 however, these positons are SFR's (PIR1 and a reserved space). wich is why the loops gets stuck...

also, the code doesn't turn off the analog comparators...

I'll change the code for a 'f627 and post it here if i find the time
Exo is offline  
Old 3rd August 2004, 04:51 PM   (permalink)
Default

OK, thanks for the pointer. I'll apply the code for the flashing LED's...

I'm wondering if the programmer board is a cause for the hanging, and a proper (known to work) program would prove this.
McGuinn is offline  
Old 3rd August 2004, 04:55 PM   (permalink)
Default

No, i just explained, the code was written for a Pic16f84. Running 16f84 code on a 16f627 is what causes the crashing

is it a 16f627 or a 16f627A that you have?

asuming its a 16f627 try what this does...
Attached Files
File Type: txt f627demo1.txt (3.1 KB, 31 views)
Exo is offline  
Old 3rd August 2004, 06:00 PM   (permalink)
Default

there is a 84 => 628 migration document on the microchip website. that might of be some help
samcheetah is offline  
Old 4th August 2004, 11:44 AM   (permalink)
Default

Quote:
Originally Posted by Exo
No, i just explained, the code was written for a Pic16f84. Running 16f84 code on a 16f627 is what causes the crashing

is it a 16f627 or a 16f627A that you have?

asuming its a 16f627 try what this does...
Exo,
Our posts crossed, so my last post was in reply to Nigel's and I didn't see yours till now.

I loaded Nigel's code onto my 16F627 (not the A version) and tried to run it. It did nothing, and then I realised that I have port A hardwired as inputs, while Nigel's code uses it as an output.
I REM'd out the lines loading the port as an output, and re-assembled the file, but on trying to write it back onto the PIC, all of the LED's lit (and remain lit) and the PIC seems to be blown!!! It won't respond to reads or writes... (have reset/rebooted...)
I'll order a new one!
McGuinn is offline  
Old 4th August 2004, 12:39 PM   (permalink)
Default

As a matter of interest, what PIC Sims are people using?
DonTronics has one called Oshon, but is this the best?
McGuinn is offline  
Old 4th August 2004, 01:06 PM   (permalink)
Default

Quote:
Originally Posted by McGuinn
I loaded Nigel's code onto my 16F627 (not the A version) and tried to run it. It did nothing, and then I realised that I have port A hardwired as inputs, while Nigel's code uses it as an output.
I REM'd out the lines loading the port as an output, and re-assembled the file, but on trying to write it back onto the PIC, all of the LED's lit (and remain lit) and the PIC seems to be blown!!! It won't respond to reads or writes... (have reset/rebooted...)
I'll order a new one!
It may be that your programmer doesn't select programming mode fast enough, the 16F628 and 16F627 have an internal oscillator, if that's selected the programmer needs to set programming mode before the oscillator has time to start. Once the oscillator has started you can't set programming mode.

Which tutorial code did you use?, the first one (deliberately) flashes the LED's far too fast to see, the second one adds a delay to give a visible flashing.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 4th August 2004, 01:43 PM   (permalink)
Default

The second one...
I REM'd out the lines as follows:

Code:
   	movlw 	b'00000000'		;set PortB all outputs
   	movwf 	TRISB
	; movwf	TRISA			;set PortA all outputs
	bcf	STATUS,		RP0	;select bank 0
...and the related movwf PORTA's in the rest of the code.
... but I think the damage was done.
McGuinn is offline  
Old 4th August 2004, 01:48 PM   (permalink)
Default

Quote:
Originally Posted by McGuinn
... but I think the damage was done.
You shouldn't be able to damage the PIC in that way, they are extremely hardy devices.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 4th August 2004, 02:38 PM   (permalink)
Default

I don't believe it's bust eighter... It's probabely just running on internal oscillator making it have trouble switching to programming mode...

does the velleman software allow you to change the vpp delay?
Exo is offline  
Old 4th August 2004, 04:15 PM   (permalink)
Default

Quote:
Originally Posted by Exo
does the velleman software allow you to change the vpp delay?
Not now as it cannot communicate with the PIC.
It looks to get an ID from the chip first and it's flagging this as unavailable.

I have a 628 I will use till radionics deliver new ones...
McGuinn is offline  
Old 4th August 2004, 04:54 PM   (permalink)
Default

Quote:
Originally Posted by McGuinn
Quote:
Originally Posted by Exo
does the velleman software allow you to change the vpp delay?
Not now as it cannot communicate with the PIC.
It looks to get an ID from the chip first and it's flagging this as unavailable.
Vpp delay isn't anything to do with the PIC, it's the programmer software, the delay between turned Vdd ON and turning Vpp ON - it needs to be short enough to prevent the internal oscillator starting up.

There is no ID from the PIC, it's most likely that the chip can't be switched to programming mode, simply because the Vpp delay on your PC software is too long.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 9th August 2004, 02:33 PM   (permalink)
Default

I was able to spend time working this over the weekend.

It looks like a made a mistake... I loaded Nigel's first LED flasher onto the PIC, and not the second one. So the chip is running, and you are correct in saying that I am unable to program it because of the VPP delay.

When I now select program mode using a physical switch on the board, the chip goes into run mode, even though it's getting the correct programming voltage on pin 4 or 14 (can't remember which).

My software won't pick it up now... How can I change the VPP delay now?
I'm using a serial port, and WinPIC won't work...
Do I need to hold an input low/high to invoke it?

I'll start reading this link on the PIC's shortly...
http://www.mikroelektronika.co.yu/en..._08chapter.htm Seems good.
McGuinn is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 04:34 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker