HerrCat
Newbie level 3
- Joined
- Sep 27, 2014
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 48
Hello everybody!
In these days I am working on my project - controlling LEDs using CDC Basic demo firmware and C# application all from Microchip Solutions v2011-07-14 libraries.
I use rm18f4550 - MCHPUSB Bootload
I connected my device to USB port, pressed "Reset" button, then "Bootloader" button once. After that my computer recognized the device and asked for drivers - I installed drivers \Device - CDC - Basic Demo\inf. (I my PC it is shown as COM3 port). Everything worked.
Then I created .hex (firmware) file from the CDC Basic Demo project (Only change I made there is that i changed HID Bootload to MCHPUSB Bootload) and successfuly loaded it into my PIC18F4550 and restarted it.
Then I started the software (C# application - \Device - CDC - Basic Demo\PC Software Example) and connected my device by pressing "connect" buttom on the form. I wrote "1", pressed "Send Data" and I recieved "2", so everything worked fine. I also tried to press "Bootload" button on my PIC18F4550 board and it worked (program showed me "Button pressed--" in it's textBox).
But problem was when I tried to control LEDs connected to RD4-RD7. I can control only diodes on pins RD0-RD3.
Code:
In USB Device - CDC - Basic Demo - C18 - PICDEM FSUSB (Microchip MPLAB.project)
I opened
HardwareProfile - PICDEM FSUSB.h
and located this, where I simply added for more than 4 LEDS (default):
When I send data or just press the button, nothing happens - LED 5 is off... LEDs 5-7 simply don't work (I tried them all)...
HW scheme for better understanding:
My leds are connected on RD0 - RD7 (each one with 1K resistor)...
I don't know why there are just four LEDs that I can control... 1,2, mLED_3_Toggle(); or mLED_4_Toggle(); works fine...
I also tried change my PIC18F4550 (I have two chips) No change!
Thank you very much for your help!
HerrCat
In these days I am working on my project - controlling LEDs using CDC Basic demo firmware and C# application all from Microchip Solutions v2011-07-14 libraries.
I use rm18f4550 - MCHPUSB Bootload
I connected my device to USB port, pressed "Reset" button, then "Bootloader" button once. After that my computer recognized the device and asked for drivers - I installed drivers \Device - CDC - Basic Demo\inf. (I my PC it is shown as COM3 port). Everything worked.
Then I created .hex (firmware) file from the CDC Basic Demo project (Only change I made there is that i changed HID Bootload to MCHPUSB Bootload) and successfuly loaded it into my PIC18F4550 and restarted it.
Then I started the software (C# application - \Device - CDC - Basic Demo\PC Software Example) and connected my device by pressing "connect" buttom on the form. I wrote "1", pressed "Send Data" and I recieved "2", so everything worked fine. I also tried to press "Bootload" button on my PIC18F4550 board and it worked (program showed me "Button pressed--" in it's textBox).
But problem was when I tried to control LEDs connected to RD4-RD7. I can control only diodes on pins RD0-RD3.
Code:
In USB Device - CDC - Basic Demo - C18 - PICDEM FSUSB (Microchip MPLAB.project)
I opened
HardwareProfile - PICDEM FSUSB.h
and located this, where I simply added for more than 4 LEDS (default):
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 /** LED ************************************************************/ #define mInitAllLEDs() LATD &= 0xF0; TRISD &= 0xF0; #define mLED_1 LATDbits.LATD0 #define mLED_2 LATDbits.LATD1 #define mLED_3 LATDbits.LATD2 #define mLED_4 LATDbits.LATD3 [B] #define mLED_5 LATDbits.LATD4 #define mLED_6 LATDbits.LATD5 #define mLED_7 LATDbits.LATD6 #define mLED_8 LATDbits.LATD7[/B] #define mGetLED_1() mLED_1 #define mGetLED_2() mLED_2 #define mGetLED_3() mLED_3 #define mGetLED_4() mLED_4 #define mLED_1_On() mLED_1 = 1; #define mLED_2_On() mLED_2 = 1; #define mLED_3_On() mLED_3 = 1; #define mLED_4_On() mLED_4 = 1; #define mLED_5_On() mLED_5 = 1; #define mLED_1_Off() mLED_1 = 0; #define mLED_2_Off() mLED_2 = 0; #define mLED_3_Off() mLED_3 = 0; #define mLED_4_Off() mLED_4 = 0; #define mLED_1_Toggle() mLED_1 = !mLED_1; #define mLED_2_Toggle() mLED_2 = !mLED_2; #define mLED_3_Toggle() mLED_3 = !mLED_3; #define mLED_4_Toggle() mLED_4 = !mLED_4; [B]#define mLED_5_Toggle() mLED_5 = !mLED_5; #define mLED_6_Toggle() mLED_6 = !mLED_6; #define mLED_7_Toggle() mLED_7 = !mLED_7; #define mLED_8_Toggle() mLED_8 = !mLED_8;[/B] Then in main.c I located "ProcessIO" void and added: void ProcessIO(void) { BYTE numBytesRead; //Blink the LEDs according to the USB device status BlinkUSBStatus(); // User Application USB tasks if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return; if(buttonPressed) { if(stringPrinted == FALSE) { if(mUSBUSARTIsTxTrfReady()) { putrsUSBUSART("Button Pressed -- \r\n"); When the button is pressed - this works [B]mLED_5_Toggle();[/B] Turns on/off LED 5? stringPrinted = TRUE; } } } else { stringPrinted = FALSE; } if(USBUSARTIsTxTrfReady()) { numBytesRead = getsUSBUSART(USB_Out_Buffer,64); if(numBytesRead != 0) { BYTE i; for(i=0;i<numBytesRead;i++) { switch(USB_Out_Buffer[i]) { case 0x0A: case 0x0D: USB_In_Buffer[i] = USB_Out_Buffer[i]; break; default: USB_In_Buffer[i] = USB_Out_Buffer[i] +1; [B] mLED_5_Toggle();[/B] After that I also tried it here-Everytime I send data it should turn on LED5... Not for me. break; } } putUSBUSART(USB_In_Buffer,numBytesRead); } } CDCTxService(); } //end ProcessIO
When I send data or just press the button, nothing happens - LED 5 is off... LEDs 5-7 simply don't work (I tried them all)...
HW scheme for better understanding:
My leds are connected on RD0 - RD7 (each one with 1K resistor)...
I don't know why there are just four LEDs that I can control... 1,2, mLED_3_Toggle(); or mLED_4_Toggle(); works fine...
I also tried change my PIC18F4550 (I have two chips) No change!
Thank you very much for your help!
HerrCat
Last edited by a moderator: