CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Suggestion needed about USB project

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
abo_shreek11



Joined: 27 Sep 2008
Posts: 10

View user's profile Send private message Send e-mail

Suggestion needed about USB project
PostPosted: Sun Nov 16, 2008 2:32 am     Reply with quote

Hi
I have a simple project in which I type on a keyboard (USB one) and display the writing on 2X16 lcd. And for this, I chose the PIC18F4550 which has a usb module. I've read most of the examples which come with the CCS complier and most of them are about interfacing a device (keyboard, mouse, etc) to a PC through the PIC. I was wondering if the USB module can be used for my project in which no PC (which have the USB drivers) is used. And if so, a C example which reads a string from USB keyboard will be useful.

Crying or Very sad

Thank You.
Ttelmah
Guest







PostPosted: Sun Nov 16, 2008 3:31 am     Reply with quote

No.
USB, is a 'master/slave' interface. Every bus, has one USB master device. The PIC, implements a USB _slave_ only.
A USB 'master', is complex. Code, several hundred times bigger, even for a very simple operation...
For your simple operation, several possiilities exit.
First, the keyboard, _may_ implement PS/2 as well as USB (most do). This is triggered, by holding one line of the connection to a level, when it is first switched on. The USB-PS/2 adapter units sold for keyboards do this. PS/2 master code, is readily available for the PIC.
Second, for a specific device, it _may_ be possible to implement a really crude subset of the USB communications, to talk to it. However think 'lot of work'.
Third, there are chips available with limited 'master' abilities. These are designed for the USB 'otg' specs, where things like cameras, can talk directly to printers. The commonest one, is the FTDI 'Vinculum', and a prototype version of this is available, that can talk to a PIC via RS232, or SPI, and implements a master that will talk to keyboards, and things like USB storage devices.

Best Wishes
abo_shreek11



Joined: 27 Sep 2008
Posts: 10

View user's profile Send private message Send e-mail

Very Clear
PostPosted: Sun Nov 16, 2008 4:40 am     Reply with quote

Hi Ttelmah

Thanks for your rapid reply. What I got from you is that the USB module in the PIC is for slave_use_only in which a PC is needed. But I can use a USB-PS/2 adapter in which the keyboard can be USB and the adapter connect with the PIC through PS/2, isn't it ?

By the way, your answer is clear and I'll go for PS/2 keyboard.

Thank You.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Nov 16, 2008 7:15 am     Reply with quote

I almost agree, except for the second part of this statement.
Quote:
A USB 'master', is complex. Code, several hundred times bigger, even for a very simple operation...

An USB host is more complex than a typical device, but a simplified host, connecting to a single device from a limited range of known types, specified as USB OTG (on-the-go) host respectively dual-role device isn't that complex. It needs some additional hardware to drive VBUS and generate the framing signals. From Microchip, PIC24FxxxGB devices have USB OTG functionality.

Anyway, it makes no sense, to connect a keyboard through USB when you can use PS/2 instead.
Ttelmah
Guest







PostPosted: Sun Nov 16, 2008 8:52 am     Reply with quote

Couple of comments.
No, the keyboard _won't_ be USB. The point is that most keyboards can switch between running in PS/2 mode, and USB mode. The adapters trigger this change. Most (except for a few really expensive ones), have nothing more in them, than a couple of connections, and you can implement these without the adapters. With the adapter attached, or the same connections made by you, the keyboard runs as a PS/2 device.
To Fvm, I make this point in my 'second' comment. Yes, limited USB operations to a single device, are not too bad, but like you, I think it'd be much easier to talk to the PS/2 interface instead.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group