It is currently 23 Feb 2019 13:47

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: 21 Nov 2014 14:58 
Offline

Joined: 08 May 2013 18:31
Posts: 628
Location: Bangalore
How to use USB CDC Visrtual COM Port library ?

I have EasyPICv7 and I want to send ADC data through USB CDC Virtusl COM Port. Here is my code for 18F4550. It is not working. PC doesn't detect any Virtual COM port. I am using Windows 7 32 bit Ultimate.


In Device Manager it shows VCP_Demo with an yello exclamation mark. What drivers I have to install and from where I can get the drivers ?


Edit: The problem got solved. I found the drivers in Packages folder. Now the project works fine.

#include <stdint.h>

// Lcd pinout settings
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D7 at LATB3_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D4 at LATB0_bit;

// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;

// Buffer of 64 bytes
char buffer[64] absolute 0x500;

double adcVal = 0.0, prevVal = 0.0;
char str[23];
unsigned int i = 0;

// USB interrupt service routine
void interrupt(){
  // Call library interrupt handler routine
  USBDev_IntHandler();
}

void USBDev_CDCParamsChanged(){

}

extern const uint8_t _USB_CDC_BULK_EP_IN;   // Data interface IN endpoint
extern const uint8_t _USB_CDC_BULK_EP_OUT;  // Data interface OUT endpoint
uint8_t dataReceived = 0;
uint16_t dataReceivedSize;

void USBDev_CDCDataReceived(uint16_t size){
  dataReceived = 1;
  dataReceivedSize = size;
}

void main(void){
  ADCON1 = 0x0F;                         // Configure all ports with analog function as digital
  CMCON  = 7;
 
  TRISA = 0xFF;
  TRISB = 0x00;
  TRISC = 0x80;
  TRISD = 0x00;
  TRISE = 0x08;
 
  PORTA = 0x00;
  PORTB = 0x00;
  PORTC = 0x00;
  PORTD = 0x00;
  PORTE = 0x08;
 
  LATA = 0x00;
  LATB = 0x00;
  LATC = 0x00;
  LATD = 0x00;
  LATE = 0x00;
 
  LCD_Init();
  LCD_Cmd(_LCD_CURSOR_OFF);
  LCD_Cmd(_LCD_CLEAR);
  LCD_Out(1,1,"ADC + USB Example");
  LCD_Out(2,1,"V = ");                           

  // Initialize CDC Class
  USBDev_CDCInit();
 
  // Initialize USB device module
  USBDev_Init();
 
  // Enable USB device interrupt
  IPEN_bit = 1;
  USBIP_bit = 1;
  USBIE_bit = 1;
  GIEH_bit = 1;

  // Infinite loop
  while(1){
 
        adcVal = ADC_Read(0);
        adcVal = adcVal * 5.0 / 1023.0;
       
        if(adcVal != prevVal) {
       
                  FloatToStr(adcVal, str);
                  LCD_Out(2,5,"                ");
                  LCD_Out(2,5,LTrim(str));
                 
                  strcat(str, "\r\n");                                   
        }
    // If device is configured
    if(USB_CDC_DeviceConfigured){
      // Set receive buffer where received data is stored
      USBDev_CDCSetReceiveBuffer(buffer);

      // Reset configured flag
      USB_CDC_DeviceConfigured = 0;
    }
        while(str[i]) {
       
             buffer[i] = str[i];
             ++i;
        }
           
        buffer[i] = '\0';
        i = 0;
      // Send back received packet
      USBDev_CDCSendData(buffer, strlen(buffer));
      // Prepare receive buffer
     
  }

}

_________________
[HW:] EasyPIC v7, mikroProg PIC, AVR, STM32, PSoC, Tiva, 8051
[SW:] mikroC PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroBasic PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroPascal PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
Visual GLCD, Visual TFT


Top
 Profile  
 
PostPosted: 16 Dec 2014 09:58 
Offline
mikroElektronika team
User avatar

Joined: 25 Jan 2008 09:56
Posts: 10175
Hi,

I'm glad that you have solved this issue.

Regards,
Filip.


Top
 Profile  
 
PostPosted: 01 Aug 2016 08:34 
Offline

Joined: 01 Aug 2016 08:26
Posts: 1
I've tried this code, but Value of ADC doesn't refresh in Usart terminal. It shows only the initial value, but when I change it with variable resistor, it doesn't change in Usart terminal. Please help!


Top
 Profile  
 
PostPosted: 04 Aug 2016 09:54 
Offline
mikroElektronika team
User avatar

Joined: 15 Jan 2016 12:50
Posts: 1717
Hi mozilla92,

Welcome to the MikroE forum.

I'm sorry for the inconvenience, I was able to reproduce the same behavior
and I have reported it to our development team.

Best regards,
Lana


Top
 Profile  
 
PostPosted: 20 Dec 2016 08:48 
Offline

