mikroC USB and Proteus Simulation
mikroC USB and Proteus Simulation
Hello all,
I was wondering whether anyone has managed to run their mikroC USB code using the Proteus USB simulation? My simulated circuit seems to work fine, but there doesn't seem to be any USB activity. The real hardware works fine as well, so I'm sure the code's fine.
--Amr
I was wondering whether anyone has managed to run their mikroC USB code using the Proteus USB simulation? My simulated circuit seems to work fine, but there doesn't seem to be any USB activity. The real hardware works fine as well, so I'm sure the code's fine.
--Amr
Hi mbaser,
I already have the Proteus USB simulator. The issue is getting my mikroC firmware to work with the simulation. The screenshot shows what I'm getting at the moment.
The LCD screen displays text, so it seems like the firmware is working fine. I guess the question to ask is, does anyone know if the mikroC USB firmware works with the Proteus USB simulation?
--Amr
I already have the Proteus USB simulator. The issue is getting my mikroC firmware to work with the simulation. The screenshot shows what I'm getting at the moment.
The LCD screen displays text, so it seems like the firmware is working fine. I guess the question to ask is, does anyone know if the mikroC USB firmware works with the Proteus USB simulation?
--Amr
There are methods using the HEX or making an MPLAB conversion of the mE ASM. Otherwise, mikroC is not on the supported compilers list:
http://www.labcenter.co.uk/products/compilers.cfm
http://www.labcenter.co.uk/products/compilers.cfm
[color=darkred][b]xor[/b][/color]
[url=http://circuit-ed.com]CircuitED -[/url]
[url=http://circuit-ed.com]CircuitED -[/url]
Code: Select all
/*
* Project name:
HIDtest (Testing the USB HID connection)
* Copyright:
(c) MikroElektronika, 2005 - 2006
* Revision History:
20050502:
- initial release;
* Description:
This example establishes connection with the HID terminal that is active
on the PC. Upon connection establishment, the HID Device Name will appear
in the respective window, and the software will start transmitting fixed
message over the USB HID connection, for eternity.
* Test configuration:
MCU: PIC18F2550
Dev.Board: EasyPIC2/EasyPIC3
Oscillator: HS 8.000 MHz (USB osc. is raised with PLL to 48.000MHz)
Ext. Modules: USB-HID terminal board/None
SW: mikroC v6.0
* NOTES:
- Be VERY careful about the configuration flags for the 18F4550 - there's
so much place for mistake!
*/
unsigned char k;
unsigned char userWR_buffer[64];
unsigned int df = 0 absolute 15;
const char *text = "Microchip Technology Inc.\r\n";
//**************************************************************************************************
// Main Interrupt Routine
//**************************************************************************************************
void interrupt()
{
HID_InterruptProc();
}
//**************************************************************************************************
//**************************************************************************************************
// Initialization Routine
//**************************************************************************************************
void Init_Main()
{
//--------------------------------------
// Zabrana svih interapta
//--------------------------------------
INTCON = 0; // Disable GIE, PEIE, TMR0IE,INT0IE,RBIE
INTCON2 = 0xF5;
INTCON3 = 0xC0;
RCON.IPEN = 0; // Disable Priority Levels on interrupts
PIE1 = 0;
PIE2 = 0;
PIR1 = 0;
PIR2 = 0;
ADCON1 |= 0x0F; // Configure all ports with analog function as digital
//--------------------------------------
// Ports Configuration
//--------------------------------------
TRISA = 0xFF;
TRISB = 0xFF;
TRISC = 0xFF;
//TRISD = 0;
//TRISE = 0x07;
LATA = 0;
LATB = 0;
LATC = 0;
//LATD = 0;
//LATE = 0;
//--------------------------------------
// Clear user RAM
// Banks [00 .. 07] ( 8 x 256 = 2048 Bytes )
//--------------------------------------
}
//**************************************************************************************************
//**************************************************************************************************
// Main Program Routine
//**************************************************************************************************
void main()
{ char i;
Init_Main();
HID_Enable((unsigned)&userWR_buffer,(unsigned)&userWR_buffer);
Delay_mS(1000);
Delay_mS(1000);
while(1) {
Delay_mS(1000);
i=0;
while(text[i]) {
userWR_buffer[0]= text[i++];
while (!HID_Write((unsigned)&userWR_buffer, 1));
}
}
Delay_mS(1000);
HID_Disable();
}
//**************************************************************************************************
Thanks for your replies, chaps.
@mbaser: Thanks for your code. I tried it out but unfortunately it still didn't work in the simulation. Have you had success in simulating mikroC USB code in Proteus?
@xor: I can accept that mikroC is not supported in terms of debugging capabilities, however, that should not stop Proteus from running the hex file. On the very same link you have in your post is the following quote:
I've done some more tests and have found some interesting results. I wrote the following USB test code:
Now, this software works perfectly on hardware - the LED flashes and the letter 'A' is sent via USB. The interesting thing is that if I load the hex file into Proteus, the LED on RA0 stays on constantly (it is meant to flash at 1Hz) and of course there is no USB activity in the simulation. What's even better is that if I remove all the USB code from the project, recompile and load it into Proteus, the simulation works fine, with the LED flashing as expected. So it seems like the USB code is causing problems with the Proteus simulation.
What I'd like to know is if there might be any difference between the USB code compiled using mikroC and mikroBasic. The reason why I ask this is due to this post. You can see a screenshot of his simulation, but what's interesting is the fact that the Proteus USB Transaction Analyzer has simulated USB activity on his PIC and Windows has even asked for a driver (although as the post states that shouldn't have happened).
As I don't have mikroBasic (and the demo limit is too short) I was wondering whether someone would be kind enough to rewrite my little test program in mikroBasic and email me the hex file so that I can test it? I'm using a PIC18F4550 and a 20Mhz crystal (PIC clock = 20Mhz, USB clock derived from 20MHz to produce 48MHz). My email address amrbekhit !!at! gmail !dot!! com
Thanks
--Amr
@mbaser: Thanks for your code. I tried it out but unfortunately it still didn't work in the simulation. Have you had success in simulating mikroC USB code in Proteus?
@xor: I can accept that mikroC is not supported in terms of debugging capabilities, however, that should not stop Proteus from running the hex file. On the very same link you have in your post is the following quote:
And I have found this to be true so far (USB excluded) - programs I write in mikroC work perfectly in Proteus.All Proteus VSM processor models are able to run binary files (i.e. Intel or Motorola Hex files) produced by any assembler or compiler. However, the debugging facilities available are very limited since the processor model has no way to correlate the machine code it is executing with your original source program.
I've done some more tests and have found some interesting results. I wrote the following USB test code:
Code: Select all
unsigned char read[64],write[64];
void interrupt(void)
{
HID_InterruptProc();
}
void main(void)
{
ADCON1=0x0F;
CMCON=0x07;
TRISA=0;
PORTA=0;
HID_Enable(&read,&write);
while(1)
{
write[0]='A';
while(!HID_Write(write,1));
PORTA.RA0=~PORTA.RA0;
Delay_ms(500);
}
}
What I'd like to know is if there might be any difference between the USB code compiled using mikroC and mikroBasic. The reason why I ask this is due to this post. You can see a screenshot of his simulation, but what's interesting is the fact that the Proteus USB Transaction Analyzer has simulated USB activity on his PIC and Windows has even asked for a driver (although as the post states that shouldn't have happened).
As I don't have mikroBasic (and the demo limit is too short) I was wondering whether someone would be kind enough to rewrite my little test program in mikroBasic and email me the hex file so that I can test it? I'm using a PIC18F4550 and a 20Mhz crystal (PIC clock = 20Mhz, USB clock derived from 20MHz to produce 48MHz). My email address amrbekhit !!at! gmail !dot!! com
Thanks
--Amr
Hi fvgm,
Unfortunately I haven't succeeded yet.
--Amr
Unfortunately I haven't succeeded yet.
--Amr
[url=http://www.mikroe.com/forum/viewtopic.php?p=69489]mikroC USB Joystick[/url]
[url=http://helmpcb.com/software/usb-hid-template-for-visual-basic-2005]USB HID Template for Visual Basic 2005/2008/2010[/url]
[url=http://www.mikroe.com/forum/viewtopic.php?p=55958]Storing floats and other objects in EEPROM[/url]
[url=http://helmpcb.com/software/usb-hid-template-for-visual-basic-2005]USB HID Template for Visual Basic 2005/2008/2010[/url]
[url=http://www.mikroe.com/forum/viewtopic.php?p=55958]Storing floats and other objects in EEPROM[/url]
fabim, could you tell us which version of Proteus you are using? Also, could you post a copy of a working hex file?
Thanks
--Amr
Thanks
--Amr
[url=http://www.mikroe.com/forum/viewtopic.php?p=69489]mikroC USB Joystick[/url]
[url=http://helmpcb.com/software/usb-hid-template-for-visual-basic-2005]USB HID Template for Visual Basic 2005/2008/2010[/url]
[url=http://www.mikroe.com/forum/viewtopic.php?p=55958]Storing floats and other objects in EEPROM[/url]
[url=http://helmpcb.com/software/usb-hid-template-for-visual-basic-2005]USB HID Template for Visual Basic 2005/2008/2010[/url]
[url=http://www.mikroe.com/forum/viewtopic.php?p=55958]Storing floats and other objects in EEPROM[/url]
Can you post you project with proteus
Hello,
Can you attach your project? I am also working on usb via proteus.
Thank you
Pranas
Can you attach your project? I am also working on usb via proteus.
Thank you
Pranas
-
- Posts: 46
- Joined: 16 Apr 2011 14:37
Re: mikroC USB and Proteus Simulation
Are you getting any error when you put your code in Proteus uC,
If not then try this..
Pause the Simulation and then right click on PIC18 CPU and then Click on USB analyzer.
Hope this solve your problem.
If not then try this..
Pause the Simulation and then right click on PIC18 CPU and then Click on USB analyzer.
Hope this solve your problem.