PICKit2 clone loads FV-1 i2c bus

Started by Digital Larry, May 31, 2018, 12:23:15 AM

Previous topic - Next topic

Digital Larry

I got a cheapo Chinese PICKit2 clone and it actually works fine to program the EEPROM in my FV-1 board.

When I have the PICKit disconnected, as expected SDA and SCL are about 3.3 volts.  With the programmer connected, that drops to 1.8 volts.  When I run a program or read command, the waveforms swing 0 to something and so it works fine.  I am just wondering why the programmer would load the bus when it's idle?  I don't have a real PICKit2 handly for comparison so I can't tell if it's just an attribute of this particular clone.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

free electron

http://ww1.microchip.com/downloads/en/DeviceDoc/51553E.pdf - page 78
As you can see the pickit2 and most likely the clones being clones have a 4k7 pull down resistors on PGD & PGC lines. PGC is the I2C clock, even if the output pins of the MCU inside the pickit are HiZ/input, that pull down resistor is loading the SCL.
I'd try to remove it or maybe increase to ~47k so it won't mess up the pull-ups on the I2C bus.

Digital Larry

That would explain it!  Interesting, so the output drivers connecting to those lines must have totem pole outputs rather than being open collector.   ???
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

free electron

I2C is bidirectional, so the I/Os usually will be an open collector/drain type.
In your case you have two masters (PicKit, FV-1) and one slave (EEPROM) on the bus. I assume, the pickit, when idle, sets it's IOs as input making them HiZ floating. The 4k7 pull downs inside the pickit are required for the debug operations. Any totem pole output on any of the master devices would block the bus.
I had exactly the same problem few years ago when i built my own pickit2 clone. I ended up using a lower value pull ups in my FV-1 circuit. The FV-1's internal pull ups have much higher value IIRC. Adding external 1k or lower ones in parallel made it work.

Digital Larry

#4
Thanks for your response... that makes sense too.  What doesn't make sense is my (fake?) recollection of having measured 5 volts on the i2c lines from this PICKit.  I guess under the circumstances as long as I just use the PICKit without connecting its voltage source to the FV-1 board then I am in no danger of putting excessive voltage on those lines.  I was so worried about it that I put some 3 volt "voltage regulator" diodes (anode to ground) on SDA and SCL, but these too pulled the voltage low enough (about 2 volts IIRC) to prevent proper loading operation.

I'll test it a little more.  I dug out an old Atom based Windows 7 mini-laptop and put Lubuntu on it and compiled the PK2CMD source I pulled from Git.  It's working fine.  I've spent so much of the past 15 years doing project management that I'm still somewhat startled to remember anything about electronics engineering.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

Digital Larry

Well, I just measured it and when reading the EEPROM, the i2c lines are going over 4.2 volts even though there's no power being supplied to/from the PICKit.  While I haven't blown anything up I am a little concerned about this and whether I should add some series current limiting resistors.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

free electron

Looking at the pickit2 schematic, is seems the Vtarget is fed back to an ADC input and measured.



However, the I/O lines are at 5V, since the main PIC is powered with that voltage. I guess, for the main function of the PicKit, which is programming/debugging PICs, their PGD & PGC lines are 5V tolerant. With the included small series resisors all works fine. It might be risky for the FV-1, especially if you are going to have the programmer plugged all the time while developing.

If this PicKit2 you have will be used as the FV-1 programmer only, i'd just mod it, remove the pull down resistors, add a small adapter board with level shifters (ie. the mosfet based one).
Adding more series resistance could ruin the rise/fall times of the waveform, scoping it while experimenting with the values will show if that's true.
Also, there are a dedicated bidirectional level translator chips, like the TXS0102 or PCA9617A, both have output enable pins, which could be used to isolate the programmer from the targer when not in use (connect only for the programming/verification period).

I tried to simulate a simplest approach which does not require any modification of the PicKit and could be built as an adapter board. The target power should be enabled as the output needs a pull up resistor R2. The results are looking good @ 200kHz:



You'd need two such circuits for both SCL and SDA signals.

I couldn't find the firmware sources for the 18F2550, only a compiled hex. Having the sources one could mod it to add more FV-1 type operations, like triggering a short reset pulse after eeprom write or controlling the OE line of the level shifter to isolate the bus from the target when not in use.

free electron

Here is an idea for an adapter, not verified in hardware, only simulated. Should be easy to test on a breadboard. The transistor type is not critical, 2n7000 will be ok too.



Actually, *bay, ali and others are full of such small smt level translating modules. Just look for "I2C Logic Level Converter Bi-Directional Module 5V to 3.3V" or something like that. They are dirt cheap.

Ice-9

Yes that will work just fine, a level shifter can be used in this situation and the 2n7000 do indeed do the job perfectly.
www.stanleyfx.co.uk

Sanity: doing the same thing over and over again and expecting the same result. Mick Taylor

Please at least have 1 forum post before sending me a PM demanding something.

Digital Larry

Thanks for all the help guys!   :D

Part of what I'm doing here is developing an FV-1 board to allow people to develop their own stuff in SpinCAD and easily upload to the board.  To that end I either make the programming interface compatible and robust with available programmers and/or develop/offer my own programmer which has all these problems inherently solved.  I am in fact working on #2 but since it's really an R&D effort I'm not sure how long it will take.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

Digital Larry

