Sunday, December 11, 2016

USB HID Host PICkit Bridge - PIC32MX

1(OK). Check Configuration Words for CPU/Peripheral System Frequency 48MHz in HardwareProfile.h
     Osc: 20 MHz
     try 48MHz first, if not stable, try 40MHz...(TCHIP-USB-MX250F128B is 40MHz)

2(OK). Check Baud Rate: 38400 first, then 921600. in HardwareProfile.h
    #define BAUDRATE2       38400UL //57600UL
    #define BRG_DIV2        4
    #define BRGH2           1

3(OK). Modify usbTPL[] in usb_config.c,  in usb_config.h
   #define NUM_TPL_ENTRIES 1

4(OK). usb_host_local.h
#define USB_SOF_THRESHOLD_64                0x5A    //0x4A will cause frame error

5. change io_mapping
    in HardwareProfile.h
    

6(OK). modify timer in InitializeTimer()

7. Test Timer/SYSCLK setup  Blink LED

8. ERRATA Don't turn cache and ... on due to Double Write on Peripheral
    Implement DMA (done)

9. Latency of the HC-06 bluetooth module is about 40ms.  The latency of a regulator PIC18F2550 USB Serial COM Port is about 1.4ms.

10. Implement Circular Buffer (Queue) for Commands.  It can only improve the regular write command, but not read command due to the latency of the bluetooth module.

================
modify usb_config.h usb_config.c
modify usb_host_local.h

add PIC32MX270F256B support

1. Update PK2DeviceFile.xml

2. add and set breakpoint in searchDevice() in PICkitFunctions.cs
    if (familyIndex != 0x10) return false; 

3. set breakpoint in DetectDevice() in PICkitFunctions.cs


USB JTAG PIC16F1459

I have been trying to make a USB Blaster Clone to program the Altera MAX 10.  I found a Japanese website, USB-Blasterもどきの製作, showing how to do it with PIC18F14k50. Unfortunately I don't have it with me, but I have PIC16F1459 and it seems it's a good candidate for the replacement.  PIC16F1459 has an internal 48MHz(3x PLL) clock which can sync with USB Host's frame signal to provide the required USB clock(± 0.20% accuracy) without an external oscillator.

After I started the conversion, I found out the original code is written with the old Microchip USB stack, so I also have to figure out how to use the newer USB stack to do it, actually it took more time to know how the old USB stack works.  After a couple of weeks, I stopped working on it and went for some other errands.

A couple of days ago, I found there is a new dev kit for MAX 10 issued by CQ Publisher.  The author put the code on the web.  Although it only supports JTAG programming mode, it's good enough to MAX 10.  It really helped me out, because it's developed with a newer USB Stack.

Originally I was thinking maybe I can run PIC16F1459 with the 3.3V source on the MAX 10 dev board, although the datasheet says the minimum is 3.6V.  I did get the USB to work, but the IO signal is unstable.  I thought that might be caused by the breadboard design, after spent another day, I gave up with the 3.6V idea, so I just used the 5V source and used 560ohm/560ohm as the level shifter.  According to the MAX 10 document, it's better to use a lower voltage at about 2.5V for the JTAG I/O, because there is no clamping diode for overshoot protection on those pins.

After a couple of tries... I finally got it done!

People who are interested with this topic can also take at a look at the following links:

USB JTAG Adaptor
OpenOCD usb_blaster.c

I am thinking PSoC 5LP is another good candidate for doing this job, because it has several special IO(SIO) pins which can use the internal D/A converter as the Vref for a more flexible IO voltage.  Cypress provides a very affordable dev kit CY8CKIT-059 PSoC® 5LP Prototyping Kit for developers.  I will give it a try in the following weeks.