I made some
steps forward..
I edited the mla example code for my clock settings, they're using an external 20MHz crystal, i'm using using an 8MHz one.
Changed clock settings to give same 48MHz clock speed needed for usb.
#pragma config PLLDIV = 4
#pragma config CPUDIV = OSC1_PLL2
#pragma config USBDIV = 2
#pragma config FOSC = HSPLL_HS
and Changed all the pins used for buttons and leds to match my settings
compiled using XC8, but when I tried to program the chip, I stayed in a kind of a waiting/verifying mode, it was weird, because while i'm flashing the chip, the pickit2 red led is on. So I took the .hex file and flashed it myself
Nothing more reliable than good ol' shell
pk2cmd -M -PPIC18f2550 -Y -Fpicdem_fs_usb.x.production.hex
for the host part, I want it to be as simple and reliable as it can be, So I used node-hid, which is an npm package.
All the code does is keep checking all usb devices.
var HID = require('node-hid');
var i = 1; // set your counter to 1
function myLoop () { // create a loop function
setTimeout(function () { // call a 3s setTimeout when the loop is called
console.log(HID.devices());
if(i++ < 100) { // if the counter < 100, call the loop function
myLoop(); // .. again which will trigger another
} // .. setTimeout()
}, 1000)
}
myLoop(); // start the loop
This is the output, I don't think it contains my chip, because I unplugged and plugged, and got same result.
Btw, how to set my usb like productId and path, so to identify my usb in the future ?
[ { vendorId: 1240,
productId: 51,
path: '0007:0010:00',
serialNumber: 'OlHoss',
manufacturer: 'Microchip Technology Inc.',
product: 'PICkit 2 Microcontroller Programmer',
release: 2,
interface: 0 },
{ vendorId: 1241,
productId: 5635,
path: '0006:0031:00',
release: 784,
interface: 0 },
{ vendorId: 1241,
productId: 5635,
path: '0006:0031:01',
release: 784,
interface: 1 },
{ vendorId: 10093,
productId: 4448,
path: '0003:001d:00',
release: 1,
interface: 0 } ]
Not that it's going to be very helpful,but I like to give a an overall view
https://imgur.com/a/nKDUyI double checked the wiring for the USB, it's solid, It also gives me the needed 5V power needed to power the chip.
I don't understand what I did wrong, but i'll try again, but this time, i'll change the whole project to use it without the IDE and use my LCD to output whatever is going on.
![Broken! :-BROKE](https://www.eevblog.com/forum/Smileys/default/smiliey_scope_broke.gif)
A bit unrelated to this, but I went again to check this
example, and now I remember why I didn't use it, he's using C18 compiler, a completely different world, tried to compile his code using netbeans IDE(cuz i know nothing about C18).
Problem is that I couldn't find the usb header files he used, and VC++ host code he has is useless, cuz i already have the node-hid working fine. So, dropped his example all together.
![Flogging A Dead Horse :horse:](https://www.eevblog.com/forum/Smileys/default/DeadHorse.gif)