#10
I tried a series 1k resistor in the SDA and SCL lines and it seems to work OK.  The waveforms are a bit wonky (there's some overshoot on the rising edge and of course it doesn't pull down to zero).  I'm going to get another PICKit2 clone from China and double check it.

On the one PICKit clone I already have, I never succeeded in getting it to adjust the output voltage, even setting the output voltage parameter.  But now that I have it set up and it's working, I will try again as my first tests had everything balanced in my lap.  Workbenches rock!

Update - the voltage setting e.g. -A3.3 does work, but it sets the Vdd output and does not affect the levels on the SDA/SCL lines.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

ElectricDruid

If you're designing a new board to let people program the FV-1/EEPROM, is there any way you can make it work with PICKit3 as well as PICKit2?
I understand the problem is that the PICKit3 doesn't program EEPROMs - why not? What did they change? Is there any way around that?

Obviously it's not a massive deal, since the PICKit2 clones are cheap, but they're not as cheap as a tool I already have!

Thanks,
Tom

Digital Larry

Quote from: ElectricDruid on June 06, 2018, 09:36:52 AM
If you're designing a new board to let people program the FV-1/EEPROM, is there any way you can make it work with PICKit3 as well as PICKit2?
I understand the problem is that the PICKit3 doesn't program EEPROMs - why not? What did they change? Is there any way around that?

Obviously it's not a massive deal, since the PICKit2 clones are cheap, but they're not as cheap as a tool I already have!

Thanks,
Tom
Yeah, here's how I make these decisions.... untold hours of effort on my part to save someone else ten or twenty bucks?  Hmmmm.....

You have to know that I certainly did not develop SpinCAD with the intent of getting rich off it, but time is in short supply and I have to select my activities carefully.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

free electron

Quote from: ElectricDruid on June 06, 2018, 09:36:52 AM
If you're designing a new board to let people program the FV-1/EEPROM, is there any way you can make it work with PICKit3 as well as PICKit2?
I understand the problem is that the PICKit3 doesn't program EEPROMs - why not? What did they change? Is there any way around that?

Obviously it's not a massive deal, since the PICKit2 clones are cheap, but they're not as cheap as a tool I already have!

Thanks,
Tom

With the ever-growing family of MCUs and the fact that Pickit is a programmer and a debugger i guess they decided to ditch these extra side features like EEPROM burner, logic analyzer etc.
If there is no eeprom programmer implemented in the Pickit3 firmware i don't think it will be possible. Unless you want to write your own, sources are here.
Can't see anything I2C related in the command list, though.

Digital Larry

TBH I'm steering more towards an Arduino Nano kind of implementation, cheaper if nothing else.  PICKit 2 would be stop gap until I get that running.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

free electron

Out of curiosity i've just tried to run the SpinCAD on a Raspberry Pi Zero W, accessing it via VNC. Laggy as hell, but it works!



RasPi has it's own 3.3V I2C bus, making it program the 24LC32 would be trivial.

After uploading the SpinCAD jar file to the Raspi run:
java -jar filename.jar
replacing the "filename" with the actual SpinCAD file name.

I'll check how fast it runs on a quad core Raspi3, should be much faster.

Then there is this FV-1 compiler written in Python:

https://pypi.org/project/asfv1/

I haven't tested it yet, but if it works, it could be a nice open source alternative to develop the FV-1 patches. With a built in programmer!

Digital Larry

#16
I'm running SpinCAD on my workbench on an old Atom-based notebook.  Wiped Windows 7 in favor of Lubuntu.  What really jumps out at me (and probably on the Pi as well) is the need for a scrollable work area!  I'll have to look into that again.
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

gena_p1

my connection scheme, may be someone need it
pull up resistors not needed, they are build in FV-1


add4

just for the sake of sparing someone else long hours or research, i could get the pickit3 to burn the eeprom for the FV1, but you need to desolder one resistor and one diode, as explained in the readme file attached to the standalone application

> 24LC I2C bus devices:
      Bus Speed-
                400kHz with Tools -> Fast Programming checked
                100kHz with Tools -> Fast Programming unchecked

        NOTE: Bus pullups are required for all
              programming operations.  400kHz requires
              2k Ohm pullups.

      NOTE: The I2C (24LC) Serial EEPROM devices require the following PICkit 3
            hardware changes to work properly:

            Remove TR3 from the PICkit 3.
            Remove R50 from the PICkit 3.

So if you remove those, the pickit 3 will program your eeprom, and i guess those are just for debugging, so i hope my pickit will still be able to program pic uCs in the future ^^

hope that helps someone

Quote from: ElectricDruid on June 06, 2018, 09:36:52 AM
If you're designing a new board to let people program the FV-1/EEPROM, is there any way you can make it work with PICKit3 as well as PICKit2?
I understand the problem is that the PICKit3 doesn't program EEPROMs - why not? What did they change? Is there any way around that?

Obviously it's not a massive deal, since the PICKit2 clones are cheap, but they're not as cheap as a tool I already have!

Thanks,
Tom

add4

Quote from: add4 on April 14, 2019, 03:38:37 PM

So if you remove those, the pickit 3 will program your eeprom, and i guess those are just for debugging, so i hope my pickit will still be able to program pic uCs in the future ^^


So i am now into microcontrollers programming and even with these hardware changes, my pickit3 programs and debugs my pic32mx microcontrollers perfectly. So it seems safe (so far) to do this hardware modification.

Life is beautiful