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: