Help troubleshooting JDM PIC programmer

Well, my PIC 16F690s arrived in the mail, and I soldered up an ICSP-only version of the JDM programmer to program them. Unfortunately, and not at all surprisingly, it doesn't work -- the PIC programming software (picprog, in linux) doesn't see the PIC:

$ picprog --output saved-cal-chip1.hex --skip-ones --pic /dev/ttyS0
Picprog version 1.8.3, Copyright © 2006 Jaakko Hyvätti <[email protected]>
Picprog comes with ABSOLUTELY NO WARRANTY; for details
type `picprog --warranty'. This is free software,
and you are welcome to redistribute it under certain conditions;
type `picprog --copying' for details.

value: 0xffff version: 0xffff
/dev/ttyS0:ff0002:unable to read pic device id
Here's the pinout for the 16F690, for reference:

|x

And here's what my circuit looks like (except I didn't include the socket, just the ICSP header):

|x

I only have a really weak grasp of what exactly the JDM programmer is doing and how, so it's hard to debug it, but it IS my understanding that the PIC needs to see 12v between pin 20 (Vss) and pin 4 (Vpp) in order for it to go into programming mode. With my programmer connected, I don't see any voltage difference between Vss and Vpp. I do see 5v between Vss and Vdd (pin 1), and I also see 5v between Vpp and Vdd. So I guess Vpp is at 0v for some reason. Obviously I must have some error in my circuit, but I'm having a hard time figuring out what could be wrong.

I understand that the first zener diode, D2, should bring the voltage to 5.1v, and the second zener diode, D6, should bring it to 5.1 + 8.2 = 13.3v. In other words, the voltage across C2 should be 13.3v. I do measure 5.1v between pin 7 of the serial port (RTS) and the cathode of D2, as expected, but when I measure between pin 7 of the serial port and the cathode of D6, I see 5.0v, not 13.3v. I also get 5.0v if I measure across the two terminals of C2. So either there's a problem around there, or I'm misunderstanding how the circuit is supposed to work.

Looking at the output, I'd expect to see 13.3v between pin 3 of the ICSP header (Vss) and pin 1 (Vpp), or if not that, at least the 5v I'm getting from C2. But actually, I see 0v across those pins. That appears to be because the base pin of Q1 (TxD from the serial port) is at 0v, so the transistor isn't allowing any current through. I do see the 5v from C2 at the collector of Q1, but nothing at the emitter.

So I guess what I'd like is for some of you guys with working JDM programmers to hook them up and tell me what you measure on yours. To begin with, I'm particularly interested in the voltage between pin 7 of the serial port and the cathode of D6, and the voltage across the terminals of C2 (which, as I understand it, should be the same as that first measurement). I'd also like to know the voltage between pin 7 of the serial port and pin 3 of the serial port (TxD). Finally, I'd like to see your voltage between pin 3 of the ICSP header (Vss) and pin 1 of the ICSP header (Vpp/MCLR).

Hopefully that will help me track down what I did wrong with my circuit. Thanks in advance.

Dan

Huh. Actually, I might have

Huh. Actually, I might have it working now. After doing a whole bunch of troubleshooting, debugging, multimetering, etc, on both Linux and Windows machines, I had pretty much convinced myself that there wasn’t anything wrong with my circuit and it SHOULD work, but WinPicProg and IC-Prog in Windows didn’t seem to recognize it either. So as a last-ditch effort I upgraded to the latest version of picprog (1.9.0) in Linux, and that seems to have worked?

$ picprog --output saved-cal-chip1.hex --skip-ones --jdm --pic /dev/ttyS0
Picprog version 1.9.0, Copyright © 2008 Jaakko Hyvätti <[email protected]>
Picprog comes with ABSOLUTELY NO WARRANTY; for details
type picprog --warranty'. This is free software,<br />and you are welcome to redistribute it under certain conditions;<br />type picprog --copying’ for details.

Trying realtime priority 1
Cannot use real time scheduling: Operation not permitted
Bound to CPU 0
Using >1 µs delays. --rdtsc may work for faster timings.
/dev/ttyS0: id 0x1406: detected pic16f690 version 0x06
Device pic16f690, program memory: 4096, data memory: 256.
Reading program memory,
reading data memory,
reading id words,
reading fuses,
done.

I guess now it’s time to start writing to the chip and see if I can’t get this LED to light. So don’t worry about taking those measurements, unless I come back and find that I’m still having trouble :slight_smile:

Dan

PicProg
I don’t suppose you have a Windoze machine? Both ICPROG and WINPIC have a mode where you can set the /MCLR, VPP, ICSPDAT and ICSPCLK lines high and low at will.

I did install Windows in a

I did install Windows in a virtual machine to run that hardware test mode in IC-Prog, and that was part of what convinced me that my circuit was working properly.

Hah! Just got the LED to turn on. Phew, that was an ordeal. But I know a hell of a lot more about what’s going on inside that little black chip now :slight_smile:

Dan

It sure takes more code to

It sure takes more code to get an LED on in ASM :slight_smile:

    list  p=16F690    ;tell assembler what chip we are using
include “p16f690.inc”
__config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF

org 0x0
START:
; switch to register bank 0
bcf STATUS, RP0
bcf STATUS, RP1
; init PORTA
clrf PORTA

; switch to bank 2
bsf STATUS, RP1
; use digital I/O
clrf ANSEL

; switch to bank 1
bsf STATUS, RP0
bcf STATUS, RP1
; set RA2 as the only output
movlw b’111011’
movwf TRISA

