<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>UART examples for ADuc7026</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/21655/uart-examples-for-aduc7026</link><description> 
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</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: UART examples for ADuc7026</title><link>https://community.arm.com/thread/113528?ContentTypeID=1</link><pubDate>Sun, 30 Dec 2007 17:43:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d143053f-bacf-4a7b-87be-a0db26cad8e2</guid><dc:creator>tomasz wilko</dc:creator><description>&lt;p&gt;&lt;p&gt;
Ok, I&amp;#39;ll make that&lt;br /&gt;
But I solved the problem:) , I set the CD PLL multiplier&lt;br /&gt;
in Startup.s on 1 (001) -this is 28MHz clock , but it should be CD: 0
(000) - and this is 41MHz&lt;br /&gt;
my recommended frequency.&lt;br /&gt;
&lt;b&gt;Thanks for every think&lt;/b&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART examples for ADuc7026</title><link>https://community.arm.com/thread/100086?ContentTypeID=1</link><pubDate>Sun, 30 Dec 2007 16:42:35 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9adbaf64-d0fd-4214-87e8-4e90c21264f6</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Drop Hyperterminal and get a better program. Have you tried
TeraTerm?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART examples for ADuc7026</title><link>https://community.arm.com/thread/75854?ContentTypeID=1</link><pubDate>Sun, 30 Dec 2007 02:27:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1464569c-6f32-404f-8695-e4a215f707b8</guid><dc:creator>tomasz wilko</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi there&lt;br /&gt;
Sorry for code:/ It&amp;#39;s my first time in here.&lt;/p&gt;

&lt;p&gt;
so, code from KEIL is:&lt;/p&gt;

&lt;pre&gt;
/*
 *  IODEMO.C:  Demonstrates usage of printf, scanf and malloc with
 *             GNU Compiler (on ADuC7024)
 *  Copyright KEIL ELEKTRONIK GmbH and KEIL SOFTWARE, Inc. 2003 - 2004
 *
 *  This file may be compiled in ARM or Thumb Mode
 */


#include &amp;lt;ADuC7024.H&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

unsigned char memory_pool[0x400];

int main (void) {
        int iIterator;
        int iUserVar1 = 0;
        int *iArray;

        GP1CON = 0x011;                                                 // Setup tx &amp;amp; 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(&amp;quot;Malloc failed!\n&amp;quot;);
        }
        else {
          for(iIterator = 0; iIterator&amp;lt;10; iIterator++) {
                iArray[iIterator] = iIterator*2;
          }
        }

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

    while (1);
}




/***********************************************************************/
/*                                                                     */
/*  SERIAL.C:  Low Level Serial Routines                               */
/*                                                                     */
/***********************************************************************/

#include &amp;lt;ADuC7024.H&amp;gt;                      /* ADuC7024 definitions          */

#define CR     0x0D
//int putchar(int ch)  __attribute__ ((used));
//int getchar (void)  __attribute__ ((used));

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

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

        return (COMTX = ch);
}


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

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




/***********************************************************************/
/*                                                                     */
/*  SYSCALLS.C:  System Calls Remapping                                */
/*                                                                     */
/***********************************************************************/

#include &amp;lt;stdlib.h&amp;gt;


extern int putchar (int ch);
extern int getchar (void);

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

  for (i = 0; i &amp;lt; len; i++) {
    c = getchar();
    if (c == 0x0D) break;
    *ptr++ = c;
    putchar(c);
  }
  return len - i;
}

/*      Write a buffer using putchar function in serial.c       */

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

  for (i = 0; i &amp;lt; len; i++) putchar (*ptr++);
  return len;
}

int isatty (int fd) {
  return 1;
}


void _exit (int n) {
label:  goto label; /* endless loop */
}


#define HEAP_START 0x10000000
#define HEAP_LIMIT 0x10010000

caddr_t sbrk (int incr) {
//extern char   end asm (&amp;quot;end&amp;quot;);      /* Defined by the linker */
  static char * heap_end;
         char * prev_heap_end;

  if (heap_end == NULL) heap_end = (char *)HEAP_START;//&amp;amp;end;
  prev_heap_end = heap_end;

  if (heap_end + incr &amp;gt;= (char *)HEAP_LIMIT) {
    abort ();      /* Out of Memory */
  }
  heap_end += incr;

  return (caddr_t) prev_heap_end;
}


&lt;/pre&gt;

&lt;p&gt;
according to your post:&lt;br /&gt;
1.On different baud hyperterminal doesn&amp;#39;t get real information , he
gets trash .&lt;br /&gt;
For example I send &amp;quot;hello&amp;quot;,and he gets &amp;quot;ee&amp;quot;&lt;br /&gt;
It&amp;#39;s posible when he can&amp;#39;t find the speed of data,&lt;br /&gt;
exactly he gets broken characters-but its not the point of my
problem!&lt;br /&gt;
2.there isn&amp;#39;t another program using my port ,I&amp;#39;m programing my
Aduc7026 by UART(the same port COM1)with max3232 , then I disconnect
my programmer software (ARMWSD software), and turn on
Hyperterminal&lt;br /&gt;
3.Bad information is now I don&amp;#39;t have an oscilloscope.&lt;br /&gt;
4.This case is quite unnormal for me, I&amp;#39;m not beginner, When I set
the required parameters for&lt;br /&gt;
transmission 9600/no parity/2bis he displays that:I can&amp;#39;t open my
COM1 port, but when I set incorrect&lt;br /&gt;
parameters like 4800/no parity/2bis he gets broken characters-so he
is transmitting something!&lt;br /&gt;
I read datasheet and analysed the code, every thing&lt;br /&gt;
is ok and there&amp;#39;s no way to move this UART on correct param.&lt;br /&gt;
The same COM1 port is working normally with UART on
LPC2146/at91sam/msp430 -no problems&lt;br /&gt;
On Aduc I tried to work with max3232 and max232 (he accepts 5V logic)
- the same problem&lt;br /&gt;
I can&amp;#39;t open my COM1 port on correct baud.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART examples for ADuc7026</title><link>https://community.arm.com/thread/88769?ContentTypeID=1</link><pubDate>Sat, 29 Dec 2007 23:08:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:566369b9-1873-4c5a-b1ce-9e70681489af</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
The normal reasons for failing to open the serial port is that it
is already open by another program or that you have specified a
missing port (such as com2 on a computer that only have com1
installed).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART examples for ADuc7026</title><link>https://community.arm.com/thread/51375?ContentTypeID=1</link><pubDate>Sat, 29 Dec 2007 22:43:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6b966b00-ed5a-48b4-bb4f-aa877309821a</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
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!&lt;/p&gt;

&lt;p&gt;
The hyperterminal doesn&amp;#39;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?&lt;/p&gt;

&lt;p&gt;
If the program configures 9600 baud and you on the PC connects
using 4800 baud, it is reasonable that you get broken characters.&lt;/p&gt;

&lt;p&gt;
1) Set hyperterminal to the correct baudrate.&lt;/p&gt;

&lt;p&gt;
2) Verify the baudrate of the connection with an oscilloscope.&lt;/p&gt;

&lt;p&gt;
3) If the problem persists: Repost your code, but this time
according to the posting instructions!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>