We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
What do you mean by:
APTR1H = MSB(&UsbBuffer); APTR1L = LSB(*UsbBuffer);
For the high byte, you use the address-of operator For the low byte, you try to follow a pointer.
sorry it was aa mistake while typing, even after this the bulk transfer is not working!
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; } }
Are you sure you should do:
AUTOPTRH2 = MSB(0x28); AUTOPTRL2 = LSB(0x00);
Why try to use macros to split a 16-bit value into a high and low byte, if you don't supply the 16-bit value in. What do you think MSB(0x28) is?
MSB(0x2800) is expected to be 0x28. MSB(0x28) will just be 0.
And please: Never, ever type your source code. If we can't trust that the code you post is the code you run, then why should we bother looking at the code.
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