PDA

View Full Version : Homicidal 877 user needs help



DavidFMarks
- 11th December 2007, 17:50
My Christmas star is in jeopardy ! I built a pcb based on 16f877 20 with ports c,d and b connected to darlinton chips, relays etc. Worked like a charm first time. Then whilst reinserting the chip after reprogramming I managed to get the pins out of line and (not surprisingly) everything stopped. I have bought some new 877's and replaced the voltage reg and every attempt to get the dam thing started has failed. I have now been reduced to a simple breadboard with oscillator (20meg) and caps. Pin 1 to Vdd via 1k. LED connected to Rb0 (via 1k to 0v) simple bit of code:
@DEVICE PIC16F877
DEFINE OSC 20
main:
HIGH portb.7
PAUSE 500
LOW portb.7
PAUSE 500
GOTO main
END

I have juggled around with the config settings (which I musy admit are a mystery to my ancient brain) At present the osc is set to XT
I am using an EPIC programmer with software version 2.44 and Micro Code Studio Pic Basic Pro version 2.45.
One other strange and seemingly unrelated mystery. My original code contained the sequence :
High portd.0
High portd.1
High portd.2
etc etc
After the problem occurred every effort at compiling prodce a syntax error on on of the lines - I think it was d.6
I'm sue I must be doing someting utterly stupid but I just cannot fathom out what . Any helpful suggestions would be very welcome
Cheers

mister_e
- 11th December 2007, 18:12
@ DEVICE HS_OSC, LVP_OFF
DEFINE OSC 20
PORTB=0
TRISB=0

Start:
Toggle PORTB.7
PAUSE 250
GOTO Start


Presetting Configuration Fuses (PIC Defines) into your Program
http://www.picbasic.co.uk/forum/showthread.php?t=543

Most device programmer use HighVoltage programming, and use MCLR. PGD and PGC pins. hence why you MUST disable the LVP mode.

For crystal >4MHZ, you must use HS mode.

duncan303
- 11th December 2007, 18:20
Hi

I notice that you have a 20Mhz external crystal with caps, I believe that you should be setting OSC to HS and not XT.


did you say you have 16F877 maybe also check your new chip is the same and not an 16F877A


Hope this may help

G-R-C
- 11th December 2007, 23:15
Did you happen to do anything differnt with the MCLR? Config fuses?
Another thought, if you suspect the Crystal OSC, try a resonator.
They have the caps built-in. Much simplier (in m opinion anyway).

I believe someone already mentioned it but it your switching from the
877 to the 877A this will cause you a problem if you don't change
configuration.

DavidFMarks
- 12th December 2007, 00:28
Thanks for the responses folks. I have implemented the suggestions and the plot as they say, has now thickened ! At first using my original board with the suggested changes and at first ... nothing. Then I inadvertently touched to capacito connected to the pin 8 side of the xtal my led on rb 7 began to flash , the mark space ratio was not 1 to 1 however, the on period being significantly longer. If I touch it with metal the led remains on continuously ! The caps are 22pf all the connections seem OK.
Yes I did try a resonator once before but didn't have a 20 meg (only 4) can I run the 877 20 at 4 if I change the define command. It might be worth a try as there is obviously an oscillator problem of some sort. I also inadvertently tried a 877a and as you say I got nowhere ..in fact the epic wouldn't program it. The chips I am using are new 877 20's
I wish I could use the dear old 16C84 for this job that never gave me all this grief! I am beginning to detest the 877 which is a pity since it is at the heart of a midi decoder I am using in a street organ I am building. Irony is, in that far more complex circuit it works a treat... that's what is so annoying . I shall have to go and have a stiff whisky to calm me down......

BobK
- 12th December 2007, 02:10
Hi David,