; switch back to bank 0
bcf STATUS, RP0


; set RA2 high
movlw b’000100’
movwf PORTA

; loop forever
goto $

end


Dan

Bloat

If you look at a PICaxe HEX file, I bet the binary is bigger for a BASIC program than it is for a RISC assembler program!!

Most of it’s bloat. All that variable crap at the start doesn’t really count as “code”. I can give you some shortcuts:

Instead of

   ; switch to register bank 0
bcf STATUS, RP0
bcf STATUS, RP1

use the compiler directive

   BANKSEL PORTA

That automatically modifes the STATUS bit for you. Of course you might also BANKSEL TRISA if you wanted bank 1. Your code is mostly configurationa nd this is about as much configuration as you need. You main program doesn’t really start until you get to:

 ; set RA2 high

If you use one of the PORTB pins for the LED, you can leave out

   ; switch to bank 2
bsf STATUS, RP1
; use digital I/O
clrf ANSEL

because we don’t care if it’s an analog input by default. I would probably also leave out:

   ; switch to register bank 0
bcf STATUS, RP0
bcf STATUS, RP1
; init PORTA
clrf PORTA

Anyway: well done! Seriously! You have a gift for this stuff!

Stick with it - it’s brilliant fun and, llike you say: it gives you a ton of insigt into what’s going on inside the chip!

BASIC is for girls.

Ah, thanks, all good tips.

Ah, thanks, all good tips. Yeah, so far my code is mostly just things I’ve copied and pasted from tutorials and the datasheet – now I get to start learning what I don’t need, what can be done more concisely, etc. Exciting :slight_smile: And I love how much smaller this is than, say, and Arduino board – it’ll be nice to not have to dedicate the space of one-and-a-half business cards for my robot’s brain when a single chip and a voltage regulator would do just as well.

Dan

Hehehe, now I 'get’

Hehehe, now I ‘get’ LadyAda’s comment in her PIC vs AVR page: “Overall, I’ve written some asm for both processors and I hate to break it to PIC users but writing assembly for PIC is akin to stabbing myself in the face. (Except its not even that efficient, cause you have to move the knife into the working register first (movlw KNIFE), and then you can stab yourself (movwf FACE).)” :slight_smile:

Dan

…for now…
Soon, you’ll probably be wishing you had an extra op-amp or a relay or something…!

Correct me if I’m wrong…

…but don’t microporcessors ALL have to move a value into an arithmetic register before performing operations on them? I grant you that the higher level processors do a lot for you in the background, like shifting stuff in and out of the ALU in hardware.

Whoever wrote the article is misguided. What’s this nonsense about the compiler only working for a week? U’ve been using it for as long as I can remember! It would be nice to know the published date. It may be a very very old artilce.

PIC RISC is so called because it’s a Reduced Instruction Set. The clue is in the name. Sure, the higher level language the less lines of code you have to write. But the less control you have over the core. AVR maybe does a lot for you in the background, but that means it uses more clock cycles per operation, which means it has to run faster, which means it uses more juice.

At the end of the day if you want someone else to do the work, you could get a one-line program. I see the command “tertris.exe” as a one-line program. Someone else has done all the work. I just need to type the one line and it does almost exactly what I want.

Imagine C hadn’t been invented and Windows was written in assembler… We would all still have 100MHz 486 PCs instead of ridiculously expensive, power guzzling 2GHz ones!

Programmers don’t understand hardware. You are in the position of having the ability to grasp hardware AND software and that’s a rare combination. Program in BASIC if you want, but you’ll end up with a power-hungry, bot with an expensive support framework which you don’t really understand or require.

All in all, the two systems are incomparable. Both have pros and both have cons. There is always choice.

This is an extract from my new publication “The Philosophy of BoA” (BoA, 2008)

That PIC vs AVR page is
That PIC vs AVR page is ■■■■■■■■■ I could not believe some of the points in it. I am very mad right now.

Haha I knew it would stir

Haha I knew it would stir people up. Personally, I can tell it’s biased (and she clearly admits that she is too), but I’ve got enough friends who are Mac fans and friends who are Windows fans that I long ago stopped worrying about whether or not someone else agrees with my choice of platform :slight_smile: I like what they did on the OpenCircuits page for microcontrollers as they go through and list all the most popular microcontroller platforms: “Somebody always thinks their microcontroller is the best microcontroller, so we have listed all of them as best.” And sure enough, as you scroll through the page, each type of uC is listed as the best one :slight_smile:

Just like Macs and PCs, each option has their strengths and weaknesses, and there are situations where each one is the best choice. But unlike Macs and PCs, microcontrollers only cost a couple of dollars, so you can actually buy one of each and use whichever best fits the situation. With computers, you usually have to choose one or the other and live with the compromise. We’re lucky in the world of microcontrollers because we don’t have to make that choice – as long as you’re willing to learn multiple different systems, you can have the best of all worlds.

Dan

This is a very accurate PIC

This is a very accurate PIC vs AVR page, and it has a great outcome too!

 

NEITHER :smiley:

 

http://www.electricstuff.co.uk/picvsavr.html

PIC serial programmer trouble

Hello everyone !

I am new to PIC so I started of by making the PIC Serial Programmer. The circuit seems fine but my PIC16F84 isn’t getting the required 5V. A voltage of 11v reaches my IN4148 diode but practically zero comes out. I tried reversing my diode and swapping it with a new one but no use. I also tried by giving an external 6v supply to my regulator. I got the necessary 5v at the PIC but ICPROG is detecting my PIC.

 

Please Help

Thanks !