write Register values to usb

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

write Register values to usb

642件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by AmirHejazi on Wed Feb 06 16:57:29 MST 2013
Hi every body

I suppose to send  timer register values to USB,using LPC1768 USBHostlite, to save in computer and use them for further Analysis.
consider that register value is "97" and changes every period.

I want to send this value, using File_Write. these are some line of the code:
_______________________________
USB_INT32U  temp;
.
.
temp=97;    //for example
*UserBuffer=temp;
.
.
FILE_Write(fdw,UserBuffer,1);
------------------------------
but the result is ascii codes for 97. so it writes an "a" to usb(not displays 97).
I found that i must convert the timer value to string using sprintf function.
and i found that the structure is as below:
___________________________________
char buf;
.
.
sprintf(buf,"%d",bytes_read);
-----------------------------------

but how should i use the "buf" as input for file_write ?
type of UserBuffer is uint8_t but type of buf is char

please help me
thanks
ラベル(1)
  • USB

0 件の賞賛
1 返信

626件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by vitah on Thu Mar 07 20:45:55 MST 2013
use type conversion. And buf will not be a single char. Instead, It should be a string.
char buf[512];

buf[0] = 0; // clear buf string
sprintf(buf,"%d",bytes_read);
// use strlen or 512 depend on your read process.
FILE_Write(fdw,(USB_INT08U*)buf,strlen(buf));
0 件の賞賛