Hi Vloki,
I tried running the program with the PIC18F4550 and everything compiled wonderfully, no changes were needed, just opened up the project in MPLAB X v3.00, selected the correct configuration, and was good to go.
But how would one go about configuring this project for another microcontroller such as the PIC18F2550?
Thank you!
*****EDIT*****
Holy crap, I can't believe I actually got something to work! (Note: this has only been tested as far as my PC recognizing the device as a COM port and establishing a connection through HyperTerminal; I have yet to test sending and receiving data to and from the PIC)
Here is what I did to configure my PIC18F2550 from your project (hopefully I wasn't wasting my time...please let me know if there was a faster way!)
1) I opened up your project LPC_FSUSB-CDC-X-r2.zip in MPLAB X v3.00
2) I created my own configuration for the microcontroller I am using PIC18F2550 using PICKIT3 and XC8.
3) Under project properties -> my configuration -> XC8 compiler, I copied the "Include Directories" that the other configuration settings had "./" "./plib" and "../mla/v2014_07_22/framework"
4) I also edited the PicKit3 power configuration "Power" to power the target using the PicKit3 (not sure if this was necessary since I swap from the PicKit3 usb cable to an actual usb connected directly to my PIC after programming to talk to the PC)
5) Under my project folder "...\src\BSP-FILES" I created a file for the pic18f2550 (copy and pasted from the 4550 header and source files) and just did a "replace all" from "4550" to "2550".
6) In addition to the step above, I edited every other file that had "4550" in it to include the appropriate text for the "2550" as well. I don't remember what files exactly, for sure the "system.h" and "usb_descriptors.c" files located under "...src\LPC_FSUSB-CDC-X"
7) Then in MPLAB X I built the project and made modifications as needed. These included REMOVING all of the BSP files (both source and header) that I wasn't using, and ADDING the pic18f2550 header and source bsp files.
8) I still had one error in my configuration, where the compiler didn't recognize "ICSP" or something of the sort for the in-circuit serial debugger or w/e, I simply changed this to "DEBUG" and everything compiled just file!
9) Then I programmed my device, disconnected my pickit, connected a regular usb cable to my circuit, manually loaded the driver (didnt let windows vista look for it) by locating the directory that contained "mchpcdc.inf".
...Again if there was an easier way, please let me know! But hopefully this can help someone in the future. (hopefully this actually works..again I haven't done anything besides get a "device is working properly" "COM4 detected" in my device manager.
Best.
*****EDIT 2*****
Finally got around to testing. Yeup, all works fine and dandy. Just threw this code up above main
- Code: Select all
BYTE buffer[64];
BYTE numBytes;
and threw this code at the bottom of the while loop (After declaring TRISA = 0; and PORTA = 0;):
- Code: Select all
numBytes = getsUSBUSART(buffer,sizeof(buffer)); //until the buffer is free.
if(numBytes > 0) {
if(buffer[0] == 'a') {
LATAbits.LATA1 = 1;
}
//we received numBytes bytes of data and they are copied into
// the "buffer" variable. We can do something with the data here.
}