Yes you can use a 4mhz resonator or 4 mhz crystal with 22pf caps. Just change the config settings from HS to XT (actually it doesn't matter for 4 mhz but play it safe) and you should be running. The fact you mentioned just touching a capacitor made it work again makes me think you have a solder joint problem. Try re-flowing the solder to see if that clears it up. The differences between the 877 and 877A are that there are A to D's and comparators on the 877A that need to be disabled in order to use the PortA and PortE pins as digital. Check the data sheet to get the exact register names to disable.

Also make sure you have .1uf caps on both sides of the chip as close as possible to the power supply pins. These are more important on the "A" version of the chip.

I've used both the 877, 877A, and the drop in upgrade 18F452 and have to be honest, I didn't have any problems. I made 2 layer and 4 layer boards for them. I did have a wandering wire once though, and it took out my RTC chip and the uP. Also discovered the RTC crystal had to be replaced.

It's all part of the game. But it's even worse when you're on a deadline to get the damn thing working.

We're here to help David.

HTH,

BobK

DavidFMarks
- 12th December 2007, 09:46
Well, herewe are again thanks for further suggestions. I have now changed the xtal for a 4Mh resonator with changes to the config to match. Still as dead as a dodo (rather like the 6 877's which now return the Code programming error at 0000 and have presumably died)
RB7 (pin 40 remains at about .3 volts and for some reason pin 39 is at 4.9 I have incidentally checked and rechecked the solder connections and since the circuit initially worked perfectly there can't be much wrong with the layout. In fact with the darlington chips removed thereis nothing but the supply, the two decoupling caps (0.1) a pull up on mcr (pin 1) and the resonator and led connected to rb0. Is this annoying or what (The local cats are all going into hiding) andthe divorce can't be far off .. Ah well.

DavidFMarks
- 12th December 2007, 10:25
Just tries repeating the tests using the lab2x board which was also working when I started this project ... same result. So.. using three separate circuits - New pcb, Lab2x and breadboard with simplest of all jobs i.e. flashing one led (Both of the first two circuits have aleady worked previously !) still nothing . There has to be something incredibly stupid here .. only I think perhaps I am too stupid to see it !

BobK
- 13th December 2007, 02:22
Hi David,

Just a quick question. Have you metered your power supply for the proper output voltage? I know it sounds elementary but based on what I'm reading here nothing is working! Nothing on either of your 3 boards. Try removing the micro from the socket, apply power and read for proper voltage at pins 11 & 32 are + 5v and 12 & 31 are grounds. Don't forget to turn the power off before putting the chip back in. Possibly a electrolytic capacitor is in backwards?

Did your PCB's ever work? Maybe there's a short or shorts on the board. Check all of the pins on the 877 for shorts to +V and to ground.

I guess maybe it's Miller time! Sit back or walk away for the night and get a good night's sleep and try fresh again tomorrow. We've all been there! It's not a pretty site.

I know this is no consolation but it does help to walk away some time.

BobK

DavidFMarks
- 13th December 2007, 10:00
Thanks Bob,
Voltages all check out OK. I noticethat on oneofthetwo chips I am using the output on RB0 -RB7 is about 0>4 volts on one chip and >16 on the other ..is this reasonable ?
I am using three boardsto try thechips on. One is a melabs LabX2, couple of weeks ago I plugged this in and reading the manuals (yesreally !) realised that I could do ICP through the ten pin header direct from my epic programmer. I had a simple,single led flashing program working and could change the timing in circuit .. Great ! so far so good. Then that circuit began to behave as if there was a poor connection sometimes it didn't work an pressing the chip eould restart it, gradually it died altogether. I then built my "Christmas star" PCB which has the d and c ports connected to darlingtons to switch the - side of the leds and port D connected via darlingtons to reed relays to swotch the + sides of the leds which are in a matrix with diodes. I buit a ten pin header into this pcb connected as per the melabs board to enable me to ICP. This part of the circuit I have never got to work so i programmed the 877 direct and the circuit worked like a dream with main power from a car battery charger (to power all the leds) with a 7405 providing the 5 volts for the 877 circuit (I have since tried it with a completely independent 5 volt supply from another board). Then came the disaster ! whilst reprogramming I inserted the 877 into the pcb one pin out of alignment and the whole thing died.Replacing the 877 and the 7805 did nothing. The only sign of life I have ever had sincewas as mentionedin earlier post when touching pin 13 (Xtal) would produce a flashing led where I expected it (albeit with a somewhat variable mark space ratio). Thinking this indicated an oscillator problem I followed the othe piece of advice and inserted a 4m resonator and changed to program (i.e. osc set to xt and 4)
Once again it is absolutely dead. Sorry to bore you with all of this but the full story must some where contain the clue that points to the stupid thing I must have done ! I have had the good night sleep (and the whisky) and tomorrow am off to Brussels for a three day break with wife and friends where I shall sulk a bit more and drink to much wine and Belgian beer ! Many thanks for the trouble you have gone to to keep me sane !
cheers David

james
- 13th December 2007, 12:06
David,

You had mentioned that the configurations were a mystery to you. Why dont you post the configurations settings that you've been using. If you had it working once, then the code would appear to be ok. Next items to check are Configurations and hardware..and you seem to have gone through plenty of scenario's with the hardware.

I've had problems where a simple config setting has driven me nuts, and once the setting was changed it worked like a charm. If you have MCLR set as RESET then you must have a resistor tied to +5v. I havent seen any talk of this other than mister_e's post. Write up a list of what your currently using, I think it may be beneficial. Im learning aswell, my knowledge with pic chips is very limited. If you think this may be irrelevent, I apologize for wasting your time.

Good luck to you :)
James

DavidFMarks
- 13th December 2007, 12:44
Hi James,
I have always suspected the config settings but must have tried most of the permutations by now ! The settings as at the last failed test were:
oscillator XT (whilst I have the resonator in circuit)
power up timer is enabled but nothing else under the config menu
i.e.Watchdog timer,Brown out reset lvp Flash program write are all disabled
Can't see any reference to mclr but I do have 1K to +5 voltson pin 1
Thanks for the suggestions
Cheers
David

BobK
- 13th December 2007, 13:13
Hi David,

Maybe we are getting somewhere afterall. You stated that you put in a 10 pin header to allow ICSP. Did you also add the diode to block the voltage from going to the rest of your circuitry? I use ICSP to program a product I make and I do not have any +5vdc connection between the programmer and the pcb. I only use the mclr, ground, RB6, and RB7 pins. When I did another project several years ago with an 877A I also had problems doing ICSP so I gave up on the idea. I have since worked out the problems by just using the connections I gave above. I have read in several places that the PGM pin should be grounded during the programming process.

Do you have a simple breadboard that you can setup a very basic 877A with the mclr to +v thru a 1k resistor, put a led/resistor on RB0, add the 4mhz resonator and then test out the blinky program? This could help isolate whether its the PIC or your boards. You should be able to create the blinky program without adding any config settings. Just use the one that's in the MCS program.

HTH,

BobK

Jumper
- 13th December 2007, 13:40
Hi,

Could you post a picture of your HW and maybe a simple schematic. There must be a reson for the PIC not to work properly and we all wants to help.

A simple schematic will help to provide us an understanding of what levels you have where and if we compare these with what we expect them to be we might be able to spot the problem.

What does RB6 and RB7 do after you have ISCP-programmed the PIC and disconnected the programmer? I have seen of the 877A that if RB6 and RB7 are held at an unfourtunate level/timing the PIC will refuse to start up properly. I suspect this to be related to the VDD rise and then the PIC will try to enter programming mode even when a programmer is not connected.

I have 2 877A:s connecting with each other using a cable on RB6 and RB7. And if I set the pins from one PIC in a special way the other PIC will refuse to power up.

Are there any power applied to any pin of the PIC before VDD is applied?


/me

mister_e
- 13th December 2007, 13:46
and a .HEX file of your PIC program, so we can confirm your configuration fuses are set correctly. If you set them in your programmer software, you should be able to save the .HEX file, so the next time you open it, those should be set as you did.

also check if your software is set to program the configuration fuses.. yeah it happened.

mackrackit
- 13th December 2007, 13:53
The ICSP might be it.
I use a PICSTART PLUS for ICSP. Just tried a 16F877A.
All works well when the programmer is powered. If I leave the programmer connected with the programmer power off the PIC will not start.

HTH

DavidFMarks
- 13th December 2007, 15:30
Thanks all, I am assimilating your comments and will respondwith code details etc. asap. However we are shortly seeting off for a pre Christmas long weekend in Brussels and senior management is going to get difficult if I am caught at the keyboard much more. Thanks again will be back on line asap
Regards
David

b1arrk5
- 13th December 2007, 17:11
David,

I went through almost the exact same scenario almost two years ago, and after losing a little too much hair I discovered that the problem lay in my epic programmer, the one that uses the printer port. Windows XP was playing havoc with the printer port on occasion. I upgraded to the newer USB programmer from MELABS, and have not had a hardware problems since. I still get the occassional software glitch, but as those are all self inflicted............. Anyway, perhaps someone a little closer to you might offer to program a 16f877 for you, and see if that works. I would be awfully suprised to learn that you have 6 defective chips and three defective development boards, my lab-x boards run continuously, and have never been a problem. The programmer seems to be the only thing that is common to all your problems, as you said you should be able to blink an led without any difficulty.

Jerry.

DavidFMarks
- 13th December 2007, 21:45
Few quick words before heading for the channel tunnel. Built a quick breadboard just the four power supply connection, resonator 1Y pullup on pin 1 and and led on RB7. With the software recommended earlier in this thread ... nothing... except, as once before when using the crystal if I touch pin 13 then the led flashes, trouble is its flash rate doesnt seem to have much to do with the program !! Jerry you could be right about the epic, I seem to recall having problems with it in the past I will look into it when I get back from the Brussels trip.
Cheers everyone
David M

Darrel Taylor
- 13th December 2007, 22:53
<table><tr><td valign="top">Probably just another stupid question on my part.

But, are you sure the Power Rails are connected across the entire breadboard?</td><td>
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2204&stc=1&d=1197587602" /></td></tr></table>

mister_e
- 14th December 2007, 00:04
i remind some bread board brands have some break in the middle of their +/- line too

Unless you hit the wall or you do a simple continuity test when you buy it, you don't know...

Crystal or Resonator? Some resonator may don't have the built-in cap. 15pF-22pF

Seems weird.. it's more a matter of crystal and capacitance to me.. unless the crystal is defect or totally out of spec... Some 4MHz could be lazy so far.. what happen if you set HS osc mode?

Some may require an external resistor in parrallel.. never meet one of those 'till now.

One thing is sure... when you touch it, you modify capacitance to the OSC line... it speak loud to me.

DavidFMarks
- 19th December 2007, 16:39
Back in harness after the Brussels trip. The light show in the city square was absolutely fantastic.. bet they weren't using 877's. I have spent another fruitless day finally junking the 877 circuit and deciding to use a 16F 628A which is what successfully controls my smaller Xmas star (which is flashing even as we speak). You kow what the &*(*^)(& 628A didn't work either. I then programmed it with the program which is operating the other star and that doesn't work either. So ..... Jerry it looks as if you may have hit the nail on the head and this wretched EPIC programmer is the cause of the problem. It seems to be programming OK there is certainly hex code there which I can read back and verify OK. Is the Epic programmer really that bad that it can apparently program and verify but still screw up the code in some way. Being retired I am not keen on going out to buy another programmer (they seem to be a hell of a lot dearer now). The only other thing I can think of is that the transformer I am using to power it is inadeque. It is nominal 15 vdc but the multimetwr tells me it is 21.9 volts on no load and drops to 20 when connected to the EPIC

mister_e
- 19th December 2007, 16:49
mmm, if you don't have any programming error, this should work, unless the configuration fuses are not programmed. Are you sure the EPIC is set to program the configuration fuses?

Can you post your compiled .HEX files here?

DavidFMarks
- 19th December 2007, 23:32
Thanks Steve.. I,m now going to demonstrate my ignorance .. I'm not sure I understand about programing the config fuses, just produced the program the way it seemed to work in the past. I will now try to find where the system has stored the hex file and then find out how to add it to a post !!
Cheers David

mackrackit
- 19th December 2007, 23:36
I will now try to find where the system has stored the hex file and then find out how to add it to a post !!
Cheers David
It should be in the directory where you saved the project.

DavidFMarks
- 19th December 2007, 23:54
I am attaching the hex file for the 16f626A which is currentlt running my old star but which when (apparently) programmed into a new chip doesn't run. Can't see how to add a hex file so have converted it to RTF Is that OK ?

DavidFMarks
- 19th December 2007, 23:55
Whoops, finger trouble, I meant 16F628A !

b1arrk5
- 20th December 2007, 01:19
David,

My old EPIC programmer served me well, but whenever I made any change in WindowsXP I started having programming problems. The guys here help me narrow it down to Windows poor driver/memory management. No one uses printer ports anymore I guess. I upgraded to the MeLabs USB programmer, and it works great. If your EPIC was the same as mine you could try two 9 volt batteries instead of the transformer. Have you looked under the View menu at the memory to see if it changes after you program a chip? It should look like the hex file that you attached earlier. You might also try downloading the Beta loader software from MeLabs website, it should work with your EPIC programmer, and if you haven't already, take a look at http://www.melabs.com/support/epicfixs.htm

Of course I might be leading you astray, but Darrel or Steve or one of the other gurus will figure it out. I don't mind being wrong, I still learn something!

Merry Christmas to all!

Jerry.

mackrackit
- 20th December 2007, 02:13
Never used an EPIC but this thread looks like a similar problem. Post 5 by Bruce.
http://www.picbasic.co.uk/forum/showthread.php?t=3929&highlight=reading+file

And if I am reading your hex file correctly, the osc is set for RC?

b1arrk5
- 20th December 2007, 02:48
Dave,
How do you know where in the hex file the oscillator setting is? I was proud of myself because I could count to ten in hexadecimal, but now I'm just amazed that you could decipher that. You gave me a good idea though, David could go under View in the EPIC programmer window, and post exactly what the configuration is set to, and then look under Options as Bruce suggests in the other post regarding the re-read file setting.

Jerry.

mackrackit
- 20th December 2007, 03:15
If I did it right.
Opened MPLAB, set the Pic Being used, import the hex and see what MPLAB has for the configuration.

This may not be the best way but it seems to work.

nomad
- 20th December 2007, 03:56
There's a fix for printer port issues and epic.
from melabs download section:


Stop Windows XP from polling printer port
Windows XP may periodically access printer ports and interrupt the EPIC™ programming process. This can be stopped with a registry entry.

Download the registry entry file below and merge it into your XP registry.

Download XP_stop_polling.reg (1K)


http://www.melabs.com/support/patches.htm

it programmed and verified ok, there's something wrong with the code or hardware, be it config fuses or tris or icsp left connected.

As far as programming and verifying ok, lol, I just had a hell of a time with my led project. thought I fried the pic, programmed and verified perfectly. spent 3 hours only to find I goofed and set the trisa and trisb to 255 (all inputs) oops! inputs aren't going to make anything blink. lol don't they default to inputs if tris isn't set?

my programmer, if left connected puts -7volts on all the pins.. definately not a good idea.

DavidFMarks
- 20th December 2007, 09:24
Thought the osc had to be set to intrc to use the internal oscillator, now realise it should be set to XT. Have now written simple program to switch on all port b pins, pause and swithch them off again in an endless loop. The program containsthe line cmcon = 7 can't remember why but I recall having to do this about a year ago when I wrotethe original star program. The osc isset to XT it compiles and produces the attached hex file but fails to flash the ports

b1arrk5
- 20th December 2007, 14:09
David,

If you're using a 20 MHz crystal the oscillator has to be set for HS (High Speed) XT is for a 4 Mhz crystal. I've never used the internal oscillator as all of my projects seem to need serial ports or something that requires better timing.

Dave,
Thanks, I never thought of that!

Jerry.