Why I cannot set up the connection between the USB Port and PC??? Urgent!!!

Status
Not open for further replies.

gomera

New Member
Hi there,

Im doing my final year project that asks me to store the information (entered in the GUI) in the PIC16C745 on my board. But i cannot set up the connection between them. I just use the USB Connector to connect the USB Port on my board and PC, i also installed the HIDComm in the Visual Basic and checked all the connections(they're all corect).

Can someone give me some suggestion???VERY URGENT!!!

The picture of my board is in my attachment.

Thx alot..
 

Attachments

  • IMG_0089.jpg
    254.8 KB · Views: 208
  • aaa.JPG
    59.4 KB · Views: 174
Last edited:
does it need drivers? when you plug it into pc does it even recognise something has been plugged in? are you sure your usb works? does it need external power if so is it on? thats all i can think of that might help
 
does it need drivers? when you plug it into pc does it even recognise something has been plugged in? are you sure your usb works? does it need external power if so is it on? thats all i can think of that might help

i use the external Power Supply and when i plugged in, nothing happens, but when i remove the external power supply, the PC can provide the power support for my board(why??)
 
The caps are mandatory. Too bad you're stuck with that 1990's JW PIC. Check out my Unicorn kit manual to see where the caps tend to go.

Looking at the Telit hardware manual.
How are you powering it with 3.8V?
How are you turning it on (needs a 1s low pulse on the /ON pin)
It needs 380mA, that's more than a traditional USB will supply by default, your USB firmware will have to request more before powering up the Telit modem.
Seems the device does not need the MAX232 as it's logic level serial.
Those hardware handshaking lines might be useful.

Edit, since the PIC is 5V you will need some form of level translation as described in detail in the Telit hardware documentation.
 
Last edited:

I just got 150nF capacitor can?? I think it is connected between Pin14(Vusb in my PIC) to the 5V..

The GSM Modem can work(to send message), my problem is only about the USB transmission.=]

Thx!!
 
Last edited:
You still need at least one at VDD & VSS, another 150nF cap is fine. You oscillator might do well with one too.
How do you know the PIC is communicating with the Telit? Do you have a serial port analyzer connected?

How are you powering the Telit? Where's the 3.8V supply?

Isn't the VUSB cap supposed to go to GND & VUSB?
 
Last edited:
Is this your first PIC project? USB is quite difficult even for seasoned PIC programmers, doing it on a UV PIC would be sheer hell. Worse yet on an ancient 14bit core PIC to boot.
 
Last edited:

The project is to send message to cell phone when i press the push button on my board. This part is successful that i provide a 9V to the Modem.

I try the capacitor first~=]
 
Is this your first PIC project? USB is quite difficult even for seasoned PIC programmers, doing it on a UV PIC would be sheer hell. Worse yet on an ancient 14bit core PIC to boot.

