This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC 2138 simple problem

Hi all,

I have a small starter problem with my LPC2138

I'm using Flash Magic to make the hex file and program it to the arm controller.

I managed to make a serial connection with the terminal on Flash magic, so I can send characters to it.

What I want to do is to print a sentence to the terminal.

this is how I print a character:

void    outchar0(char k)
        {
        unsigned long a;                        //local variable
        U0THR=k;                                        //ascii code to buffer transmitter
                while((a=U0LSR&0x41)!=0)
                {
                }
        }

Parents
  • thanks for the replies.

    I'm not that good in programming the arm controller with Keil, I just started.

    so if you ask me why I use the magic constant 0x41 then its because I extracted it from a democode found on the internet.

    I appreciate the long answer from Per Westermark, but for now I don't understand much of it.
    It will take me some time to figure al things out.

    I already found how to print a sense by using sendstr()

    
    void sendstr (char *p) {                   /* Write string */
      while (*p) {
        putchar (*p++);
      }
    }
    
    int putchar (int ch)      /* Write character to Serial Port    */
            {
            if (ch == '\n')
            {
        while (!(U0LSR & 0x20));
        U0THR = CR;                          /* output CR */
            }
            while (!(U0LSR & 0x20));
            return (U0THR = ch);
            }
    

    this works for sendstr ("1000"); sendstr(" test3 ");

    but now I want to print a value.

    like : value = 1000; sendvalue(value);

    is there an easy solution for this?
    thanks in advance!

Reply
  • thanks for the replies.

    I'm not that good in programming the arm controller with Keil, I just started.

    so if you ask me why I use the magic constant 0x41 then its because I extracted it from a democode found on the internet.

    I appreciate the long answer from Per Westermark, but for now I don't understand much of it.
    It will take me some time to figure al things out.

    I already found how to print a sense by using sendstr()

    
    void sendstr (char *p) {                   /* Write string */
      while (*p) {
        putchar (*p++);
      }
    }
    
    int putchar (int ch)      /* Write character to Serial Port    */
            {
            if (ch == '\n')
            {
        while (!(U0LSR & 0x20));
        U0THR = CR;                          /* output CR */
            }
            while (!(U0LSR & 0x20));
            return (U0THR = ch);
            }
    

    this works for sendstr ("1000"); sendstr(" test3 ");

    but now I want to print a value.

    like : value = 1000; sendvalue(value);

    is there an easy solution for this?
    thanks in advance!

Children