Hi Frnds,
I am using Cypress CY7C68013A EZ-USB micro controller, I have used BULKLOOP example given by cypress, where they have given a loop back transaction between EP2 to EP6, But I have changed the code for transmission of 64bytes of data as bulk on EP1, below code which i have written for bulk write operation, when i run this code it is transferring 64bytes of data ,but as a JUNK data, what is the mistake in this code, if there is any mistake please through some light on it.
if(!(EP01STAT & bmEP1INBSY)) { //Source is Internal RAM Buffer memset(UsbBuffer,'\0',64); APTR1H = MSB(&UsbBuffer); APTR1L = LSB(*UsbBuffer); // Destination is External RAM at 0x2800 AUTOPTRH2 = MSB(0x28); AUTOPTRL2 = LSB(0x00); EP1INBC = 0x40; //64KB count = EP1INBC;// (EP2BCH << 8) + EP2BCL; SYNCDELAY; for( i = 0x0000; i < count; i++ ) { EXTAUTODAT2 = EXTAUTODAT1; } SYNCDELAY; // EP1INBC = 0x40; //64KB // Destination is External RAM at 0x2800 APTR1H = MSB(0x28); APTR1L = LSB(0x00); AUTOPTRH2 = MSB(&EP1INBUF); AUTOPTRL2 = LSB(&EP1INBUF); // EP1INBC = 0x40; //64KB count = EP1INBC;// (EP2BCH << 8) + EP2BCL; SYNCDELAY; for( i = 0x0000; i < count; i++ ) { EXTAUTODAT2 = EXTAUTODAT1; } SYNCDELAY; EP2BCL = 0x40; // re(arm) EP2OUT u8TransmitFlag =1; } }
Rajesh
Dear Per Westermark,
Thanks for u r valuable suggestions, I have changed code according to as u said, it is now working fine, But there is one more problem now,
I have used EP1 as IN transfer mode , i.e., EP1IN , but when i trasmit my buffet for first time i get JUNK, after I transmit for 2nd time onwards i get the what i am transmitting, I have checked many times, I get JUNK data first time and then the actual data, why it is happening . If there is any solution please tell.
if(!(EP01STAT & bmEP1INBSY)) // if(!(EP1INCS &0x02)) { // while(!(EP1INCS &0x02)); count=EP1INBC; for(i=0;i<count;i++) { EP1INBUF[j]=gb+i+Inc; gb++; j++; } SYNCDELAY; gb=0;j=0; Inc++; EP1INBC = 0x40; SYNCDELAY; // EP1INCS |=0x01; ACC=XBYTE[0x9800]; SYNCDELAY; ACC=XBYTE[0x8000]; SYNCDELAY; ACC=XBYTE[0xB800]; } Rajesh