# pic24fj64gb002 (USB Host)

{% hint style="info" %}
Programming this chip is optional. This chip doesn't talk to the host of the computer it's nothing more than a slave. The ATMEGA has full control of the data so there is very little to no risk.
{% endhint %}

If you do want to reprogram keep in mind this is a lengthy process all of these steps have already been done on your device.

## Programming Bootloader

We will start of by installing the following programs:

| Program     | Link                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ds30 loader | <p>Project File: "Crypsis\Crypsis Hardware\Baseboard\PIC24(USBHOST)\DEPENDENCIES\ds30LoaderGUI.exe"</p><p></p><p>or</p><p>  <a href="https://www.hobbytronics.co.uk/download/ds30%20Loader.zip"><https://www.hobbytronics.co.uk/download/ds30%20Loader.zip></a></p>                                                                                                                                                           |
| MPLAB IPE   | <p>Project File: "Crypsis\Crypsis Hardware\Baseboard\PIC24(USBHOST)\DEPENDENCIES\MPLABX-v5.30-windows-installer.exe"</p><p></p><p>or</p><p><a href="https://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v5.30-windows-installer.exe"><https://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v5.30-windows-installer.exe></a> </p><p></p><p><strong>You only have to install the IPE, IDE is not required.</strong> </p> |

1. Connect the EdgeConnect In the following manner to the breakout board and Crypsis **make sure it's connected to the bottom board with the arrow pointing to the USB MALE**<br>

![Wire the ](https://1957962940-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWEjxvYparZinAu2pan%2Fuploads%2FJepucJktAfVZdDIPIdAt%2Feb82d87cb33e2605c82ae54e284aa425.jpg?alt=media\&token=a7dd906d-f2fc-44f6-b9da-7939e888d11f)

2\. Connect the Pickit4 to the breakout board in the following manner. This should not be required since all cables are pre-installed make sure they match the above and below picture.

| BASEBOARD | PICKIT4 |
| --------- | ------- |
| MCLR      | MCLR    |
| GND       | GND     |
| 3v3       | VDD     |
| PGRD      | PGD     |
| PGRC      | PGC     |

![Pickit 4 Wires.](https://1957962940-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWEjxvYparZinAu2pan%2Fuploads%2FaAezf65u0mBBPzRpfQD7%2F0dc0f9e03c8ef085643b3007d1cff02f.png?alt=media\&token=a8ce89cb-25bd-4bf3-8a97-4fb7027c2fe7)

3\. Plug the Pickit 4 programmer into the computer.

4\. Open MPLAB IPE and select the relevant programmer and destination chip. Select the PIC24FJ64GB002 and press connect, it will fail. Then go to settings press advanced mode and type microchip is as password. Then go to power check the box and select 3.375 volts.&#x20;

{% file src="<https://1957962940-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWEjxvYparZinAu2pan%2F-MXN8I3_AAk9Yomzx4WY%2F-MXN8saF8Ae8BrcfQIlv%2FSteps_for_enabling_power.mp4?alt=media&token=a3624024-a5c7-483b-91a2-61bf9cea6d3d>" %}
Video Containing Steps
{% endfile %}

5\. Go back to Operate and click connect. If an error appears re-check wiring.

![](https://1957962940-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWEjxvYparZinAu2pan%2F-MXMXYf3uimxUMK-gn66%2F-MXN7kGuj8F9j8K9BrIt%2Fimage.png?alt=media\&token=a6d89b2e-df33-4275-9f94-0c6eba5594cf)

6\. Browse to the hex file Location should be: Crypsis\Crypsis Hardware\Baseboard\PIC24(USBHOST)\bootloader\_24FJ64GB002.hex . Then click Program.

![](https://1957962940-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWEjxvYparZinAu2pan%2F-MXN8I3_AAk9Yomzx4WY%2F-MXN8J7nOJL1th6ah8ZD%2Fimage.png?alt=media\&token=f7216053-939d-4a89-b6b4-04fefecfa5a1)

Bootloading is now successful. Keep the EdgeConnector connected to the&#x20;

## Programming pic24fj64gb002

Follow the steps

1.Keep the Crypsis connected to the breakout board like above. Connect the breakout board to the USB-TTL converter

3.3v -> VCC\
PGRD -> TX\
PGRC -> RX\
GND -> GND

![](https://1957962940-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWEjxvYparZinAu2pan%2F-MXNHIT0viCdpOwMZk_W%2F-MXNOIgAFLCJhZy6Nei7%2Fimage.png?alt=media\&token=1e647eab-c071-453c-8417-48795fa8bf0c)

2\. Make sure the jumper is in the 3v3 position and connect the USB-TTL to the computer.

![](https://1957962940-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWEjxvYparZinAu2pan%2F-MXNHIT0viCdpOwMZk_W%2F-MXNN4yFL-EEKcU8o7tB%2Fimage.png?alt=media\&token=dbe66fec-cb16-40b9-87cf-0ecc5064891f)

3\. Open DS30 loader "ds30 Loader\ds30 Loader\bin\ds30LoaderGUI.exe"

4\. Select the following hex file "Crypsis\Crypsis Hardware\Baseboard\PIC24(USBHOST)\keyboard.hex" Select the correct COM port for the USB TTL and the correct chip. Also change BAUD rate to 115200. Click on view select advanced mode and go to the reset tab change it to DTR. Now press write and you are done.

![](https://1957962940-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWEjxvYparZinAu2pan%2F-MXNHIT0viCdpOwMZk_W%2F-MXNPIN-t4Y4FjNhy0r8%2Fimage.png?alt=media\&token=facaf402-f335-402d-bcee-1e8285151552)

You are finished programming now you need to put the settings.

## Configuring settings

For this step make sure the ATMEGA is bootloaded with the Arduino Leonardo bootloader. This has always been done by us so if you didn't remove it this won't be an issue. If you did follow the steps for ATMEGA32U4 Programming and then come back to this. Also, make sure you have installed Arduino. This can be found in the following folder: Crypsis\Crypsis Hardware\Baseboard\ATMEGA\DEPENDENCIES\arduino-1.8.12-windows.exe

1. Make sure Crypsis is not connected to the Edge Connect. Then connect the Crypsis to your PC.

2\. Open the following code with Arduino "Crypsis\Crypsis Hardware\Baseboard\PIC24(USBHOST)\Setup.ino"

3\. Select the correct COM-port for the Crypsis and program by clicking on the arrow in the top left.

![Make sure SMSSERIAL.begin() contains 9600 afther bootloading](https://1957962940-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWEjxvYparZinAu2pan%2F-MXNRjZCCLerYkSl2Vy1%2F-MXNW2hGdPMt9mnJ9iC9%2Fimage.png?alt=media\&token=6188a7c6-47a7-4799-82c6-79ed7408bb77)

4\. Open the serial terminal by clicking on the top-right magnifying glass. When opened make sure the settings are the same as the picture below. Then enter the following commands by entering in the text field and pressing send:\
\-  "MODE 6"\
\-  "KEYBOARD 0"\
\-  "BAUD 38400"

![](https://1957962940-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWEjxvYparZinAu2pan%2F-MXNWJ3Fk4dwWBp6FQWI%2F-MXNXfV5yHGZ3unAXsgD%2Fimage.png?alt=media\&token=ca0b45f4-5de1-4ebd-b195-149275dffdf0)

You are now done with the USBHOST follow the steps of the ATMEGA32U4 and NRF to fully finish programming your Crypsis.
