My USB device doesn't receive bytes from pc

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
surajka
Posts: 2
Joined: 23 Apr 2009 13:54

My USB device doesn't receive bytes from pc

#1 Post by surajka » 23 Apr 2009 14:43

My project using pic18f2550 is given below . computer detects my device.
MY device id and manufacuture id are correctly recognized. i dont know whether the controller receives the data i send. i use mikroc's hid terminal to communicate with the device. The status led is on at port b, and my led at port b blinks on reset, but only one time. I have programmed to blink it once again after enabling the usb port.

That is no operation is executed after enabling the usb hid.
i use 8mhz crystal , use internal pll oscillator divide by two,
and all other configuration bits are ok.
can anybody help with this..?
i have given my program below you can download and see all my project files at
http://surajka.jimdo.com/downloads/


somebody please help....



This is my code
#include "USBdsc.c"
void Send_To_Usart();

unsigned short Read_buffer[64];
unsigned short Write_buffer[64];
unsigned short int No_Of_Bytes_Received;

// Timer interrupt service routine
void interrupt()
{
HID_InterruptProc(); // Keep alive
TMR0L = 100; // Re-load TMR0L
INTCON.TMR0IF = 0; // Re-enable TMR0 interrupts
}

void main() // Start of MAIN program
{
ADCON1 = 0xFF; // Set PORTB to digital I/O //STATUS LED
TRISB = 0; // Set PORTB to outputs
PORTB = 0XFF; // Clear all outputs

// Set interrupt registers to power-on defaults
// Disable all interrupts

INTCON=0;
INTCON2=0xF5;
INTCON3=0xC0;
RCON.IPEN=0;
PIE1=0;
PIE2=0;
PIR1=0;
PIR2=0;
// Configure TIMER 0 for 3.3ms interrupts. Set prescaler to 256
// and load TMR0L to 100 so that the time interval for timer
// interrupts at 48MHz is 256*(256-100)*0.083 = 3.3ms
// The timer is in 8-bit mode by default
T0CON = 0x47; // Prescaler = 256
TMR0L = 100; // Timer count is 256-156 = 100
INTCON.TMR0IE = 1; // Enable T0IE
T0CON.TMR0ON = 1; // Turn Timer 0 ON
INTCON = 0xE0; // Enable interrupts

Delay_Ms(500);
PORTB=0;
Delay_Ms(500);
PORTB=0XFF;
Usart_Init(4800);
Hid_Enable(&Read_buffer, &Write_buffer);

PORTB=0;
Delay_Ms(500);
PORTB=0xFF;
for(;;) // do forever

{
if(No_Of_Bytes_Received = Hid_Read())
// Read from the USB port. Number of bytes read is in No_Of_Bytes_Received
{
PORTB=0;
Delay_Ms(500);
PORTB=0xFF;
Delay_Ms(500);
PORTB=0;
Delay_Ms(500);
PORTB=0XFF;

Send_To_Usart();

PORTB=0;
Delay_Ms(500);
PORTB=0xFF;
Delay_Ms(500);
PORTB=0;
Delay_Ms(500);
PORTB=0XFF;

No_Of_Bytes_Received=0;
}
}
Hid_Disable();
}


void Send_To_Usart() //send the message received from the usb port.
{
int i;
for(i=0; i < No_Of_Bytes_Received; i++)
Usart_Write(Read_buffer);
}

surajka
Posts: 2
Joined: 23 Apr 2009 13:54

#2 Post by surajka » 24 Apr 2009 21:48

somebody please help with a solution..[/list]

Post Reply

Return to “mikroC PRO for PIC General”