UART examples for ADuc7026

Hi there
I have problem with keil (even with AD code) example of UART

//******************************************
unsigned char memory_pool[0x400];
int main (void) { int iIterator; int iUserVar1 = 0; int *iArray;

GP1CON = 0x011; // Setup tx & rx pins on P1.0 and P1.1 // Start setting up UART at 9600bps COMCON0 = 0x80; // Setting DLAB COMDIV0 = 0x93; COMDIV1 = 0x00; COMCON0 = 0x07; // Clearing DLAB

// initialize memory pool init_mempool (memory_pool, sizeof(memory_pool));

// create an array big enough to hold 10 integers iArray = malloc (10*sizeof(int));

if(iArray == NULL) { printf("Malloc failed!\n"); } else { for(iIterator = 0; iIterator<10; iIterator++) { iArray[iIterator] = iIterator*2; } }

// demonstrate user input via scanf
// an alternative to scanf is gets and sscanf printf("please enter a number: "); scanf("%i", &iUserVar1); printf("\nUser Input: %i\n", iUserVar1);

while (1);
}

//******************************************
When I configure My Hyper terminal (as it should be
9600/2stop/no parity )
he displays that:
I can't open my COM port !?!?
When I change setting, example: 4800/2stop/no parity
there's no bad information, and something is transmiting to my PC- I see a "ee..##.e# ....etc.)

What is the problem?
regards and happy NEW YEAR

Parents
  • You have a big problem with this forum too. Did you read the instructions about how to post source code? Your posted code is not readable!

    The hyperterminal doesn't know about what you do in your program, so it should not be possible for it to accept 4800 baud but fail to open the serial port for 9600 baud. Did you have any other program using the same port and then stopped that second program?

    If the program configures 9600 baud and you on the PC connects using 4800 baud, it is reasonable that you get broken characters.

    1) Set hyperterminal to the correct baudrate.

    2) Verify the baudrate of the connection with an oscilloscope.

    3) If the problem persists: Repost your code, but this time according to the posting instructions!

Reply
  • You have a big problem with this forum too. Did you read the instructions about how to post source code? Your posted code is not readable!

    The hyperterminal doesn't know about what you do in your program, so it should not be possible for it to accept 4800 baud but fail to open the serial port for 9600 baud. Did you have any other program using the same port and then stopped that second program?

    If the program configures 9600 baud and you on the PC connects using 4800 baud, it is reasonable that you get broken characters.

    1) Set hyperterminal to the correct baudrate.

    2) Verify the baudrate of the connection with an oscilloscope.

    3) If the problem persists: Repost your code, but this time according to the posting instructions!

Children
More questions in this forum