Question about DMA and usbcore on E51 cpus

Quote from the ch554 English datasheed:

Note: the length of the buffer that receives data >= min (maximum data packet length possibly received + 2 bytes, 64 bytes)

I am still not shure if I understand that correctly.


An example:

#define EP0_SIZE 0x08

uint8_t xdata EP0Buffer[EP0_SIZE +2]? _at_ 0x0000;//8 byte buffer for EP0 to save memory

//gap may be used by the linker

uint8_t xdata EP2Buffer[2*BULK_SIZE] _at_ 0x0080;


EP0 shares the buffer beetween IN & OUT. Should i reserve 2 more Bytes for that buffer?

For EP1..3 it can happen that 2 bytes of EPxInBuffer will be destroyed. But that does not seem a problem. EP4 i never used up to now.


Is it save to use #define EP0_SIZE 0x08 to use just a 10 byte Buffer for DMA0 or should i alway declare 0x40 even when I plan just to use 8Bytes for the control transfers?


That was the first question I asked here.

https://www.wch.cn/bbs/thread-67984-1.html


So you can just reserve 10 bytes for ep0 until you get screwed by the USB host send more data that it should.


In theory it is a problem, but in practice, ch55xduino set ep1_addr at 10 (in board.txt) at the first version and nobody complains so far.


thanks dq_user for your response.


Maybe i will use something like that:

uint8_t xdata EP2Buffer[2*BULK_SIZE] _at_ 0x0000;

uint8_t xdata EP3Buffer[2*BULK_SIZE] _at_ 0x0080;

uint8_t xdata EP0Buffer[BULK_SIZE+2] _at_ 0x0100;

when using EP0Size = 0x08 EP0Buffer[10..63] can be savely used for some temp buffers.

by memset(&EP0Buffer[10], 0xAA, BULK_SIZE-10); Test the range  for something different all 60 sec 

in some debug build should give an idea if overflows can happen.



只有登录才能回复,可以选择微信账号登录