View previous topic :: View next topic |
Author |
Message |
hemnath
Joined: 03 Oct 2012 Posts: 242 Location: chennai
|
questions about example program ex_usb_hid.c |
Posted: Sun May 25, 2014 11:21 pm |
|
|
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: 19554
|
|
Posted: Mon May 26, 2014 1:31 am |
|
|
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
|
|
Posted: Mon May 26, 2014 2:04 am |
|
|
Thanks Ttelmah for the explanation. |
|
|
hemnath
Joined: 03 Oct 2012 Posts: 242 Location: chennai
|
|
Posted: Mon May 26, 2014 2:08 am |
|
|
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
|
|
Posted: Wed May 28, 2014 6:56 am |
|
|
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
|
|
Posted: Fri May 30, 2014 5:32 am |
|
|
Thanks E_Blue..
What is Endpoint in USB?
Why there is maximum of 16 Endpoints.
Please clarify. |
|
|
|