16F84A programming problem

Thread Starter

emslots

Joined Jun 3, 2012
12
Hi,
A new analogue synthesizer project I am working on has led me into the world of PIC's, and as I have mainly worked in analog, I am finding PIC programming a bit difficult....

Here's what I am trying to do - the synth uses a MIDI to CV converter for translating MIDI signals from keyboards, etc. to analogue voltages for notes, and a trigger output for the envelope generator.

For the MIDI converter circuit, I need to program a PIC16F84A with some already working and tested .asm code I have obtained from the code author/cicruit designer (written for PIC16F84).

I have successfully converted .asm to HEX using MPLAB IDE, and have been programming the chip using a PIC K150 programmer from an eBay seller, but it will not work no matter what configuration settings I set up.

I can no longer contact the program author, so cannot confirm the configuration settings, and have spent many frustrating hours trying to get the PIC programmed - so could I be missing something very basic here?

The PIC circuit is attached.

Any help would be greatly appreciated!
 

Attachments

MrChips

Joined Oct 2, 2009
30,806
Good to show the circuit diagram but how do you know the code works?
When you are in a situation like this you have to tackle things yourself and wrestle it to the ground.
How much experience do you have programming PICs?
How do you know that the chip is being programmed?
I would begin with a PIC16F84A on a breadboard and see if you can program it to make an LED flash.
 

Thread Starter

emslots

Joined Jun 3, 2012
12
The code was originally used to program a 16f84A that the author then sent to me. It worked, but eventually went faulty, hence the need to program a new one.

I am a complete PIC newbie, so have been picking up information where I can from various sites on the net.

When programming the PIC with HEX, I get a message saying that the programming was successful, so presumably no problem there.

Meanwhile, I will try a simple LED flashing program as you suggest, and see what happens....
 

MrChips

Joined Oct 2, 2009
30,806
Ok, good start.
Next we have to find out the differences between PIC16F84 and PIC16F84A.
Followed by looking at the configuration bits.
 

Thread Starter

emslots

Joined Jun 3, 2012
12
Yes, I had wondered if the fact that the code was written for 16F84, and we are using 16F84A, was an issue.

Regarding configuration bits, these were all added externally (they are not embedded in the code). The only one I did not experiment with was code protect, because it was not really necessary in this case, and I have heard it can cause problems with re-programming if it's altered.

I have tried the other three in various combinations.

Incidentally, the PIC supplied by the author was a 16F84A, so that is the type I have been using since.
 

Thread Starter

emslots

Joined Jun 3, 2012
12
The AD7528 Digital to Analogue converter has been replaced, just to confirm that the circuit is OK, but it made no difference.

If it is any help, the MIDI input signal from the opto-isolator disappears at pin 13 of the PIC, but if you remove the PIC from the circuit, it is present.
 

Markd77

Joined Sep 7, 2009
2,806
Configuration settings:
XT oscillator : recommended value for 4MHz crystal
WDT : likely to be off, most programmers don't use it
PWRTE : most likely on, although it probably won't make any difference
CP : probably off, shouldn't make any difference
 

Thread Starter

emslots

Joined Jun 3, 2012
12
Configuration settings:
XT oscillator : recommended value for 4MHz crystal
WDT : likely to be off, most programmers don't use it
PWRTE : most likely on, although it probably won't make any difference
CP : probably off, shouldn't make any difference

I have tried those settings once or twice - but I will try again (I have mainly used HS for the oscillator setting).
 

Thread Starter

emslots

Joined Jun 3, 2012
12
Sadly, those settings didn't work, but thanks for the suggestion - at least I now have some idea of how they are supposed to be set!
 

MrChips

Joined Oct 2, 2009
30,806
I cannot provide much help at this point except the following:
The code uses software timing delays and is designed for 4MHz operation.
You cannot use HS oscillator mode. Use XT mode.
Can you confirm that the MCU is running at 4MHz?

What is the part number written on your PIC?

Also you still have to figure out why RB7 is killing the MIDI interface.
 

Thread Starter

emslots

Joined Jun 3, 2012
12
Hi,
I'm getting 4.2 MHz from the crystal (measured at pin 15).

The PIC part no. is PIC16F84A-04/P.

I have checked the circuit all around pin 13 of the PIC and pin 5 of the opto, but there are no shorts to ground or unusual resistances anywhere near.

Weird!
 

Thread Starter

emslots

Joined Jun 3, 2012
12
STOP PRESS - just tried the same PIC and DAC on a different board, and SUCCESS! Getting a gate signal and the DAC is giving voltage outputs that are proportional to notes on the MIDI keyboard (approximately, as it is yet to be set up properly).

It looks as though there could be a problem with a short under the MIDI channel selection switch somewhere, as I was getting a permanent 5V on pin 8 of the PIC (which I only just noticed). Never mind, I have the PIC working and that's the important thing!

Thanks to all who offered their help, it is very much appreciated; I will try to contribute something to the forum on another subject if I can.
 

ErnieM

Joined Apr 24, 2011
8,377
I played around a bit with the pdf code. It took some scrubbing to get back the formatting removed by the pdf process.

I dropped it into MPLAB and built a project with it, making a few changes to make it a bit more compatible with MPLAB around line 49-52, then removed some duplicate defines thru lines 56-77.

I added some fixed config bit settings. The first time thru the simulator it chocked on the watchdog timer, as this was on by default. I believe the config settings I used would work with your project.

See if you can get this thing to build. I left my hex in the zip in case you can't.

(I must be bored today) :D
 

Attachments

Thread Starter

emslots

Joined Jun 3, 2012
12
Thanks for taking the trouble to do all that - it seems to be working OK with no Watchdog Timer, no Code Protection, XT oscillator and no PWRTE. The fault was down to me (yet to find it on the first board, but there is a short somewhere).

Human error on my part I am sorry to say!

I will try your revised code and let you know the outcome.

Thanks again.
 

Thread Starter

emslots

Joined Jun 3, 2012
12
ErnieM,
I tried your revisions, and the code built fine, but did not work when HEX applied to the chip - never mind, I'll stick to the original code now I have it running, but thanks once more for your efforts.

Enjoy the rest of the holiday!
 
Top