atc1441 / CH559sdccUSBHost

USB host to Arduino Interface with the Cheap CH559 uC
GNU General Public License v3.0
231 stars 54 forks source link

Ram corruption #15

Open fabiodl opened 3 years ago

fabiodl commented 3 years ago

Here is the result of 3 days of head scratching (huge thanks for this project, btw!) ;)

USBHost.c has

__at(0x0000) unsigned char __xdata RxBuffer[MAX_PACKET_SIZE];
__at(0x0100) unsigned char __xdata TxBuffer[MAX_PACKET_SIZE];

but the SDCC manual (page 42) reports The compilerdoesnotreserve any space for variables declared in this way (they are implemented with an equate in the assembler). and indeed I had memory corruption.

__at(0x0000) unsigned char __xdata RxBuffer[MAX_PACKET_SIZE]={0};
__at(0x0100) unsigned char __xdata TxBuffer[MAX_PACKET_SIZE]={0};

fixes it

atc1441 commented 3 years ago

Thank you :)