1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

LPC 2148 Serial Communication

Discussion in 'ARM' started by Twisted_transistor, Oct 28, 2012.

  1. Twisted_transistor

    Twisted_transistor New Member

    Joined:
    Jul 22, 2012
    Messages:
    23
    Likes:
    0
    Hi.. I've written a code to transmit a character to PC using UART0. But, however, the hyperterminal is blank.
    Why is this happening?
    My code is as follows:

    Code (text):
    #include "LPC214x.h"
    void init(void);

    int main()
    { int i=0;
    init();

    while(i<=10){

    U1THR='D';
    while(!(U1LSR && 0x60));
    i++;

    }
    }

    void init()
    {
    PINSEL0=0x00050005;
    U1FCR=0x07; //enable and clear FIFOs
    U1LCR=0x83; //8-N-1, enable divisors
    U1DLL=0x62; //9600 baud (9615)
    U1DLM=0x00;
    U1LCR=0x03; //8-N-1, disable divisors
    }
     
  2. Twisted_transistor

    Twisted_transistor New Member

    Joined:
    Jul 22, 2012
    Messages:
    23
    Likes:
    0
    But if I modify d same code for UART1 it works fine.. Its only giving a problem with UART0..

    Is this happening because I'm using UART0 as ISP port to program my chip? I use flash magic & use the DTR & RTS to control the RST & ISP pins. So is it possible that my port is stuck in ISP mode & is that the reason why its not functioning as a normal UART?

    I'm really confused..
     
  3. پروژه های الکترو

    پروژه های الکترو Member

    Joined:
    Apr 20, 2012
    Messages:
    37
    Likes:
    0
    Location:
    تهران اندروید
    Have you also changed PINSEL register to a proper value or just you have changed everything 1 to 0?
     
    Last edited: Nov 11, 2012
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US

    How about using:

    U0

    Code (text):
    U0THR='D';
    while(!(U0LSR && 0x60));
     
  6. ELECTRO_ANKUSH

    ELECTRO_ANKUSH New Member

    Joined:
    Nov 24, 2013
    Messages:
    1
    Likes:
    0
    how to use uart interrupt in lpc2148?
    how to receive char through interrupt in lpc2148?tell me what is wrong in this code.received char i've to transmit again but it is not working.
    #include <lpc214x.h>
    void init_UART0(void)
    {
    VPBDIV=0x01;
    PINSEL0|=(1<<0)|(1<<2);
    U0LCR=0x83;

    /*to set baudrate using formula, load below registers
    .....................................................................................................*/
    U0DLL=78;
    U0FDR=0x28;
    U0LCR=0x03;
    U0IER=0x01;

    VICIntSelect=0x00;//IRQ interrupt
    VICVectAddr0=(unsigned long)UART0_isr;//isr assigned to 0th slot
    VICVectCntl0=0x26;//vector interrupt enable & UART0 select
    VICIntEnable=(1<<6);//enable interrupt

    }

    void Transmit(unsigned char ch)
    {
    while(!(U0LSR & 0x20)); //check THO is empty or not
    U0THR=ch;
    }

    void UART0_isr(void)__irq
    {
    unsigned char p;
    p=U0RBR;
    Transmit(p);
    VICVectAddr0=0x00;//clear address register

    }
    int main()
    {
    init_UART0();
    while(1);
    }
     
  7. Bidmeshki

    Bidmeshki New Member

    Joined:
    Dec 23, 2014
    Messages:
    1
    Likes:
    0
    it seems that your code is correct . if you are using P0.1 for ISP programing, you must remove the pull up resistor on this pin.
     

Share This Page