On Thu, Nov 06, 2014 at 12:41:20PM +0100, Tam=E1s Fekete wrote: > Hi everyone! > I am not sure if this problem is related to this topic. But I don't > know where else it would fit. > I am using a dspic33fj128mc802 with mplab xc16 compiler. I have to > read data from an ADC at about 1ms intervals. The data that I get is > a floating point number. I convert this number into a string using > the function sprintf. Send out the string. At the PC side I receive > and save the data with putty.exe. Then save the session in a .dat > file. I can use this .dat file with matlab to plot the results. >=20 > The problem is that sprintf really slows down the process. I should > be taking samples at about 1ms intervals and because of the sprintf > function this is between 5-7 mseconds. I checked this with an > oscilloscope and without the sprintf function I can get down to even > less than 1ms intervals easily. >=20 > If anybody could suggest a faster way to make a string out of a > floating point number or another way to send and receive the data I > would be very thankful. Yes, I've had sprintf take all the time it likes. What I would do is read the data from ADC registers and either transmit it as is, or encode it as hexadecimal. Then do the conversion on the PC side. But I don't know that chip, so I can't be specific. Also, I don't know the compiler or library you mention, so I don't know what other functions might be available. I would check for ecvt or some equivalent, and compare conversion time against sprintf. --=20 James Cameron http://quozl.linux.org.au/ --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .