Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help needed with USB interfacing for PIC18F4550

Status
Not open for further replies.

maniyuri

Newbie level 6
Joined
Aug 2, 2010
Messages
14
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Location
islamabad
Activity points
1,365
Hi all,

I have tried using the USB example code from the library of MikroC with PIC18F4550 but it is not working. It gives an error :Main function not defined.


Code:
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))
      ;
  }
}


Please help me out. I am totally new to USB interfacing. If there is some material that you could refer, it would be of great help.

I also had some other doubts. What is the value in front of the first two lines (absolute 0x500, absolute 0x540). Any help will be greatly appreciated.

Regards.
 
Last edited by a moderator:

an error :Main function not defined.

Looks to me like your "main" should be called "Main"

unsigned char readbuff[64] absolute 0x500; // Buffers should be in USB RAM, please consult datasheet
unsigned char writebuff[64] absolute 0x540;
absolute address is to force where processor puts the array--at absolute addr 0x500 in usb memory
 

Your project must include C file with main routine.
5_1318796916.png
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top