Joined: 17 Oct 2016 12:08
Posts: 1
Hey guys where can i get the drivers for USB CDC i am using PIC 18F4550 and windows 10: on my Device manager the drivers show "Mikroe Virtual Com port" with a yellow exclamation and code 10 is there something wrong am doing because at first it was an issue of digital signature not being signed of which i solved it but now its these any ideas?


Top
 Profile  
 
PostPosted: 21 Dec 2016 14:33 
Offline
mikroElektronika team
User avatar

Joined: 15 Jan 2016 12:50
Posts: 1717
Hi Teebonks,

Welcome to the MikroE forum.

You can find drivers in the installation folder of the Package,
for example in:

c:\Users\Public\Documents\Mikroelektronika\mikroC PRO for PIC\Packages\USB_Device_PIC\Examples\VCPDriver\

Best regards,
Lana


Top
 Profile  
 
PostPosted: 07 Jan 2019 02:17 
Offline

Joined: 07 Jan 2019 01:46
Posts: 3
Hello,

I am trying to use USB CDC Visrtual COM Port library.
Now I am trying to use following Example.
Examples\PIC18F4550\Virtual COM Port

When driver installation wizard
I set following pass for the driver.
"C:\Users\Public\Documents\Mikroelektronika\mikroC PRO for PIC\Packages\USB_Device_PIC\Examples_work\VCPDriver

But I have faced error as below.

"Driver software for the device has been found, but error has occurred."
"File - Mikroe Virtual Com Port - is not there."

Note: Original massage is Japanese.

How can I solve this Error?

Thank you.


Top
 Profile  
 
PostPosted: 09 Jan 2019 11:57 
Offline
mikroElektronika team
User avatar

Joined: 18 Dec 2018 10:30
Posts: 129
Hi,

Welcome to the MikroE forum.

Could you please provide me with more details about this issue?
Also, which Windows you are using?

Please send me the screenshot of the Device Manager after writing an example of VCP to the MCU?

Kind regards,

_________________
Stefan Filipović


Top
 Profile  
 
PostPosted: 10 Jan 2019 01:47 
Offline

Joined: 07 Jan 2019 01:46
Posts: 3
Hi Stefan,

Thank you very much for your reply.

I am using Windows 7 Professional Service Pack 1.

And followings are screenshot images of
device manager, property of device manager ,
and popped up window after driver software update.

Thank you.


Attachments:
File comment: Device Manager
There is VCP demo with yellow ! alert.

device manager.png
device manager.png [ 63.61 KiB | Viewed 167 times ]
File comment: property of VCP Demo in Device Manager
VCP Demo property.png
VCP Demo property.png [ 29.73 KiB | Viewed 167 times ]
File comment: popped up window after driver software update.
Driver software update.png
Driver software update.png [ 53.82 KiB | Viewed 167 times ]
Top
 Profile  
 
PostPosted: 10 Jan 2019 11:09 
Offline
mikroElektronika team
User avatar

Joined: 18 Dec 2018 10:30
Posts: 129
Hi,

I just tested the VCP_Example project from USB_Device_PIC library on the PIC18F4550 and EasyPIC v7 development board and it works well.
I have tested on both Windows 7 and Windows 10.

Can you tell me which development board you are using?
Have you installed USB CDC drivers on your Windows?

Here is the link to these drivers for Windows 7:
https://www.silabs.com/documents/public ... rivers.zip
I suggest installing them using administrator privileges (right click on the icon -> run as administrator).

Sometimes the system language of Windows could cause problems with the driver installation.
Unfortunately, you cannot change system language on Windows 7 Professional.
Have you thought about upgrading to Windows 7 Ultimate?
Here is the explanation of how this could be done:
https://answers.microsoft.com/en-us/win ... bf5?auth=1

Kind regards,

_________________
Stefan Filipović


Top
 Profile  
 
PostPosted: 15 Jan 2019 08:44 
Offline

Joined: 07 Jan 2019 01:46
Posts: 3
Hi stefan,

Thank you very much for your information.

I could connect my PIC18F4550 board to another windows 10 PC.
In installation of device driver, my PC did not request me any additional operation.
After installation of device driver, I could confirm call back function by teraterm.
It seems no problems.

In VCP_Example.c there are following comment.

Notes: Example uses CDC Driver included in Windows. An .inf file
is supplied with the example in order to match the driver
with this device (user must guide driver installation
wizard to the VCPDriver folder).

Do I still need Device driver update by VCPDriver folder on my windows 10 PC?

Thank you.


Top
 Profile  
 
PostPosted: 15 Jan 2019 10:00 
Offline
mikroElektronika team
User avatar

Joined: 18 Dec 2018 10:30
Posts: 129
Hi Toshihito,

You're welcome.

I'm glad that you have managed to solve this.

You do not need to update device drivers if it's already working as expected with the present drivers.

Kind regards,

_________________
Stefan Filipović


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: