18F4685 not programming when using SPI

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
henker
Posts: 45
Joined: Mon Dec 22, 2008 11:22 pm
Location: Prospect, NS, Canada
Has thanked: 7 times
Been thanked: 2 times
Contact:

18F4685 not programming when using SPI

Post 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
Attachments
TC77.fcf
(6.5 KiB) Downloaded 419 times

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: 18F4685 not programming when using SPI

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 18F4685 not programming when using SPI

Post 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.

henker
Posts: 45
Joined: Mon Dec 22, 2008 11:22 pm
Location: Prospect, NS, Canada
Has thanked: 7 times
Been thanked: 2 times
Contact:

Re: 18F4685 not programming when using SPI

Post 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

Post Reply