ADUC7024 UART no funciona

0

Actualmente estoy trabajando para obtener mi ADUC7024 ( ARM7) microprocesador para comunicarse conmigo a través de UART / RS232. Lo he intentado todo y estoy realmente desesperado, especialmente porque el software de ejemplo proporcionado es prácticamente 1: 1 lo que tengo como código (y no funciona: /):

El código se compila y ejecuta, los diodos se encienden correctamente (aunque no se apagan O.o) pero el puerto RS232 permanece vacío.

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 y "UART no funciona" significa que simplemente no hay comunicación visible (intenté escuchar a través de Putty y HyperTerminal)

    
pregunta Asmodiel

1 respuesta

3

Ok, lo resolví (una especie de error de novato): tuve que ajustar la configuración de la interfaz UART

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;
}
    
respondido por el Asmodiel

Lea otras preguntas en las etiquetas