MikroC PRO HID USB Programming and Proteus

Discussion on projects that are created by users and posted on mikroElektronika website.
Post Reply
Author
Message
Xtron
Posts: 35
Joined: 24 Oct 2013 19:57

MikroC PRO HID USB Programming and Proteus

#1 Post by Xtron » 24 Oct 2013 20:28

Guyz! I started USB development in MikroC Pro V 6.0 with PIC 18F4550 example give in MikroC help as:

Code: Select all

unsigned char readbuff[64] absolute 0x500;   // Buffers should be in USB RAM, please consult datasheet
unsigned char writebuff[64] absolute 0x540;

char cnt;
char kk;

void interrupt(){
   USB_Interrupt_Proc();                   // USB servicing is done inside the interrupt
}

void main(void){
  ADCON1 |= 0x0F;                         // Configure all ports with analog function as digital
  CMCON  |= 7;                            // Disable comparators

  HID_Enable(&readbuff,&writebuff);       // Enable HID communication

  while(1){
    while(!HID_Read())
      ;

    for(cnt=0;cnt<64;cnt++)
      writebuff[cnt]=readbuff[cnt];

    while(!HID_Write(&writebuff,64))
      ;
  }
}



Also include the USBdc.c file in the project but the hex file generated by this code is too small of 1 KB or of few lines as shown:


:0400000034EF0CF0DD
:1018CE000902290001010080320904000002030010
:1018DE0000000921010100012221000705810340BA
:0918EE000001070501034000019F
:1018F7000600FF0901A10119012940150026FF0073
:101907007508954081021901294075089540910293
:01191700C00F
:1019180012034800490044002000540045005300C9
:02192800540069
:10192A001201000200000008341201000100010245
:02193A000001AA
:0A193C000A035400650073007400F4
:041946000403090489
:020000040030CA
:0E00000020321F1EFF8881FF03C003E0034073
:00000001FF



where the example Hex file of MikroC is of 17 KB.
Problem is that my code is not working at all and no error is showing by the compiler where statistics show 37.1% of RAM and 39.5 of ROM but small hex file didn't look in that mood. And if I compile the example project in my compiler it's hex become small and code don't work at all on Proteus V8.1.
Attachments
Proteus Results
Proteus Results
Untitled.png (201.81 KiB) Viewed 15635 times
MikroC results
MikroC results
usb1.jpg (244.05 KiB) Viewed 15635 times

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: MikroC PRO HID USB Programming and Proteus

#2 Post by filip » 25 Oct 2013 14:46

Hi,

Please, can you set the Long HEX Format in the Output setting and see if this helps ?

Regards,
Filip.

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: MikroC PRO HID USB Programming and Proteus

#3 Post by jayanthd » 25 Oct 2013 15:37

Hi Xtron

Please zip and post the mikroC Project files and Proteus file. I have done many USB Simulations in Proteus using mikroC Code. Let me try to find the problem. In Proteus have you set Clock frequency properly as set in Code. Have you disabled WDT in Proteus?
[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

Xtron
Posts: 35
Joined: 24 Oct 2013 19:57

Re: MikroC PRO HID USB Programming and Proteus

#4 Post by Xtron » 26 Oct 2013 09:29

jayanthd wrote:Hi Xtron

Please zip and post the mikroC Project files and Proteus file. I have done many USB Simulations in Proteus using mikroC Code. Let me try to find the problem. In Proteus have you set Clock frequency properly as set in Code. Have you disabled WDT in Proteus?
I just solved the problem and want to share it with you that my compiler is not properly "C_acked" which is creating problem, and keeping my code limited to 2K. :D
I want to say thanks and now I have entered in new problem which is about C# usb hid application. I want code an C# Forum application you help is required as you said you have experience in that field. Waiting for your reply!
Thanks Again.

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: MikroC PRO HID USB Programming and Proteus

#5 Post by jayanthd » 26 Oct 2013 09:50

I have experience with mirkoC USB and vb.net mcHID.dll for USB communication. I also have experience with C# and Visual C#. If you need code using Visual C# then provide the driver used to communicate between C# app and USB. I will write a code for you.
[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

Xtron
Posts: 35
Joined: 24 Oct 2013 19:57

Re: MikroC PRO HID USB Programming and Proteus

#6 Post by Xtron » 26 Oct 2013 19:53

jayanthd wrote:I have experience with mirkoC USB and vb.net mcHID.dll for USB communication. I also have experience with C# and Visual C#. If you need code using Visual C# then provide the driver used to communicate between C# app and USB. I will write a code for you.
A lot of Thanks jayanthd I have done it using easyUSBHID.dll library but this one is demo version if you have some nice libraries then please tell me. We can also share our visual C# code, proteus simulations and mikroC code. I also want to know on what project you worked or working relative to USB. Thanks

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: MikroC PRO HID USB Programming and Proteus

#7 Post by jayanthd » 27 Oct 2013 09:51

http://www.edaboard.com/thread271037.html

http://www.edaboard.com/thread271146.html

These is one of my project using mcHID.dll from helmpcb.com and vb.net

Provide the link for demo version of easyUSBHID.dll I will try to write a VC#.net application.
[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

programmer5
Posts: 69
Joined: 28 Jan 2012 06:50
Location: Pakistan
Contact:

Re: MikroC PRO HID USB Programming and Proteus

#8 Post by programmer5 » 27 Oct 2013 18:40

Example code given with compiler works perfect even in Proteus. I checked it myself.

Xtron
Posts: 35
Joined: 24 Oct 2013 19:57

Re: MikroC PRO HID USB Programming and Proteus

#9 Post by Xtron » 28 Oct 2013 09:39

programmer5 wrote:Example code given with compiler works perfect even in Proteus. I checked it myself.
thnx programmmer5 the problem was not in code, whether it is in compiler. compiler was not registered and running in demo version:.

Xtron
Posts: 35
Joined: 24 Oct 2013 19:57

Re: MikroC PRO HID USB Programming and Proteus

#10 Post by Xtron » 28 Oct 2013 09:45

jayanthd wrote:http://www.edaboard.com/thread271037.html

http://www.edaboard.com/thread271146.html

These is one of my project using mcHID.dll from helmpcb.com and vb.net

Provide the link for demo version of easyUSBHID.dll I will try to write a VC#.net application.
here is the link to download the .dll file and project examples, you can google it as "easyusbhidnetclass.org":
http://www.microgenios.com.br/Examples% ... ss.org.zip

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: MikroC PRO HID USB Programming and Proteus

#11 Post by jayanthd » 29 Oct 2013 05:45

Ok. I was successful in using easyUSBHID.dll. I have written an example VC#.net code and it is communicating with microcontroller in Proteus and also real hardware. I can write a code for you if you send me the VC# 2010 or 2012 application and mention how the app should work. Just design the GUI interface for the VC# application as needed and send me the VC# files. I will add the code to make it work.

It is very easy to Use. I will try with VB.net and reply. Simulation video link attached.

https://mega.co.nz/#!Ms5VCaaB!O5c7U34hY ... RWQ1ehpQLE

https://mega.co.nz/#!dkwVnSZD!Vti4by8Rh ... 6O55m6DbrA
[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

Xtron
Posts: 35
Joined: 24 Oct 2013 19:57

Re: MikroC PRO HID USB Programming and Proteus

#12 Post by Xtron » 02 Nov 2013 09:22

jayanthd wrote:Ok. I was successful in using easyUSBHID.dll. I have written an example VC#.net code and it is communicating with microcontroller in Proteus and also real hardware. I can write a code for you if you send me the VC# 2010 or 2012 application and mention how the app should work. Just design the GUI interface for the VC# application as needed and send me the VC# files. I will add the code to make it work.

It is very easy to Use. I will try with VB.net and reply. Simulation video link attached.

https://mega.co.nz/#!Ms5VCaaB!O5c7U34hY ... RWQ1ehpQLE

https://mega.co.nz/#!dkwVnSZD!Vti4by8Rh ... 6O55m6DbrA
jayanthd i watched the video you send, thanks a lot for this. I want to say that easyUSBHID.dll file was in demo version whom's link I send you and then you use it in your application, do you eliminate its demo limit for using in your tutorial that you send me. Thanks
I publish this project on Libstock you can see and download complete project.
http://www.libstock.com/projects/view/8 ... pic18f4550

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: MikroC PRO HID USB Programming and Proteus

#13 Post by jayanthd » 02 Nov 2013 12:45

do you eliminate its demo limit for using in your tutorial that you send me.
My Company purchased an unlimited license paying some $455. I can't provide the key for the dll as it is registered with my Company's details (Address, etc...) but if You provide the VC# code or VC# GUI then I will write a code using my Company's key so that it runs beyond 30 minutes.

See attached example. Install the file by running setup.exe. It is a VC#.net application for USB HID using easyUSBHID.dll

Download easyUSBHIDNetClass.dll from easyUSBHIDNetClass.org or from the .rar file and put it in windows\system32 folder.

Run Proteus simulation and click the buttons in th VC# app.

https://mega.co.nz/#!Vk4y0KZb!fj-rLF9wv ... OjxBRca0SA

https://mega.co.nz/#!94plFQBD!RD-10WU8O ... 9SQesKMmyk

http://youtu.be/ovpJvgB9-64
[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

turkmenab
Posts: 1
Joined: 05 Mar 2015 06:23

Re: MikroC PRO HID USB Programming and Proteus

#14 Post by turkmenab » 05 Mar 2015 06:26

Hi XTron,

I am also having the same problem that my hex code is less than 1 KB. Can you help me to fix the problem?

Thanks, Abdullah

Xtron
Posts: 35
Joined: 24 Oct 2013 19:57

Re: MikroC PRO HID USB Programming and Proteus

#15 Post by Xtron » 07 Mar 2015 10:00

Problem is about the cracked version if you r using. Other option is to set the project settings, include libraries properly.

Post Reply

Return to “User Projects”