• AVR Freaks

Helpful ReplyHot!DLL MCP2210 - SPI transfer function too slow

Author
Landroval
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/06/03 08:45:10
  • Location: 0
  • Status: offline
2019/06/07 02:01:52 (permalink)
0

DLL MCP2210 - SPI transfer function too slow

Hi,
I'm currently using "mcp22210_dll_um_x86.dll"  from the file "MCP2210 DLL (v2.1)" which is developped by Microchip.
When I measure the execution time of the "Mcp2210_xferSpiData" fonction  (SPI transfer function) I obtain 0,012s. Which is far too high for my application.
Do you know how to obtain the DLL code ? There must be a delay in it that slows its execution.
Do you know another DLL for MCP2210 that works on Windows ?

Thank you for your answers.
#1
Landroval
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/06/03 08:45:10
  • Location: 0
  • Status: offline
Re: DLL MCP2210 - SPI transfer function too slow 2019/06/21 08:00:09 (permalink)
0
Up
#2
NorthGuy
Super Member
  • Total Posts : 5543
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: online
Re: DLL MCP2210 - SPI transfer function too slow 2019/06/21 11:06:13 (permalink)
0
If I were you, I would try to transmit more data in a single transfer. I've never used MCP2210, but I worked a lot with my own USB devices. USB is sending data in packets, and you do not want the packets go out empty. Packing more data into a packet is key to high speed.
#3
Landroval
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/06/03 08:45:10
  • Location: 0
  • Status: offline
Re: DLL MCP2210 - SPI transfer function too slow 2019/06/24 02:08:20 (permalink)
0
Hi,
Thanks a lot for your answer.
 
NorthGuy
If I were you, I would try to transmit more data in a single transfer.



Your point is very relevant.
However when I try to communicate with the MCP2210 I use the command strucutre given in its datasheet ( http://ww1.microchip.com/downloads/en/devicedoc/22288a.pdf
You can find the command message to return an ADC value in the "TABLE 3-58" from the previous link.
I do not see how to command many measurements while this structure allows me only to send 60 bytes of data per transfer.
 
Thanks a lot for your help,
Cordially
 

 
#4
oliverb
Super Member
  • Total Posts : 204
  • Reward points : 0
  • Joined: 2009/02/16 13:12:38
  • Location: 0
  • Status: offline
Re: DLL MCP2210 - SPI transfer function too slow 2019/06/24 02:33:55 (permalink)
0
FWIW how are you measuring execution time for the DLL? If you are trying to time a single action then you may find that the result is rounded up to some minimum value.
#5
Landroval
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/06/03 08:45:10
  • Location: 0
  • Status: offline
Re: DLL MCP2210 - SPI transfer function too slow 2019/06/24 02:41:20 (permalink)
0
Hi,
I am doing a serie of 10 000 measurements. I get a global time of 40s.
I have a measurement every 4 ms. I am trying to reach 10 000 measurements per second.
Currently I am using the function "WriteFile" (from fileapi.h) for every measurement. But this function lasts 2ms. In addition I have to do this function twice to get the correct value.
I do not see how to increase this speed and/or how to make many measurements in one command.

Cordially
#6
Landroval
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/06/03 08:45:10
  • Location: 0
  • Status: offline
Re: DLL MCP2210 - SPI transfer function too slow 2019/06/27 07:37:44 (permalink)
0
FYI I set my Bit Rate to 1.000.000 and all delays to 0 (CS to first data / data to data / last data to CS). I am trying to read a value from an ADC (mcp3204) which is very fast.
#7
NorthGuy
Super Member
  • Total Posts : 5543
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: online
Re: DLL MCP2210 - SPI transfer function too slow 2019/06/27 08:20:16 (permalink)
0
Landroval
I do not see how to command many measurements while this structure allows me only to send 60 bytes of data per transfer.

 
Make sure you use all (or nearly all) of 60 bytes every transfer.
 
#8
NorthGuy
Super Member
  • Total Posts : 5543
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: online
Re: DLL MCP2210 - SPI transfer function too slow 2019/06/27 08:30:02 (permalink) ☄ Helpfulby Landroval 2019/07/02 06:06:31
3.5 (2)
You can also get a USB capable PIC (that is what MCP2210 is) and do your own programming. I did that with PIC16F1454 and I can get 500KB/sec speed on the SPI side. I used a USB HID class (because it doesn't need a driver), so the USB side is limited to 64KB/sec. But, if this is not enough, you can use USB CDC class, or even create a custom USB class and write your own PC driver.
#9
Landroval
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/06/03 08:45:10
  • Location: 0
  • Status: offline
Re: DLL MCP2210 - SPI transfer function too slow 2019/07/01 02:08:46 (permalink)
0
NorthGuy
you can use USB CDC class


Hi,
Thank you very much for this idea. I am not familiar with USB classes. Is it possible to control a HID USB peripheral with an USB CDC class ?
If I understand well with CDC class there is not this 64KB/sec limitation. But then I have to create my own driver right ? I assume that Microchip did not develop their own driver and that's why they make MCP2210 be recognized with a HID class.


#10
oliverb
Super Member
  • Total Posts : 204
  • Reward points : 0
  • Joined: 2009/02/16 13:12:38
  • Location: 0
  • Status: offline
Re: DLL MCP2210 - SPI transfer function too slow 2019/07/16 05:24:24 (permalink)
0
I believe that part of the problem is that in 64 bit versions of Windows it is extremely difficult to load uncertified device drivers. In 32 bit you could bypass the certification requirement and load the driver anyway. The HID "trick" is one way of accessing a USB peripheral from user mode, to avoid the need for a certified device driver.
 
Presumably in Linux that limitation does not apply, though I found that using a HID class the application needed to be owned by "root" to work. There's a fix for that, but at the time it was quicker to set the group to root.
 
As I understand it CDC is a class for a "legacy" serial port. It has limitations and USB-serial vendors seem to prefer to supply their own drivers.
 
#11
NorthGuy
Super Member
  • Total Posts : 5543
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: online
Re: DLL MCP2210 - SPI transfer function too slow 2019/07/16 05:51:29 (permalink)
0
oliverb
Presumably in Linux that limitation does not apply, though I found that using a HID class the application needed to be owned by "root" to work. There's a fix for that, but at the time it was quicker to set the group to root.



You just need to create a file with udev rules giving desired permissions and drop in into /etc/udev/rules.d
#12
ric
Super Member
  • Total Posts : 23200
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: DLL MCP2210 - SPI transfer function too slow 2019/07/17 13:26:52 (permalink)
0
oliverb
...
As I understand it CDC is a class for a "legacy" serial port. It has limitations and USB-serial vendors seem to prefer to supply their own drivers.

One reason for that is, the Microsoft CDC drivers (prior to Windows 10) had a few well known bugs which could stop a port working until it was unplugged and replugged.

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#13
Jump to:
© 2019 APG vNext Commercial Version 4.5