Information about the sdcc port 1. Make sure you have something newer than sdcc 2.7.2 (I used 2.7.3). do "sdcc --version" to check. 2. The sdcc compiler is rather touchy so make small changes and then test. 3. Using lots of printf's when DEBUG is defined can cause stack problems so use them sparingly. fprintf uses lots of stack so I had to tweak sd18f2550.lkr to allow the stack to grow down to 0x1f0 from 0x2ff by not allowing 0x1f0 to 0x1ff to be used: DATABANK NAME=gpr1 START=0x100 END=0x1F0 4. Stay away from (void *) pointers, they will end up causing things like: ; .line 368; system/usb/usbctrltrf/usbctrltrf.c pSrc = (void *)&bdt_data.CtrlTrfData; 0038f6 0e28 movlw 0x28 MOVLW 0x28 0038f8 0000 nop BANKSEL LOW(_bdt_data) 0038fa 2500 addwf 0, 0, 0x1 ADDWF LOW(_bdt_data), W, B 0038fc 0101 movlb 0x1 BANKSEL _pSrc 0038fe 6ff8 movwf 0xf8, 0x1 MOVWF _pSrc, B 003900 0e00 movlw 0 MOVLW 0x00 003902 0004 clrwdt BANKSEL HIGH(_bdt_data) see the clrwdt instruction? That's a "clear watchdog timer" instruction, clearly not right. 5. The original Microchip code had a POINTER struct that caused sdcc to go crazy, like this: .line 75; main.c *pDst.bRam = *pSrc.bRom; 000f48 c093 movff 0x93, 0x2 MOVFF _pDst, r0x02 000f4a f002 000f4c c094 movff 0x94, 0x3 MOVFF (_pDst + 1), r0x03 000f4e f003 000f50 c095 movff 0x95, 0x4 MOVFF (_pDst + 2), r0x04 000f52 f004 000f54 0e90 movlw 0x90 MOVLW _pSrc 000f56 6ef6 movwf 0xf6, 0 MOVWF TBLPTRL 000f58 0e91 movlw 0x91 MOVLW (_pSrc + 1) 000f5a 6ef7 movwf 0xf7, 0 MOVWF TBLPTRH 000f5c 0e92 movlw 0x92 MOVLW (_pSrc + 2) 000f5e 6ef8 movwf 0xf8, 0 MOVWF TBLPTRU Here it's loading up TBLPTR with the address 0x929190, not quite right! 6. Using "data" as a passed parameter is a problem, not sure why. It's been changed to "d". 7. The sdcc compiler needs to have the pragmas with at least one use. In other words you cant do: ---------------------------------- file A: #pragma udata usbram5 cdc_notice (no usage of cdc_notice) file B: cdc_notice = 0; ---------------------------------- You have to move the pragma to file B: ---------------------------------- file A: (no usage of cdc_notice) file B: #pragma udata usbram5 cdc_notice cdc_notice = 0; ----------------------------------