ADUC7024 UART not working

armcembeddedrs232uart

I am currently working on getting my ADUC7024 (ARM7) microprocessor to communicate with me via UART/RS232. I have tried everything and I'm getting really desperate especially since the provided example software is practically 1:1 what I have as code (and it's not working :/) :

The code compiles and runs, the diodes are properly lighting up (though not turning off O.o) but the RS232 port remains empty.

int putchar(int ch)  {                   /* Write character to Serial Port  */

    if (ch == '\n')  {
        while(!(0x020==(COMSTA0 & 0x020)))
        {}
        COMTX = CR;                         /* output CR */
        }
    while(!(0x020==(COMSTA0 & 0x020)))
    {}

    return (COMTX = ch);
}

int getchar (void)  {                      /* Read character from Serial Port */

    while(!(0x01==(COMSTA0 & 0x01)))
    {}
    return (COMRX);
}

int write (int file, char * ptr, int len) {
  int i;

  for (i = 0; i < len; i++) putchar (*ptr++);
  return len;
}

int main() {
    char output1[13] = "Hello World\n";

    // Setup tx & rx pins on P1.0 and P1.1\
    GP1CON |= 0x011;

    // Start setting up UART at 9600bps
    COMCON0 = 0x080;                // Setting DLAB
    COMDIV0 = 0x00b;                // Setting DIV0 and DIV1 to DL calculated 115200
    COMDIV1 = 0x000;
    COMCON0 = 0x007;                // Clearing DLAB

    GP4CON = GP4CONVAL;
    GP4DAT = 0xFF000000;            // P4.2 configured as an output. LED is turned on

    while(1)
    {

        greenLight(1);
        write(0,output1,13);
        delay(2000);
        redLight(1);
    }
}
volatile void redLight(bool state) {
    if (state) {
        GP4SET = 1<<21;
    } else {
        GP4CLR = 1<<21;
    }
}

volatile void greenLight(bool state) {
    if (state) {
        GP4SET = 1<<22;
    } else {
        GP4CLR = 1<<22;
    }
}

void delay (int length)
{
    while (length >=0)
        length--;
}

Oh and "UART doesn't work" means that there is just no visible communication (I tried listening via Putty and HyperTerminal)

Best Answer

Ok, I solved it (kind of a rookie mistake) - I had to adjust the configuration of the UART interface

void ConfigUART9600(void)
{
//int udiv0;
GP1CON = 0x11;

COMCON0 = 0x80;                 // set 7th bit to enable access to COMDIV0 and COMDIV1
COMDIV0 = 0x88;                 // 9600 baud rate
COMDIV1 = 0x0;                  // 
COMCON0 = 0x03F;                // clear 7th bit to switch access to COMTX and COMRX; 8 bits, even parity, two stop bits
COMDIV2 = 0x0;
}