UBW no longer working after programming device incorrectly

USB PICs and the UBW

Moderator: phalanx

Post Reply
Ultima
Posts: 12
Joined: Wed Dec 26, 2012 4:39 am

UBW no longer working after programming device incorrectly

Post by Ultima » Wed Dec 26, 2012 5:12 am

Hi,

I followed a tutorial to help guide me through the process to establish an interface between my PC and UBW. The tutorial shows how to change the USB CDC basic device demo from p18f4550 to p18f4553. (I substituted in p18F2553 and had to comment out the section in main.c starting if(USBSuspendControl == 1) because the project would not build otherwise). When I selected "program device", I choose "No" in order to use the board’s default configuration settings.The tutorial is at:
http://www.eee.metu.edu.tr/~design/lib/ ... cation.pdf

However, after my attempt to program a new hex file onto the UBW failed, the UBW is no longer recognised by the PC and does not accept either driver. The behaviour of the UBW has also changed, no flashing orange LED when I plug in the UBW and in programming mode the red LED no longer flashes (steady red light, no orange light)-probably due to the change I made to the code earlier.

Is there anyway to fix this, or do I need to get a new UBW?

Ultima

P.S. I did have some initial difficulties with starting programming mode (I searched for mchpusb.inf). The first few times I tried this with out success. However, on one occasion I did exactly the same thing, getting to the point where a window appeared asking for the driver (I selected choose driver from disk), but an additional step appeared asking me to select the type of device (I choose com port) and that time the process worked. It seemed most random.

User avatar
EmbeddedMan
Support Volunteer
Posts: 1362
Joined: Sun Mar 05, 2006 9:23 pm

Re: UBW no longer working after programming device incorrect

Post by EmbeddedMan » Wed Dec 26, 2012 4:18 pm

Unfortunately, while the advice given in that tutorial is correct for the setup they use, it is not correct for the UBW.

The PICDEMFSUSB tool 'knows' what config bits need to be programmed for each 'known' development board in order for them to work properly. So if you try to send a HEX file down using that tool, and it detects that you have any config bits in your HEX file, it will check them with what it thinks are the correct config bits for your board. If they do not match, then it will issue the warning that you got. If you do what the tutorial says and use the default config bits for the board, it will replace the config bits in your HEX file with what it thinks should be the config bits, and then program the board.

But that tool does not know about UBW, and UBW uses slightly different config bits than the 'default' that the tool knows about. So it added config bits to your HEX file and then programmed your UBW, and now your UBW will not run because the oscillator config bits are not what they need to be.

Whenever you generate a HEX file for UBW, you must make sure that it does not contain any config bits. If you get that warning from the PICDEM tool, then you should immediately cancel out of the programming operation, and re-build your HEX file without config bits. If your HEX file does not contain any config bits, then the warning won't come up, and your UBW can always be placed into programming (bootload) mode if anything goes wrong.

All of the examples that I have on the UBW website do not contain config bits (if they are there, they are commented out) to prevent this type of problem.

Now, if you really know what you are doing (and that's not very hard to do actually) you CAN put config bits in your HEX file, as long as they match the ones already in the UBW (see the bootloader project for the correct config bits) in the ways that matter. For example, you can change some of the config bits (like WDT (watchdog timer) or CCP2MX, etc. but NOT the ones that you need to run like PLLDIV or CPUDIV or USBDIV or FOSC).

Now, your UBW is not going to work again until you re-program it with a hardware programmer. One that will work quite well for you is the PICKit3. SparkFun even sells it : https://www.sparkfun.com/products/9973 You can load up the bootloader HEX file (http://www.schmalzhaus.com/UBW/FW/B/out ... _24MHz.hex) and use the PICKit3 to program that into your UBW. It will then be able to be bootloaded over USB.

Sorry about this confusion - the whole subject of bootloading is complicated, and you have to understand a bunch of different pieces to know what's safe to do and what's not. The PICKit3 will ALWAYS be able to get you out of trouble - it can program any completely borked PIC. (it can also do debugging, which is really nice.)

You may ask why I didn't code-protect the config bits on the UBW. The reason is that some users of the board need to be able to change those bits in order to do what they need to do, and they don't want to have to buy hardware programmers. So I left them open to try and make the system as generic as possible.

*Brian

Ultima
Posts: 12
Joined: Wed Dec 26, 2012 4:39 am

Re: UBW no longer working after programming device incorrect

Post by Ultima » Wed Dec 26, 2012 4:48 pm

Hi, I appreciate the detailed response. I neglected to say I am using the development board version, i.e.: https://www.sparkfun.com/products/762

Will the PICKit3 be able to manage this, where the PIC is integrated? Maybe I need an additional cable to connect the pins?

Ultima

User avatar
EmbeddedMan
Support Volunteer
Posts: 1362
Joined: Sun Mar 05, 2006 9:23 pm

Re: UBW no longer working after programming device incorrect

Post by EmbeddedMan » Mon Jan 07, 2013 7:24 am

Yup, the PICKit3 will program it just fine. You can get yourself out of any trouble with the PICKit3. :-)

