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]
Rating:
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.
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)".
DOWNLOAD LINK | RELATED COMPILER | CONTAINS |
---|---|---|
1316923507_microchip_hid_bo_mikrobasic_pic.rar [1.79MB] | mikroBasic PRO for PIC |
|
1316923512_microchip_hid_bo_mikroc_dspic.rar [1.79MB] | mikroC PRO for dsPIC30/33 & PIC24 |
|
1316923191_microchip_hid_bo_other_other.rar [4.21MB] | Other Compiler |
|
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.