Page 1 of 1

18F4685 not programming when using SPI

Posted: Sun Jan 02, 2011 3:36 pm
by henker
Hello All,
I'm interfacing a TC77 SPI Thermometer to a 18F4685.
I'm using FC V3 and the issue I'm having is that as soon as I'm adding the SPI Macro, I'm getting problems programming the PIC.
When programming, the PIC is not recognised anymore. I have to Manually Erase (in PPP) the PIC before I can reprogram.
Has anyone had this issue?
I presume it is a clock issue. Attached is the sample.
Thanks
Henk

Re: 18F4685 not programming when using SPI

Posted: Wed Jan 05, 2011 8:02 pm
by Jan Lichtenbelt
Dear Henk

I tried your program with Flowcode 4. The simulation works correct. I do not have the 18F4685, but loading in a PIC gave an error. I hope Steve or Ben can help you.

I have a remark. Do not divide by 16. The simulation works correct, but in a PIC you can get wrong results. Better is to use rotate right for dividing numbers with are a power of 2. In stead of /16 use >>4.

Good luck

Jan Lichtenbelt

Re: 18F4685 not programming when using SPI

Posted: Thu Jan 06, 2011 1:40 pm
by Benj
Hello Henk,

I had a similar problem when using a SPI device on an AVR. Basically if the SPI pins are commoned with the programming pins then the slave SPI device can interfere with the programming signals. To get around this I had to add hardware to disable the CS pin of my SPI slave device if the uC was put into reset.

Re: 18F4685 not programming when using SPI

Posted: Sun Jan 09, 2011 11:17 pm
by henker
Ben / Jan,

Thanks for the reply.
It is a weird problem; I picked up the project several days ago (Hadn't used the PIC for about three days) and it programmed correctly without any hasstle.
One of my friends also has some issues with this type of PIC when programming it.
Anyway, if it happens again, teh way around it is to just erase it in PPP and then program it.

Thanks for the help!
Henk