You can either purchase the little adapter https://www.sparkfun.com/products/194 or you can just run wires from the necessary pins (VCC, GND, Reset/MCLR, RB6, RB7) to the PICKit3 from the headers on the UBW. Either will work.

*Brian

Ultima
Posts: 12
Joined: Wed Dec 26, 2012 4:39 am

Re: UBW no longer working after programming device incorrect

Post by Ultima » Fri Apr 05, 2013 4:09 am

Finally have a chance to get back to working with the ubw. I've read through the pickit documentation and the ubw documentation, but can't figure out where the connections go between the two (in order to reprogram the ubw with the suggested hex file above).

For the pickit we have:
1 = VPP/MCLR
2 = VDD Target
3 = VSS (ground)
4 = ICSPDAT/PGD
5 = ICSPCLK/PGC
6 = LVP

And for the ubw:


1 = TX / RC6/CK
2= RX / RC7/DT/SDO
3= GND
4= VCC
5= 0 / AN12/INT0/FLT0/SDI/SDA
6= 1 / AN10/INT1/SCK/SCL
7= 2 / AN8/INT2/VMO
8= 3 / AN9/CCP2/VPO
9= 4 / AN11/KBI0
10= 5 / KBI1/PGM
11= 6 / KBI2/PGC
12= 7 / KBI3/PGD

Otherside
12= GND
13= VCC
14= 5 /AN4//HLVDIN/C2OUT
15 = 4 / T0CKI/C1OUT/RCV
16= 3 / AN3/VREF+
17= 2 / AN2/VREF-/CVREF
18= 1 /AN1
19= 0 / AN0
20= VPP /RE3

So my take would be:
Pickit pins -> ubw pins
1 -> 20
2 -> ? (maybe 4 if VDD = VCC?)
3 -> 3
4 -> 12
5 -> 11
6 -> ? (What is LVP?)


Ultima

Edit: I'm going to assume 2 -> 4 and 6 does not need to be connected based on what I've read elsewhere. Here's hoping I don't mess up the pickit.

User avatar
EmbeddedMan
Support Volunteer
Posts: 1362
Joined: Sun Mar 05, 2006 9:23 pm

Re: UBW no longer working after programming device incorrect

Post by EmbeddedMan » Fri Apr 05, 2013 6:32 am

So the good news is that it's _really_ hard to damage the PICKit. Microchip designed it pretty well.

As far as UBW connections - the trick is that you need the following 5 lines: (in order, starting from pin 1 of the PICKit connector) MCLR, Vcc, GND, RB7 (PGD), RB6 (PGC) (note that you do NOT need to connect pin 6 - LVP - of the PICKit)

So you can use the pins that are exposed on the edges of the UBW. You have your list correct for PIKit to UBW:
1 -> 20 (VPP/RE3)
2 -> 4
3 -> 3
4 -> 12 (KBI3/RB7/PGD)
5 -> 11 (PBI2/RB6/PGC)

*Brian

Ultima
Posts: 12
Joined: Wed Dec 26, 2012 4:39 am

Re: UBW no longer working after programming device incorrect

Post by Ultima » Fri Apr 05, 2013 9:02 am

Thanks for the confirmation.

After connecting the PICKit 3 and UBW in this configuration with both of them connected via usb to the PC I then went to MPLAB and imported the suggested hex file. I selected PICKit 3 as the programmer with PIC18F2553. There were some complaints about the destination device perhaps being incorrect, but I ignored this and selected the option 'Program'.
Windows now detects and installs the the ubw as a usb device.

