This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:discussions:problem_with_a_in-out_communication [2013/11/21 10:27] – [C CODE:] 62.81.195.254 | en:discussions:problem_with_a_in-out_communication [2017/02/04 19:23] (current) – gelöscht stefan | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | <- [[: | ||
| - | ====== Problem with a IN-OUT Communication ====== | ||
| - | |||
| - | //, 2013/11/21 11:11 // | ||
| - | |||
| - | |||
| - | |||
| - | ~~DISCUSSION~~ | ||
| - | ======C CODE:====== | ||
| - | < | ||
| - | # | ||
| - | # | ||
| - | |||
| - | // configure endpoint 2, in, quad buffered, 512 bytes, interface 0 | ||
| - | EP_CONFIG(2, | ||
| - | |||
| - | // configure endpoint 6, out, doublebuffered, | ||
| - | EP_CONFIG(6, | ||
| - | |||
| - | // select ZTEX USB FPGA Module 1.15 as target | ||
| - | IDENTITY_UFM_1_15(10.13.0.0, | ||
| - | |||
| - | // this product string is also used for identification by the host software | ||
| - | # | ||
| - | |||
| - | // enables high speed FPGA configuration via EP6 | ||
| - | ENABLE_HS_FPGA_CONF(6); | ||
| - | |||
| - | // this is called automatically after FPGA configuration | ||
| - | # | ||
| - | IOA7 = 1; // reset on | ||
| - | IOA0 = 1; // reset on | ||
| - | IOA3 = 0; | ||
| - | OEA |= bmBIT0 | bmBIT3; | ||
| - | IOC0 = 0; // controlled mode | ||
| - | OEC = 1; | ||
| - | // | ||
| - | CPUCS = 0x12; | ||
| - | IFCONFIG = bmBIT7 | bmBIT5 | 3; // internel 30MHz clock, drive IFCLK ouput, slave FIFO interface | ||
| - | // | ||
| - | SYNCDELAY; | ||
| - | FIFOPINPOLAR = 0; | ||
| - | SYNCDELAY; | ||
| - | PINFLAGSAB = 0x80; | ||
| - | SYNCDELAY; | ||
| - | PINFLAGSCD = 0x0E; | ||
| - | SYNCDELAY; | ||
| - | |||
| - | // | ||
| - | //PORTACFG = 0x00; | ||
| - | |||
| - | // | ||
| - | EP2CFG = 0xA0; | ||
| - | SYNCDELAY; | ||
| - | EP6CFG = 0xE0; | ||
| - | SYNCDELAY; | ||
| - | |||
| - | // | ||
| - | FIFORESET = 0x80; // reset all FIFOs | ||
| - | SYNCDELAY; | ||
| - | FIFORESET = 0x82; | ||
| - | SYNCDELAY; | ||
| - | FIFORESET = 0x84; | ||
| - | SYNCDELAY; | ||
| - | FIFORESET = 0x86; | ||
| - | SYNCDELAY; | ||
| - | FIFORESET = 0x88; | ||
| - | SYNCDELAY; | ||
| - | FIFORESET = 0x00; | ||
| - | SYNCDELAY; | ||
| - | |||
| - | //Arm out buffers | ||
| - | OUTPKTEND = 0x82; | ||
| - | SYNCDELAY; | ||
| - | // | ||
| - | EP2FIFOCFG = 0x10; | ||
| - | SYNCDELAY; | ||
| - | EP6FIFOCFG = 0x4C;//0x0c | ||
| - | SYNCDELAY; | ||
| - | EP6AUTOINLENH = 0x02; | ||
| - | SYNCDELAY; | ||
| - | EP6AUTOINLENL = 0x00; | ||
| - | SYNCDELAY; | ||
| - | ] | ||
| - | |||
| - | // set mode | ||
| - | ADD_EP0_VENDOR_COMMAND((0x60,, | ||
| - | IOA7 = 1; // reset on | ||
| - | IOC0 = SETUPDAT[2] ? 1 : 0; | ||
| - | IOA7 = 0; // reset off | ||
| - | ,, | ||
| - | NOP; | ||
| - | ));; | ||
| - | |||
| - | ADD_EP0_VENDOR_REQUEST((0x70,, | ||
| - | EP0BUF[0] = IOC; | ||
| - | EP0BCH = 0; | ||
| - | EP0BCL = 1; | ||
| - | ,, | ||
| - | // include the main part of the firmware kit, define the descriptors, | ||
| - | # | ||
| - | |||
| - | void main(void) | ||
| - | { | ||
| - | init_USB(); | ||
| - | |||
| - | while (1) { | ||
| - | } | ||
| - | } | ||
| - | |||
| - | </ | ||
| - | ~~JAVA FUNCTION~~ | ||
| - | |||
| - | < | ||
| - | |||
| - | System.out.println( LibusbJava.usb_bulk_write(ztex.handle(), | ||
| - | bufBytes[i] = LibusbJava.usb_bulk_read(ztex.handle(), | ||
| - | </ | ||
| - | |||
| - | |||
| - | |||
| - | It doesn´t work. Anyone know why this code doesn´t work. I have tried to add the configuration of AUTOIN and AUTOOUT. I have been several days with the manuals but I cannot find the problem. | ||
| - | |||
| - | I want to send 512 bytes, then I process the bytes and finally I want to receive the 512 bytes. I want to use EP2 and EP6. | ||
| - | buf1 is an array of 512 bytes and buf[i] is an arry of 512 bytes too. | ||
| - | |||
| - | Thank you very much. | ||
| - | |||
| - | Best Regards | ||