In order to learn how to use the FT245R, I've built a simple circuit
that writes increasing values to the TX buffer using a 7-bit counter
whose 30 Hz clock is also hooked up to the WR# pin.
I wrote this program:
=============================================
int f;
struct ftdi_context ftdic;
assert(ftdi_init(&ftdic) >= 0);
assert(ftdi_usb_open(&ftdic, 0x0403, 0x6001) >= 0);
unsigned char buf[1];
while ((f = ftdi_read_data(&ftdic, buf, sizeof(buf))) >= 0) {
for (int i = 0; i < f; ++i) {
printf("Got byte: 0x%02x\n", buf[i]);
}
}
assert(ftdi_usb_close(&ftdic) >= 0);
ftdi_deinit(&ftdic);
return 0;
=============================================
It does indeed print increasing values, but it prints each byte
several thousand times in a row before going on to the next. Any idea
what I'm doing wrong?
Thanks,
Aaron
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|