However, my next quest seems to discover why pdfsusb does not detect it (unless I missed a step somewhere).

Ultima
Posts: 12
Joined: Wed Dec 26, 2012 4:39 am

Re: UBW no longer working after programming device incorrect

Post by Ultima » Sat Apr 06, 2013 8:49 am

I'm not getting the standard behaviour from the ubw after programming it with the pickit. In MPLAB when I do reprogram it I get the following:

PICkit 3 detected
Connecting to PICkit 3...
Running self test...
Self test completed
Firmware Suite Version...... 01.28.56
Firmware type......................PIC18F
PICkit 3 Connected.
PK3Err0045: You must connect to a target device to use PICkit 3.

Target Detected
Device ID Revision = 00000007

Programming...
Programming/Verify complete

Verifying...
Verify complete

The ID revision remains the same afterwards:
Target Removed

Target Detected
Device ID Revision = 00000007

No detection by windows when I plug in the ubw, only green power light appears on ubw.

When entering programming mode (does this need to be done also when using the pickit?) I get an alternating red/orange light. Still no recognition from windows, but pdfsusb sees it [PICDEM FS USB 0 (Boot)]

User avatar
EmbeddedMan
Support Volunteer
Posts: 1362
Joined: Sun Mar 05, 2006 9:23 pm

Re: UBW no longer working after programming device incorrect

Post by EmbeddedMan » Mon Apr 08, 2013 11:40 am

Since you are programming only the bootloader HEX file with the PK3, after you get that step done you will need to program the UBW with the firmware version that you wish to use. It appears that PDFSUSB.exe is able to see your board in bootloader mode, correct? So just download the HEX file for the firmware, and you should be back to factory condition.

*Brian

Ultima
Posts: 12
Joined: Wed Dec 26, 2012 4:39 am

Re: UBW no longer working after programming device incorrect

Post by Ultima » Sun Apr 14, 2013 11:26 am

I wasn't sure which hex file was the factory default so I decided to directly try the helloworld hex file. It seems to work as the orange and red lights are currently flashing simultaneously, although pdfsusb provides a warning that it failed to reset board when I clicked the execute button.

What I'm aiming to achieve is to have some leds connected to the ubw, which flash at frequencies I can specify from my computer - so I figured I might need the hellousbworld hex file as an example. However, when I try loading it with pdfsusb, I get the following windows warning:

Access violation at address 0040507A in module 'PDFSUSB.exe'. Read of address 00000000

Any suggestions?

Ultima

P.S. Both build successfully with MPLab, but there is a warning with helloworld:
WARNING: This version of MPLAB C18 does not support procedural abstraction. Procedural abstraction will not be run.

User avatar
EmbeddedMan
Support Volunteer
Posts: 1362
Joined: Sun Mar 05, 2006 9:23 pm

Re: UBW no longer working after programming device incorrect

Post by EmbeddedMan » Tue Apr 23, 2013 12:09 pm

Ahh, yes. I believe that error (in the PDFSUSB.exe app) may have to do with an older version of .NET on your machine. Can you try downloading and running the .Net v3.5SP1 installer (http://www.microsoft.com/en-us/download ... aspx?id=22) and see if it fixes the problem for you? Let me know either way-

*Brian

Ultima
Posts: 12
Joined: Wed Dec 26, 2012 4:39 am

Re: UBW no longer working after programming device incorrect

Post by Ultima » Thu May 09, 2013 5:23 am

On checking add/remove programs I have .NET v1.0.3705 and .NET 1.0 Hotfix and .NET 1.1 and .NET 2.0 SP2 and .NET 3.0 SP1 and .NET 3.5 SP1 and .NET 4 Client Profile.

I downloaded the installer in any case and selected repair. However, alas, after completion pdfsusb still reports the access violation...

I also checked that all critical windows updates were installed (they were).

Ultima
Posts: 12
Joined: Wed Dec 26, 2012 4:39 am

Re: UBW no longer working after programming device incorrect

Post by Ultima » Thu May 09, 2013 7:23 am

How odd. I decided to re-download helloUSBWorld and I got a zip file with different contents. I've been able to load this one without a problem. The previous version I was trying to use was called helloUSBWorld.X and the current one does not have the".X" - not sure how I managed to get the wrong one!

Post Reply