I tried to connect like, Vusb-->capacitpr-->GND, but it still didnt work..=[ =[ =[

The 4-pin USB should be connected like GND -->D+ -->D- -->5V right??
 
Last edited:
Hi gomera the bypass cap ( your 150nf) should a close as you can between the Vss, Vdd pins. The osc doesn't need any external caps as that type of can osc the caps are in the device. As Bill has said for a student using such an ancient UV erase pic will be a hard job. But I do take my hat to you for trying to do your best. Could you upload your code as there might be a problem there and we can help if there is.

Regards Bryan
 

Thank you for ur reply!!!

You mean that i should put my cap between Vdd(Pin20) & Vss(Pin19)??Should it be between Vusb & GND..already blur...

I use Visual Basic to create my GUI and use MPLAB to wrtie C++ in my PIC.

In the MPLAB, I create one Source File & two Header Files, which i also not sure about..

Project.c:

#include <htc.h>

#ifndef _XTAL_FREQ
#define _XTAL_FREQ 4000000
#endif

__CONFIG(WDTDIS&PWRTDIS&UNPROTECT&H4);

void Delay(int loop)
{
int i;
for(i=0;i<loop;i++);
}

void init(void)//Assign & Initialize PORTB I/0
{
PORTB=0x02;
TRISB=0x02;
}

void initUSART(void)//Initialize USART
{
TXSTA=0x22;
RCSTA=0x90;
SPBRG=0x9b;
}

void enter(void)//ACSII Keycode for "Enter"
{
while(!TRMT);
TXREG=0x0d;
}

void tx_start(void)//ASCII Keycode for "Ctrl+Z"
{
while(!TRMT);
TXREG=0x1a;
}

void send_msg(const char*str)//Sending String of Characters
{
char ps;
ps=*str;
while(ps>0)
{
str++;
if(ps==0)break;
while(!TRMT);
TXREG=ps;
ps=*str;
}
}

void main(void)
{
init();
initUSART();
while(1)
{
if(RB1=1)
{
RB2=1;
RB3=1;
send_msg("at+cmgf=1");
enter();
__delay_ms(50);
send_msg("at+cmgs=");
send_msg("+6583010050");
enter();
__delay_ms(50);
send_msg("hello");
tx_start();
__delay_ms(50);

RB2=0;
RB3=0;
}
else if(RB1=0)
{
RB2=0;
RB3=0;
}
}
}

USB.h:

unsigned char GetEP2 (unsigned char buffer[]);
unsigned char PutEP1 (unsigned char bytes, unsigned char buffer[]);
extern void StallUSBEP(char);
extern void UnstallUSBEP(char);
extern void CheckSleep();
extern void ServiceUSBInt();
extern void InitUSB();
extern void RemoteWakeup();

USB_defs.h:

#define TRUE 1
#define FALSE 0
#define NULL 0

#define NUM_CONFIGURATIONS 1
#define NUM_INTERFACES 1

#define ConfiguredUSB() while ((USWSTAT&0x3)!=CONFIG_STATE) {}
#define STALL_EP0 EP_STALL0 = 1
#define Send_0Len_pkt BD0IBC = 0; BD0IST = 0xc8; USB_dev_req = NULL

static volatile unsigned char bank3 USW_STAT @ 0x197;

#define POWERED_STATE 0x00
#define DEFAULT_STATE 0x01
#define ADDRESS_STATE 0x02
#define CONFIG_STATE 0x03

#define ENDPT_DISABLED 0x00
#define ENDPT_IN_ONLY 0x01
#define ENDPT_OUT_ONLY 0x02
#define ENDPT_CONTROL 0x06 /* enable for in, out and setup */
#define ENDPT_NON_CONTROL 0x0E /* enable for in, and out */

#define TOKEN_OUT (0x01<<2)
#define TOKEN_ACK (0x02<<2)
#define TOKEN_IN (0x09<<2)
#define TOKEN_SETUP (0x0D<<2)

#define CLEAR_FEATURE 0x01
#define GET_CONFIGURATION 0x08
#define GET_DESCRIPTOR 0x06
#define GET_INTERFACE 0x0A
#define GET_STATUS 0x00
#define SET_ADDRESS 0x05
#define SET_CONFIGURATION 0x09
#define SET_FEATURE 0x03
#define SET_INTERFACE 0x0B
#define HID_SET_REPORT 0x21
#define HID_GET_REPORT 0xA1
#define VEND_SET_MEMORY 0x80

#define HOSTTODEVICE 0x00
#define HOSTTOINTERFACE 0x01
#define HOSTTOENDPOINT 0x02
#define DEVICETOHOST 0x80
#define INTERFACETOHOST 0x81
#define ENDPOINTTOHOST 0x82

#define EP0OUT 0
#define EP0IN 1
#define EP1OUT 2
#define EP1IN 3
#define EP2OUT 4
#define EP2IN 5

// Descriptor Types
#define DEVICE 1
#define CONFIGURATION 2
#define STRING 3
#define INTERFACE 4
#define ENDPOINT 5
 
Code in the GUI:

Private Sub Command1_Click()
Dim Buffer() As Byte
Dim BufferSize As Long
ReDim Buffer(2)
Dim iChar As Integer
iChar = Asc("A")
Buffer(0) = CByte(0)
Buffer(1) = CByte(41)
BufferSize = 2
HIDComm1.WriteTo Buffer, BufferSize
End Sub

Private Sub Form_Load()
HIDComm1.Connect
End Sub

Private Sub Form_Unload(Cancel As Integer)
HIDComm1.Uninit
End Sub

Private Sub HIDComm1_ConnectSuccess(ByVal Status As Long)
Caption = "USB-Connected"
End Sub

Private Sub HIDComm1_Disconnected(ByVal Status As Long)
Caption = "USB-Disconnected"
End Sub
 

Maybe i can just connect one PC to another PC, and load my GUI in both PCs to test if it can detect the signal??
 
Maybe i can just connect one PC to another PC, and load my GUI in both PCs to test if it can detect the signal??
Good idea.
I would suggest taking the Telit module out and connecting your project to a PC serial port and see what's happening. Without a simulator, debugger or ICE you've got quite a battle ahead.
Are you sure your PIC code works?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…