[an error occurred while processing this directive] [an error occurred while processing this directive]
Ответ: One solution.
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)
[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]

Отправлено Yuriy 28 августа 2001 г. 19:40
В ответ на: Мысли по поводу IAR C V1.40 for AVR и просьба отправлено Igor Lapshin 28 августа 2001 г. 19:09

Never try to use printf. It consumes too many memory.

/*-------------------------------------------------------*/
void put_hex1 (char c)
{
c &= 0x0F;
if (c < 10) put_char(c + '0');
else put_char(c + 'A' - 10);
}
/*-------------------------------------------------------*/
void put_hex2 (U8 c)
{
put_hex1 ((c>>4) & 0x0F);
put_hex1 ( c & 0x0F);
}
/*-------------------------------------------------------*/
void put_hex4 (U16 w)
{
put_hex2((w >> 8) & 0xFF);
put_hex2( w & 0xFF);
}
/*-------------------------------------------------------*/
void put_hex8 (U32 dw)
{
put_hex2((dw >> 24) & 0xFF);
put_hex2((dw >> 16) & 0xFF);
put_hex2((dw >> 8) & 0xFF);
put_hex2( dw & 0xFF);
}
/* -----------------09.04.00 10:59-------------------
print dw as a decimal digit,
qty of digit - as a second parameter
--------------------------------------------------*/
void put_dec_n (U32 dw, U8 n)
{
char ct[10], i;
for(i = 0; i < n; i++)
{
ct[i] = dw % 10;
dw /= 10;
}
i = n - 1;
do
{
put_hex1(ct[i]);
} while (i-- != 0);
}
/*-------------------------------------------------------*/
void put_bin8 (U8 c)
{
U8 i = 8;

do
{
if (tst_bit(c,7)) put_char('1');
else put_char('0');
c <<= 1;
} while (--i);
}
/*-------------------------------------------------------*/
void put_CRLF (void)
{
put_char(0x0D);
put_char(0x0A);
}
/*-------------------------------------------------------*/
void put_string_P (const char flash *s)
{
while (*s)
put_char(*s++);
}

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru