Vincent Gagliardo

Setting up UART

Discussion created by Vincent Gagliardo on Jul 17, 2013
Latest reply on Jul 24, 2013 by TomE

Device: MCF52258

Complier: CW 10.2

RTOS: none/bare metal

 

Note: Hardware design is similar to M52259DEMO

 

After reading a couple of examples on this board, I setup a bareboard project with UART support in codewarrior.

Verified divider for baud rate is setup correctly.

 

However I do not see any output on hyperterminal. Please

help.  Can anyone provide examples for this device?

 

See code snippet from the main function below:

 

/*

* main implementation: use this sample to create your own

application

*

*/

 

 

#include "support_common.h" /* include peripheral

declarations and more */

#if (CONSOLE_IO_SUPPORT || ENABLE_UART_SUPPORT)

/* Standard IO is only possible if Console or UART support is

enabled. */

#include
#include "uart_support.h"
#endif

 


class counterclass
{
private:
    int m_counter;
public:
    counterclass(void)
    {
        m_counter = 0;
    };
    void increment(void)
    {
        m_counter++;
    };     
};

 

int main(void)
{
    counterclass myccounter;
//    UARTError error;
    volatile char c;
    unsigned char status;
    
//    MCF_GPIO_PORTUC;
    MCF_GPIO_PUCPAR &= 0xf0;
    MCF_GPIO_DDRUC = 0x01;
//    uart_init(int channel, unsigned long systemClockKHz,
unsigned long baudRate)
//    uart_init(3, unsigned long systemClockKHz, 19200);
    
    
//    UARTError InitializeUART(UARTBaudRate baudRate)
//    error = InitializeUART(kBaud19200);
    
    uart_init(TERMINAL_PORT, SYSTEM_CLOCK_KHZ,
TERMINAL_BAUD);
    uart_init(1, SYSTEM_CLOCK_KHZ, TERMINAL_BAUD);
    uart_init(2, SYSTEM_CLOCK_KHZ, TERMINAL_BAUD);
    
#if (CONSOLE_IO_SUPPORT || ENABLE_UART_SUPPORT)
//    printf("Hello World in C++ from MCF52258 derivative on
MCF52258 board\n\r");
//    printf("\n\rM52223EVB board\n\r");
#endif
    for(;;) {    
        myccounter.increment();
//        c = uart_getchar (TERMINAL_PORT); // Read a
character.
//        uart_putchar (TERMINAL_PORT, c); // echo it.
        
//        c = uart_getchar (2); // Read a character.
//        uart_putchar (2, c); // echo it.
        
        uart_putchar (0, 'a');
        uart_putchar (1, 'b');
        uart_putchar (2, 'c');
        
    }
}

 

Outcomes