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 CCS Technical Support

questions about example program ex_usb_hid.c

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



Joined: 03 Oct 2012
Posts: 242
Location: chennai

View user's profile Send private message

questions about example program ex_usb_hid.c
PostPosted: Sun May 25, 2014 11:21 pm     Reply with quote

Hi,
I've been studying the USB and gone through the example code ex_usb_hid.c.

I have a question,
ADC on PIN AN0: Whether the ADC value will not exceed 255? If i want to send 1023, will it not send?

Thanks in advance.
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Mon May 26, 2014 1:31 am     Reply with quote

The example, configures the ADC for low accuracy only.
#device ADC=8

and

ADC_CLOCK_INTERNAL

This gives an 8bit low accuracy value.

No, you could not send 1023, The example PC code expects to only receive single bytes for simplicity/speed.

To send a larger value, the code at the PC end would need to be re-written to expect two bytes for each value, and the transmission code would have to switch the ADC to a more accurate mode, and send this as two bytes.

'HID' code is originally designed for things like joysticks (human interface devices), with the assumptions this brings.
hemnath



Joined: 03 Oct 2012
Posts: 242
Location: chennai

View user's profile Send private message

PostPosted: Mon May 26, 2014 2:04 am     Reply with quote

Thanks Ttelmah for the explanation.
hemnath



Joined: 03 Oct 2012
Posts: 242
Location: chennai

View user's profile Send private message

PostPosted: Mon May 26, 2014 2:08 am     Reply with quote

I'm asking in general, not considering this example.

This example sends 8 bit(1 byte) data in a single pipe. I'm clear about that.

Is it possible to send a 16 bit value through the single pipe?

Example:
out_data[0]=250; // It can be sent.

Will it be?
out_data[0]=1000;

Will USB allows 16 bit value?
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Wed May 28, 2014 6:56 am     Reply with quote

No, USB sends only single bytes, that means 0 to 255 decimal values.
To send 16bit value you must two break the value in to two bytes and then put one byte on [0] and the other byte in [1]

Something like

Code:

out_data[0]=make8(1000,0);
out_data[1]=make8(1000,1);


Of course on PC side you will need to put them together again in correct order by software.
_________________
Electric Blue
hemnath



Joined: 03 Oct 2012
Posts: 242
Location: chennai

View user's profile Send private message

PostPosted: Fri May 30, 2014 5:32 am     Reply with quote

Thanks E_Blue..

What is Endpoint in USB?

Why there is maximum of 16 Endpoints.
Please clarify.
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