uart_support

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

uart_support

2,172件の閲覧回数
MPotts
Contributor III

I am attempting to use uart_support with an M52259DEMOMCU board [CodeWarrior IDE 5.9.0]. I can receive data using uart_getchar() but when I send data using uart_putchar() it seems to always output a null byte. I call uart_init() once before doing any I/O.

 

However if I use printf() the data is output correctly. If I trace through printf() after some gyrations it eventually uses uart_putchar(). Maybe there is some initialization I am missing? Any suggestions would be be appreciated.

 

Thanks,

Mark

 

Following up: I traced printf() in more depth. It calls:

 

set_printf(TERMIO_PutChar); /* set up TERMIO_PutChar for writing */

----------------------------------------------------------

void set_printf(void (*f)(char)) {
  /* installs a handler function to write to the terminal */
  pbuf.outc = f;
  pbuf.s = NULL;
  pbuf.i = 0;
}

----------------------------------------------------------

static struct __print_buf {
  char * s;
  void (*outc)(char);
  unsigned int i;
}
pbuf;

 

It looks like I may need to call TERMIO_PutChar at some point, however I can't locate this function(?).

 

Message Edited by Mark Potts on 2009-06-01 06:51 PM
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 返信

991件の閲覧回数
MPotts
Contributor III

More tracing:

 

void TERMIO_PutChar( char ch)
{
    size_t cnt = 1;
    __write_console(1, (unsigned char *)&ch, &cnt, 0L);

}

--------------------------------------------------------------------

int __write_console(__file_handle handle, unsigned char * buffer, size_t * count, __ref_con ref_con)
{
#pragma unused(handle,ref_con)
...    __init_uart_console() ...
...    WriteUARTN( buffer, *count ) ...
}

--------------------------------------------------------------------

UARTError __init_uart_console(void)
{
    UARTError err = kUARTNoError;
    static int initialized = 0;
   
    if (initialized == 0)
    {
        err = InitializeUART( UART_CONSOLE_BAUD_RATE );
        if (err == kUARTNoError)
            initialized = 1;
    }
    return( err );
}

--------------------------------------------------------------------

UARTError InitializeUART(UARTBaudRate baudRate)
{
#if UART_SUPPORT_TYPE==UART_54451
    baudRate = kBaud115200;
#endif
    uart_init(TERMINAL_PORT, SYSTEM_CLOCK_KHZ, baudRate);
    return kUARTNoError;
}

--------------------------------------------------------------------

UARTError WriteUARTN(const void* bytes, unsigned long length)
{
    int count;
    for (count = 0; count < length; count++) {
        uart_putchar(TERMINAL_PORT, *( ((char *)bytes) + count));
    }
    return kUARTNoError;
}

--------------------------------------------------------------------

 

End result - printf() boils down to uart_init() and uart_putchar() - but these don't seem to work by themselves?

0 件の賞賛
返信