[En-Nut-Discussion] ICC AVR 7.13A Compiler Bug
Jean Pierre GAUTHIER
jp.gauthier at wanadoo.fr
Fri Aug 31 16:56:34 CEST 2007
Hello,
With the ATMEGA2561, nut/dev/usart.c seems to be bad compiled with ICCAVR
(version 7.13A). (tested with NUTOS 4.2.1 and 4.3.99)
At the end of the UsartRead(NUTFILE * fp, void *buffer, int size) function,
for exemple, when 1 char must be read (size=1), rbf->rbf_cnt is decremented
by 128 instead 1!
To avoid this, insert dummy instruction(s) as below.
Of course other instructions, upon your imagination, should be inserted ;-)
Best regards,
Jean Pierre
End of Nut/dev/usart.c/UsartRead()function :
/*
* Get raw characters from receive buffer.
*/
else {
if ((rc = size) > avail)
rc = avail;
for (taken = 0; taken < rc; taken++) {
*cp++ = *rbf->rbf_tail++;
if (rbf->rbf_tail == rbf->rbf_last) {
rbf->rbf_tail = rbf->rbf_start;
}
}
}
if (taken) {
taken++; // <----------- insert dummy instruction
taken--; // <----------- insert dummy instruction
NutEnterCritical();
rbf->rbf_cnt -= taken ; // a compiler bug was here!!!
NutExitCritical();
if (rbf->rbf_cnt < rbf->rbf_lwm) {
(*dcb->dcb_rx_start) ();
}
}
return (int) rc;
}
More information about the En-Nut-Discussion
mailing list