USB

2013. 1. 11. 00:29
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

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
Posted by ElectricShock
:
BLOG main image
잡동사니들(지극히 개인취향인...) (다른글에도 댓글 부탁해요♥) You May Leave English Messages on GuestBook. by ElectricShock

공지사항

카테고리

분류 전체보기 (782)
Programming(=프로그래밍) (3)
MiDi (2)
Animation (4)
Blender (3D Graphic Program.. (10)
Blendtuts.com (Series) (1)
Blender 기초 팁들 (2)
Processing (디지털미디어과) (2)
Music (1)
Books in the world (0)
Communication(CAN, UART, et.. (12)
MCU Examples (PIC 기반) (7)
Transistor (1)
Mikro C Pro (11)
Mikro Pascal (1)
Proton IDE (0)
Robot (0)
Swift 3D (1)
Dummies Series (1)
All about Hacking (0)
제2 외국어 (1)
PIC 해외서적들 (3)
AVR (25)
PIC (MikroC) (MPLAB) (4)
Assembly (2)
ARM (3)
Arduino (26)
PSpice (1)
Proteus ISIS (14)
CodeVision (2)
FPGA (15)
MPLAB (24)
PCB (the Procedure) (15)
3D Printer (5)
PICKIT3 (6)
Matlab (11)
RaspBerry PI (15)
BeagleBone (1)
Android Studio (17)
졸업작품 (172)
Korea History (0)
Issue(사회) (73)
Multimeter 리뷰 (1)
Oscilloscope (1)
A (34)
B (19)
J (6)
C (32)
P (12)
T (37)
H (12)
I (12)
M (44)
R (5)
E (5)
F (2)
D (9)
O (2)
L (7)
S (9)
W (2)
V (6)
G (14)
Visual C++ or Visual Studio (2)
Android App Development (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백