cancel
Showing results for 
Search instead for 
Did you mean: 

Making printf function

jkim71
Associate II
Posted on August 06, 2007 at 05:13

Making printf function

4 REPLIES 4
jkim71
Associate II
Posted on July 27, 2007 at 06:16

I am working with STR710 and 712

In other Samsung CPU there were printf function where %f or %d can be used. I have no idea if this was provided by Samsung or my colleague.

But as far as I have searched, I can't find this function in STR7 library.

I have tried to make printf using printf of samsung. I though this would be easy because this function only manipulate string and argument.

But this did not work. Board seems to be rebooted continuously.

I have no idea why this happens. This can be a problem of compile option or other. anyway I don't know.

Please help me solve this problem.

Thanks.

kleshov
Associate II
Posted on July 28, 2007 at 05:23

The function printf is part of the standard C library. All toolchains for ARM I know of ship with such library. There is no printf in ST's STR7 library, that is not the library's purpose. Instead, try looking in stdio.h.

So what is the problem exactly?

jkim71
Associate II
Posted on August 06, 2007 at 00:23

I mean printing debug message via serial.

Not simply print string, but also values of variables like printf in C library such as %x for hexa, %d for integer.

ben2
Associate II
Posted on August 06, 2007 at 05:13

depending on if you need the serial I/O to be interrupt driven or not, it is not to hard. I am using the serial port for debug. The easiest way is to write a printf wrapper function. Here is mine, it is not interrupt driven though. The fnr_printf_va() function is a simplified printf_va() without floating point, but with some extra formating. You should be able to replace it with the printf_va() function.

void DBG_printf(s32 level,s8* format, ...)

{

s8 buff[255];

va_list args;

s16 out;

s16 p;

if(level < dbg_level) {

va_start(args,format);

out = fnrprintf_va(buff,format,args);

va_end(args);

p=0;

UART1->IER = (BIT16_8 | BIT16_6);

while(out >0) {

while((UART1->SR & BIT16_9) != 0) {

asm volatile (''nop'');

}

while((UART1->SR & BIT16_9) == 0) {

UART1->TxBUFR = buff[p];

p++;

out--;

if(out==0) {

break;

}

}

}

}

}