TOP Contributors

  1. MIKROE (2779 codes)
  2. Alcides Ramos (376 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139560 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57254 times)
  4. USB Device Library (47607 times)
  5. Network WiFi Library (43219 times)
  6. FT800 Library (42551 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26930 times)
  10. microSD click (26309 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
Project

Microchip HID Bootloader Template and ADC Over USB for PIC18F and PIC24F (PIC18F14K50, PIC18F27J53, PIC18F2553, PIC18F4553, PIC24FJ64GB002 Tested)

Rating:

15

Author: Ghanshyam Patel

Last Updated: 2016-02-17

Package Version: 1.2.0.0

Category: Bootloaders

Downloaded: 8401 times

Followed by: 10 users

License: MIT license  

A template for mikroBasic, mikroC and MPLAB C18/C30 that is compatible with Microchip's HID Bootloader for PIC18F and PIC24F microcontrollers and PIC18F14K50, PIC18F27J53, PIC18F2553, PIC18F4553 and PIC24FJ64GB002 have been tested. ADC Over USB Example (firmware and Visual Basic 2010 project) and a custom HID bootloader project are also included.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Microchip HID Bootloader Template and ADC Over USB for PIC18F and PIC24F (PIC18F14K50, PIC18F27J53, PIC18F2553, PIC18F4553, PIC24FJ64GB002 Tested)" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Microchip HID Bootloader Template and ADC Over USB for PIC18F and PIC24F (PIC18F14K50, PIC18F27J53, PIC18F2553, PIC18F4553, PIC24FJ64GB002 Tested)" changes.

Do you want to report abuse regarding "Microchip HID Bootloader Template and ADC Over USB for PIC18F and PIC24F (PIC18F14K50, PIC18F27J53, PIC18F2553, PIC18F4553, PIC24FJ64GB002 Tested)".

  • Information
  • Comments (5)

Project Blog

This is a template for mikroBasic and mikroC that is compatible with Microchip's HID Bootloader for PIC18F and PIC24F microcontrollers PIC18F14K50, PIC18F27J53, PIC18F2553, PIC18F4553 and PIC24FJ64GB002 have been fully tested but other PIC18F and PIC24F MCUs should work without major changes. The bootloader occupies space until 0x1000 for PIC18F MCUs and 0x1400 for all PIC24F MCUs. A working example is also included that displays ADC voltage in a Windows program. The mikroBasic and mikroC code to remap interrupts and reset are based on mikroPascal code provided by “icserny” here:

http://www.microchip.com/forums/tm.aspx?high=&m=516499&mpage=1#516944


PIC18F14K50 Development Hardware:

http://www.libstock.com/projects/view/320/usb-logic-tool-pic18f14k50-in-mikrobasic-mikroc-mplab-c18

http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en536385


PIC18F27J53 Development Hardware:

Schematic, PCB Layout and Bill Of Materials attached (in the blog not the project download) - all parts are meant to be generic but specific part numbers are given to save time searching for one.

Use the schematic to build it yourself (breadboard or protoboard) or buy the PCB from BatchPCB (see bottom of blog):

http://batchpcb.com/index.php/Products/82504


PIC24F64GB002 Development Hardware:

The schematic is attached for building on breadboards and protoboard but no PCB has been designed yet.


mikroBasic and mikroC compilation:

If Microchip’s HID Bootloader being used is less than version v2.90 the hex file that is generated by the compiler cannot directly be used. ":020000040000FA" must be added to the top of the hex file - you can use notepad to do it or just run my VBScript which adds it for you and creates a second hex file in the parent folder.

 

Bootloader Hardware Entry (Original & Custom):

 The template uses the reset button for PIC18F14K50 to go into boot loader mode from user code. It can be changed to simulate a reset by adding a loop that waits for the button to be release just before resetting the microcontroller (to make sure it is not pressed at startup). PIC18F47J53 family uses RB2 as the bootloader switch. All other PIC18Fs use RB4 as the bootloader switch. PIC24FJXXGB002 uses RA4 as the bootloader switch and PIC24FJXXGB004 uses RA10 as the bootloader switch. The custom bootloader for all MCUs will enable internal pull-up before checking the port pin.

 

Bootloader Software Entry (Custom Only):

A modified HID Bootloader (PIC18F2450 and PIC18F4450 not supported) is also included that makes use of EEPROM(255) to boot either enter bootloader mode or the actual program. The bootloader will only go to the users program if EEPROM(255) is 170. If it 85 then it will still go into bootloader mode but writes 170 so it will not go back - write 85 in you program then reset to enter bootloader mode once. My template will work with Microchip's original bootloader or my custom bootloader. The template has a "ihex" EEPROM file inlcuded to write 170=0xFF to EEPROM(255) when programming the microcontroller.

 

PIC18F47J53 family does not have an internal EEPROM so it makes use of flash memory 0xFBFF but 0xF800 to 0xFBFF are used since the minimum erase size is 1 page = 0x400 instructions = 1024 bytes.

 

PIC24F64GB004 family does not have an internal EEPROM so it makes use of flash memory 0x83FE but 0x8000 to 0x83FF are used since the minimum erase size is 1 page = 0x400 instructions = 1536 bytes. mikroBasic and mikroC run into Address Error traps when declaring initial flash data not starting at 0x8000 and enabling HID so software entry is not implemented in those compilers. 0x8000 is where the program visibility space starts.

 

ADC over USB Example:

The ADC over USB project will not work with other microcontrollers unless the USB RAM start address is changed. For PIC18F13K50 & PIC18F14K50 it is 0x280 and for PIC18F2553 & PIC18F4553 it is 0x500 – search for USB RAM in the data sheet. PIC18F47J53 family and PIC24F64GB004 family do not need to specify it because all RAM can be used as USB RAM.

 

HID PC Source Code:

A Visual Basic 2010 project is included so the PIC communicates using the HID template code to display ADC value in Windows. A blank template and a working ADC over USB example are included.

 


 

Some additional information for setting up Windows software:

mikroBasic and mikroC do not rely on external files so they will work as is. For each project MPLAB needs the correct path to MPLAB C18 libraries and includes; for my project MPLAB C18 is located: “C:\Program Files (x86)\Microchip\MPLABC18”. If yours is not installed there then change the location from IDE menu “Project->Build Options->Project” then select the “Directories” tab. Then select “Include Search Path”, “Library Search Path” and “Linker-Script Search Path” under “Show directories for:” and for each change the location to your install directory. If you are using the lite version and need to disable optimizations, in the build options select “MPLAB C18” or “MPLAB C30” tab and select “Optimization” in “Categories:”. For MPLAB C18 select “Disable” and for MPLAB C30 click “0” in “Optimization Level” image. To get started with Microchip Application Libraries (my source) download Microchip's latest Application Libraries from:
http://www.microchip.com/stellent/idcpl ... e=en547784

After it is installed you will find the HID bootloader here:
...\Microchip Solutions v2011-07-14\USB\Device - Bootloaders\HID

And a POT demo:

…\Microchip Solutions v2011-07-14\USB\Device - HID - Custom Demos

 

Edit: Version 1.1.0.0

·         The addition of ":020000040000FA" to the top of the hex file is no longer necessary when using HID Bootloader v2.90. "[Create Bootloader Hexfile].vbs" performs that function. When using HID Bootloader v2.90 remember to select "EEPROM" in Write Options under Program->Settings - only needed if using the custom bootloader.

·         PIC18F2553 & PIC18F4553 uses RB4 (internal pull-up enabled) to enter into bootloader mode. PIC18F27J53 uses RB2 (internal pull-up enabled) to enter into bootloader mode.

 

Edit: Version 1.2.0.0

·         Added information on using MPLAB IDE for beginners.

·         Added blank templates because USB over ADC example is getting too big with all the extra useful functions left in there.

·         Added schematics for PIC18F14K50, PIC18F27J53, PIC18F2553, PIC18F4553 and PIC24FJ64GB002.

·         Updated MPLAB C18 code to make look cleaner and fewer lines. Also changed the code to wake PC up if it is sleeping. Created a part to process instructions if USB is not connected or if the host is sleeping.

·         Changed ADC acquisition time from 20us to 7.45us for PIC18F14K50 and 2.45us for PIC18F27J53, PIC18F2553 & PIC18F4553. For PIC18F27J53, PIC18F2553 & PIC18F4553 use 12-bit ADC values and modify the PC program to handle 10-bit and 12-bit values. The values changed to are considered a general purpose timings used in most cases by the datasheet.

·         Added PIC24FJ64GB004 family (specifically PIC24FJ64GB002). Uses RA4 (internal pull-up enabled) to enter bootloader.



ALSO FROM THIS AUTHOR

USB Logic Tool - PIC18F14K50 in mikroBasic, mikroC, MPLAB C18

5

The device is meant to be a prototyping aid and designed to work well by minimizing breadboard space used, interaction through a visual interface, easy setup and low cost. The low cost allows it to be built at home or a PCB can be purchased for a low price.

[Learn More]

Wireless Light Status Indicator Using Low Cost RF Module

5

The project transmits an encoded sensor reading wireless using the UART module. The data sent can be unencrypted for a higher chance of the data being accepted or it can be XTEA encrypted. The project uses PIC12F1822 and PIC12F1840 (code can be used interchangeably for both) for testing but the examples are only for PIC12F1840.

[Learn More]

NEC IR Protocol Encoder/Decoder with PIC16F150X Timer1 Gate signal capture (MPLAB XC8, mikroC, mikroBasic)

0

A project to encode (remote) and decode (receiver) InfraRed signals using the NEC protocol. It uses the Timer1 Gate function to continually capture the signal to reduce software load and gives it a fast response. The idea is to reverse polarity on the Timer1 Gate capture as soon as it interrupts so it can capture both the high & low signals.

[Learn More]