PIC16C505, does it automatically lock? - Page 1
Forum section: electronics / general

author: Stonent
author_rank: Super Contributor
timestamp: November 09, 2013, 11:12:36 am
content: I got my Velleman Pic programmer working and just for the fun of it I pulled the PIC16C505 from my Velleman TV Tennis game and tried to read it. It looked like it finished but then it got an error OSCCAL 3FFFI'm guessing that's its way of telling me "Scram! The door is dead bolted and you're not coming in!" ?Since the 16C chips are one time programmable, do they automatically enable code protection?

author: Crazy Ape
author_rank: Regular Contributor
timestamp: November 09, 2013, 03:49:38 pm
content: Automatically enable code protection? Nope.The code protection is set via the configuration bits just like in a flash based PIC.Page 37 of the data sheet.http://ww1.microchip.com/downloads/en/devicedoc/40192c.pdf

author: garak
author_rank: Contributor
timestamp: November 09, 2013, 05:54:37 pm
content: From memory, OSCCAL on that PIC is a 14 bit word, and I'd be willing to bet a few slices of pizza that 0x3FFF (i.e. all ones) is an invalid value, something is pulling the data line constantly high. You should check your socket/wiring. Are you using a real serial port for this? If not, then this could also be the cause.

author: Stonent
author_rank: Super Contributor
timestamp: November 09, 2013, 09:07:21 pm
content: Yep full built on the motherboard serial. None of this USB nonsense.

author: garak
author_rank: Contributor
timestamp: November 10, 2013, 09:34:33 am
content: A quick Google seems to reveal that you're not the first to have trouble with the 16C505 and the Velleman programmer, but I only had a quick look and didn't find any solutions. If you're sure that the programmer is working correctly then you might just be out of luck. You could also try going to velleman's site and getting the latest software. The copy they provide on disk is probably ancient.I started off with the Velleman programmer too (seems like a long time ago, now) and I found it pretty limiting. If you really want to get into PIC work, you'll be far better off with something like a PICKit 3, which can be had for about $45USD+S/H. Using one of these will allow you to use all the tools etc that MPLAB gives you, including In-Circuit debugging, which will be very handy. I personally use a MikroProg from MikroElektronica which was more expensive, but since I use their compiler anyway it made sense.Here's a link to the PICKit3 in the US:http://www.microchipdirect.com/ProductSearch.aspx?Keywords=PG164130Their lead time is pretty awful though. Sparkfun have the same thing for $50here, but a little hunting might reveal a better price.

author: Stonent
author_rank: Super Contributor
timestamp: November 10, 2013, 10:55:18 am
content: Yeah I can program the pic that came with it just fine and the demo hex file tests all the buttons and leds on the board works. I bought the velleman kit because it was $6 at RadioShack and have never played with Pics before. Just AVR and MSP430. It has a port on the board that you can plug a pickit into so it is useful as a premade programmer with sockets for 8 pin through 28 pin chips.

author: garak
author_rank: Contributor
timestamp: November 10, 2013, 11:33:34 am
content: Ahh, for $6 that wasn't a bad buy at all. That's probably less than it costs Velleman to actually make the things. Methinks RS are doing some stock clearance.The other thing you could try would be to go into the software settings and turn the speed down as far as it can go. It'll take a lot longer to read, but it might actually be able to do it.Of course, the other possibility is that code protection is indeed turned on. I've not done ANY PIC work in about a year, and nothing on PIC16 for twice that, but IIRC you should be able to read the config bits regardless of the state of the code protection. This will tell you if code protect has been turned on.EDIT: Having let my head tick along a little more, I'm now pretty sure that your device has CP enabled. I think what's happening is that the programmer software is attempting to extract the OSCCAL value from the code so that it can be used again, and since the CP is turned on it gets nothing. It's still worth reading the config bits if you can, because I am rusty and by no means an expert, but I'm pretty sure it's locked down.

author: JTR
author_rank: Regular Contributor
timestamp: November 10, 2013, 11:50:07 am
content: Quote from: garak on November 09, 2013, 05:54:37 pmHawaiian, with extra pineapple.The PIC16C505 is a BASELINE part. Its OSCCAL is 12-bits.

author: amyk
author_rank: Super Contributor
timestamp: November 10, 2013, 12:46:28 pm
content: Try to read the config word first, it is readable even if code protection is enabled (and if it's not readable, then suspect the programmer/connections.)