Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ARM lpc 2148 interfacing with uart0

Status
Not open for further replies.

pradeep23

Member level 5
Joined
Aug 20, 2012
Messages
86
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Activity points
1,866
hi hello i am trying my arm lpc2148 to communicate with uart0

can u give some any code for that .....using 9600 baud rate ..

I am just trying my message to display in hyper terminal dats plz help me
 

hi pradeep
please find attached keil project for serial.
you have to make simple changes according to your hardware interface.
 

Attachments

  • Serial.rar
    8.6 KB · Views: 68

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include<lpc214x.h>
#include<stdio.h>
#include<string.h>
 
//#define U0THR=0xA;
             
//#define FOSC            12000000            
 /*on board crystall frequency */
#define PLL_M           4                            
 /*Cclk = M x Osc  Cclk =60Mhz  Osc 14.745 Mhz M~4   */
#define MSEL            (PLL_M-1)
#define PSEL0           5      
 /*see user manual PLLCFG*/
#define PSEL1           6  
 /*see user manual*/
 
#define PLLE            0
 /*see user manual PLLCON*/
#define PLLC            1    
 /*see user manual PLLCON*/
 
#define PLOCK           10  
 /*see user manual PLLSTAT*/
 
#define PLL_0FEED1       0xAA  
 /*constant*/
#define PLL_0FEED2       0x55                
 /*constant*/
 
 
void systemPllInit(void)
{
    // --- enable and connect the PLL (Phase Locked Loop) ---
    // a. set multiplier and divider
    PLL0CFG = MSEL | (1<<PSEL1) | (0<<PSEL0);
    // b. enable PLL
    PLL0CON = (1<<PLLE);
    // c. feed sequence
    PLL0FEED = PLL_0FEED1;
    PLL0FEED = PLL_0FEED2;
    // d. wait for PLL lock (PLOCK bit is set if locked)
    while (!(PLL0STAT & (1<<PLOCK)));
    // e. connect (and enable) PLL
    PLL0CON = (1<<PLLE) | (1<<PLLC);
    // f. feed sequence
    PLL0FEED = PLL_0FEED1;
    PLL0FEED = PLL_0FEED2;
       
}
 
 
 
 
void uart0_init(void)
 
{
 
  
  PINSEL0|=0x00000005;
  U0IER=0x01;
  U0FCR=0x07;
  
  U0LCR=0x83;
  U0DLL=0x4F;
  U0DLM=0x00;
 
  U0LCR=0x03;
 
  U0FCR =0x01; 
 
}
 
int main()
{
static int i;
static char c[]="hi hello ";
systemPllInit();
uart0_init(); 
 
for(i=0;i<20;i++)
{
U0TER=0x80;
while (!(U0LSR & 0x20));
U0THR=c[i];
 
}
while(1);
 
}




this is correct ...for uart0 we have to initialize the PLL ?
 
Last edited by a moderator:

It is not necessary for UART0
it is required to initialize your system clock.

- - - Updated - - -

It is not necessary for UART0
it is required to initialize your system clock.
 

so if i changed the code its not working y?

- - - Updated - - -


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<lpc214x.h>
#include<stdio.h>
#include<string.h>
 
 
 
 
 
void uart0_init(void)
 
{
 
  
  PINSEL0|=0x00000005;
  U0IER=0x01;
  U0FCR=0x07;
  
  U0LCR=0x83;
  U0DLL=0x4F;
  U0DLM=0x00;
 
  U0LCR=0x03;
 
  U0FCR =0x01; 
 
}
 
int main()
{
static int i;
static char c[]="hi hello ";
//systemPllInit();
uart0_init(); 
 
for(i=0;i<20;i++)
{
U0TER=0x80;
while (!(U0LSR & 0x20));
U0THR=c[i];
 
}
while(1);
 
}




this code is correct or wrong plz help i ddnt get i am trying from last 3 days
 
Last edited by a moderator:

how to handle interrupt of Rx. Not working for me and plz repost your final working code.
thank you..and sorry for digging.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top