[Fx2lib-devel] Some bugs
Status: Beta
Brought to you by:
mulicheng
From: Maarten B. <sou...@ds...> - 2009-07-24 14:53:46
|
Hi, I just looked through the fx2lib code and found some issues. 1. The generated documentation for fx2regs.h has put many descriptions next to the wrong (next) registers. 2. usbjt.a51 has several areas defined without specifying the memory type. I advise to change them to (CODE, ABS, CON) so they will not end up in xdata by accident and the linker can check for overlaps. 3. The value in loop_count in delay.c seems wrong. And if you don't like volatile in delay.c then I suggest the use of NOP's and also use only 8 bit counters. This way the chosen model has little influence. E.g. void delay(WORD millis) { register BYTE count_inner, count_outer; do { count_outer = 3; do { count_inner = 250; do { #if (CPUFREQ == CLK_12M) NOP(); // 1 cycle #elif (CPUFREQ == CLK_24M) NOP(); // 5 cycles NOP(); NOP(); NOP(); NOP(); #else NOP(); // 13 cycles NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); #endif } while (--count_inner); //should result in DJNZ Rn : 3 cycles } while (--count_outer); //should result in DJNZ Rn } while (--millis); } Or if you want even more precise timing either fully write the function in asm or use a timer. 4. The functions in eputils.c could be sped up if you use the autoptr's. And even more if you unroll the inner loop for the special case of 64 bytes. Greets, Maarten |