http://www.mikroe.com/forum/viewtopic.php?t=20939
궁금한 내용 있으면 댓글 남겨주세요
simply I need my computer to detect a usb connection in proteus
the crystal is 20Mhz and i setup usb drivers
my simple code is the example at the Mikroc projects usb read and write
Coding...
unsigned char k;
unsigned char userWR_buffer[64], userRD_buffer[64];
const char *text = "MIKROElektronika Compilers ER \r\n";
//*********************************************************************
// Main Interrupt Routine
//********************************************************************
void interrupt()
{
HID_InterruptProc();
}
//**********************************************************************
//**************************************************************************************************
// Initialization Routine
//**************************************************************************************************
void Init_Main()
{
//--------------------------------------
// Disable all interrupts
//--------------------------------------
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
CMCON |= 7; // Disable comparators
//--------------------------------------
// 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()
{
unsigned char i, ch;
Init_Main();
HID_Enable(&userRD_buffer, &userWR_buffer);
Delay_ms(1000); Delay_ms(1000);
while (1)
{
k = HID_Read();
i = 0;
while (i < k)
{
ch = userRD_buffer[i];
userWR_buffer[0] = ch;
while (!HID_Write(&userWR_buffer, 1)) ;
i++;
}
}
HID_Disable();
}
Q & A
Where is RESET circuit on pin 1.
리셋 회로는 어디있나?
Thanks for your replay.
The proteus program donnot need for reset circuit
but I connect it to the pin No.1
but It still has no response.
What do you think about that problem?
프로테우스는 필요로하지않는다. 리셋 회로를
Try example "Hid ReadyWrite test" in example folder.
If that don't help try MicroC Pro compiler Version.
경로 ▼
(C:\Program Files\Mikroelektronika\mikroC PRO for PIC\Examples\Internal MCU modules\p18F4550)
Thank you alot for your reply
I have some questions
What exactly this function do?
이 함수가 하는게 정확이 무엇인가? ▽
HID_Write(&userWR_buffer, 1)
Write 1 byte(first byte in buffer).
There is two potential problems:
If your Send/Receive buffer size are different than usbdsc.c file:
만약 네 송수신 버퍼 사이즈가 다르면
unsigned char const HID_INPUT_REPORT_BYTES =1;
unsigned char const HID_OUTPUT_REPORT_BYTES =1;
Calling HID_Write(&userWR_buffer)
without blocking call
could hang PIC
if you try to send more data
before previous USB packet is send.
.
.
.
'MCU Examples (PIC 기반)' 카테고리의 다른 글
Controlling Stepper Motor in FDD(=플로피디스크 드라이브) (0) | 2013.02.24 |
---|---|
Parallel Dot Matrix (0) | 2013.02.01 |
SD Card (0) | 2013.01.11 |
Using Relays with Microcontrollers (0) | 2013.01.03 |