Discussion in "ARM Development" started by    shyam    Dec 28, 2007.
Fri Dec 28 2007, 10:34 AM
#1
topics to be discussed
1. selction of pins for different function.
2. setting PLL .
3.setting baud rate.
4.sending a byte of data.
5. receiving a byte of data.
6. using in interrupt.
7.difference between polled and interrupt mode


any thing u wanna add??
Fri Dec 28 2007, 10:58 AM
#2
A small example programme to learn and test communication on hyperterminal . If till tomorrow i i could understand and test it on my board then i will feel bit satisfied
I believe you have made a proper list of topics further .

/* Include header file depending upon device been used */
#include<Philips\LPC2148.h>

void Initialize(void);
/* Macro Definitions */
#define TEMT (1<<6)
#define LINE_FEED 0xA
#define CARRIAGE_RET 0xD
/************************* MAIN *************************/
int main()
{
int i;
char c[]="Philips LPC";
Initialize()
/* Print forever */
while(1)
{
i=0;
/* Keep Transmitting until Null character('\0') is reached */
while(c[i])
{
U0THR=c[i];
i++;
}
U0THR=LINE_FEED;
U0THR=CARRAIGE_RET;
/* Wait till U0THR and U0TSR are both empty */
while(!(U0LSR & TEMT)){}
}
}
/*************** System Initialization ***************/
void Initialize()
{
/* Initialize Pin Select Block for Tx and Rx */
PINSEL0=0x5;
/* Enable FIFO's and reset them */
U0FCR=0x7;
/* Set DLAB and word length set to 8bits */
U0LCR=0x83;
/* Baud rate set to 9600 */
U0DLL=0x10;
U0DLM=0x0;
/* Clear DLAB */
U0LCR=0x3;
}
/*********************************************************/






[ Edited Fri Dec 28 2007, 02:06 PM ]
Fri Dec 28 2007, 11:01 AM
#3
I am looking forward for elaborate explanation on above subtopics . I do miss a lot words while typing a post and send it without checking . Please ignore myomissions.
Fri Dec 28 2007, 11:46 AM
#4

wow u r really being quick i wud prefer to take a step a time...
moreover it is always better to set PLL than using its default value....

we will certainly try to get ur programme running....

1. selction of pins for different function.

in lpc as u might have noticed one pin can be configured to serve as 4 different funtions ex.
P0.1/RXD0/PWM3/EINT0 it is one single pin..

these functions lets say are fun0 fun1 fun2 fun3.

edited[
P1 in lpc21xx donot have special functions they have just fun0 and fun1.
things to note: we r not considering JTAG yet.. actually PINSEL2 is the PINSEL associated for P1 but
fun1 is related for JTAG debug.. Pins 0 through 15 of port 1 are not available.
]
in all cases fun0 is GPIO

by default (unless the functionality is selected all pins have this fun0).
the functionality can be configured by using PINSEL register (32 bit).

edited
[

thus it wud be clear by now that P1 does not have a PINSEL corresponding to it....
oops!! forgot pinsel2 plz ignore this line :blush


]
in binary the functions can be numbered as 0 00
1 01
2 02
3 03
each pin thus has two pinsel bits corresponding to it..
thus it wud be clear now .. for 32 bit Port 1 2 PINSEL registers wud be required..
they are PINSEL0 & PINSEL1.

now to ajay's code.

void Initialize()
{
/* Initialize Pin Select Block for Tx and Rx */
PINSEL0=0x5;


writing 0x5 in binary we get.. 0x 01 01
the first two bits determine the function chosen
for P0.0 i.e. fun1 => UART0 TXD0
similarly the next two bits determine
the function chosen
for P0.1 i.e. fun1 => UART0 RXD0

thus ajay has selected his pair of RX/TX
!dance
!dance !dance


[ Edited Fri Dec 28 2007, 04:09 PM ]
Fri Dec 28 2007, 12:13 PM
#5
Slow and steady wins the race . You be slow and i am going to be steady . Ultimately we all will win.
Fri Dec 28 2007, 12:51 PM
#6


[ Edited Fri Dec 28 2007, 04:13 PM ]
Fri Dec 28 2007, 01:07 PM
#7
please note P0.31 is GPO Port only i.e. cannot be configured as input!
it is generally used as USB good link led signal!!
Fri Dec 28 2007, 01:25 PM
#8
2. setting PLL .

The PLL is used to multiply the external crystal frequency up to the maximum 60 MHz. It
is controlled by the constants M and P.


Within the PLL are two constants which must be programmed in order to determine the clock for the CPU and AHB. This clock is called Cclk. The first constant is a straightforward multiplier of the external crystal. The output frequency of the PLL is given by:
Cclk = M x Osc


In the feedback path of the PLL is a current-controlled oscillator which must operate in the range 156MHz – 320
MHz.. The second constant acts as a programmable divider which ensures that the CCO is kept in specification.
The operating frequency of the CCO is defined as:
Fcco = Cclk x 2 x P



well i had already submitted a design for lpc2138/48 if u find it ... u wud notice the crystall of frequency 14.745 Mhz.


so
- System should run at max. Frequency (60MHz) [limit: max 60 MHz]
- Choose multiplier M=4
so cclk = M * F_OSC= 4 * 14745000Hz = 58980000 Hz

- F_CCO must be inbetween the limits 156 MHz to 320 MHz
datasheet: F_CCO = F_OSC * M * 2 * P
- choose devider P=2 => F_CCO = 14745000Hz * 4 * 2 * 2
= 235920000 ~=236 MHz

now you can choose the multiplier and devider value for PLL depending on your crystall
Fri Dec 28 2007, 01:58 PM
#9
please note:


There are two PLL modules in the LPC2141/2/4/6/8 microcontroller. The PLL0 is used to
generate the CCLK clock (system clock) while the PLL1 has to supply the clock for the
USB at the fixed rate of 48 MHz. Structurally these two PLLs are identical with exception
of the PLL interrupt capabilities reserved only for the PLL0.



so @ ajay...
u should configure the PLL first...

lets see how to do it=>>>

Fri Dec 28 2007, 02:57 PM
#10
take a look at the code...

#define FOSC		14745000             
 /*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_FEED1	0xAA   
 /*constant*/ 
#define PLL_FEED2	0x55                 
 /*constant*/


void systemPllInit(void)
{
        // --- enable and connect the PLL (Phase Locked Loop) ---
	// a. set multiplier and divider
	PLLCFG = MSEL | (1<<PSEL1) | (0<<PSEL0);
	// b. enable PLL
	PLLCON = (1<<PLLE);
	// c. feed sequence
	PLLFEED = PLL_FEED1;
	PLLFEED = PLL_FEED2;
	// d. wait for PLL lock (PLOCK bit is set if locked)
	while (!(PLLSTAT & (1<<PLOCK)));
	// e. connect (and enable) PLL
	PLLCON = (1<<PLLE) | (1<<PLLC);
	// f. feed sequence
	PLLFEED = PLL_FEED1;
	PLLFEED = PLL_FEED2;
	
}


steps to initialise pll
1.
// --- enable and connect the PLL (Phase Locked Loop) ---
// a. set multiplier and divider
PLLCFG = MSEL | (1<<PSEL1) | (0<<PSEL0);
remember MSEL = M -1 cause to remove devide by zero error... the MSEL value is always +1 there will be other instances too... we will discuss as they come across..
2.
// b. enable PLL
PLLCON = (1<<PLLE);
every time you make a change in PLLCON register be sure to follow it up with a feed sequence to affect the changes done... else there wud be no effect and old status will be in effect... :-)
so..
// c. feed sequence
PLLFEED = PLL_FEED1;
PLLFEED = PLL_FEED2;//mandatory
3.
// d. wait for PLL lock (PLOCK bit is set if locked)
while (!(PLLSTAT & (1<<PLOCK)));
4.
// e. connect (and enable) PLL
PLLCON = (1<<PLLE) | (1<<PLLC);
// f. feed sequence
PLLFEED = PLL_FEED1;
PLLFEED = PLL_FEED2;

now your system is ready to work at the desired PLL frequencies... remember PLL settings shud be carefully done... as they help generate the frequencies for almost all on chip devices...

note: dont worry writing this function in your every code.. it will remain same as long as u use the same crystall...



[ Edited Fri Dec 28 2007, 04:01 PM ]
 saowangru like this.

Get Social

Information

Powered by e107 Forum System

Conversation

scena
Wed May 20 2020, 03:59 AM
Does anyone have microcontroller programming software for STC15F104W (core 8051, 4 k, 128 byte, 6 I/O pin, UART ... DIL8), that works?
Sun May 03 2020, 01:08 AM
Tamu Gurung
Hi I am looking for a assembly language program for a digital decimal counter. Time counts max limit of 2 mins starting from 2.00 mins and ending at 0.00. time is to be displayed on 4 7-segment LED displays. Edsim51 simulator to be used. Thanks
Wed Mar 25 2020, 07:09 PM
Tajammul
Sir kindly send the code file i2c for 8051
ExperimenterUK
Sat Mar 14 2020, 04:06 AM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 06:25 PM
ABEBE
how can get hadwere of this project
Rohitnani
Sat Mar 07 2020, 09:41 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 09:28 PM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 02:42 PM
Pearl Olin
Hello,
Wed Jan 22 2020, 10:46 PM
MINU CHAUDHARY
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.
Tue Jan 14 2020, 11:38 AM
shubham kharade
when i am trying to simulate the program in Proteus 8 professional, I am getting some errors as cannot find module file dhtxx.md can u help me

Downloads

Comments

Davidthils
Thu May 21 2020, 08:44 AM
Jakeror
Wed May 20 2020, 09:28 PM
motorCar
Wed May 20 2020, 03:05 PM
Vordrync
Wed May 20 2020, 07:52 AM
JadenjiT
Wed May 20 2020, 03:15 AM
scena
Tue May 19 2020, 06:08 PM
CodySiz
Tue May 19 2020, 02:22 PM
ClaireSat
Mon May 18 2020, 09:50 PM

Online

Guests: 49, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 01:37 AM

Members: 38211
Newest member: Davidthils
Forum Activity
xrxx Avatar
Posted By xrxx
Thu Apr 30 2020, 06:59 AM
BCD MULTIPLICATIONAssume that you have to 2 BCD nu...
liqian Avatar
Posted By liqian
Tue Apr 28 2020, 05:26 AM
I happened to see your post and I got many useful ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Apr 28 2020, 04:21 AM
The code is hard to read.Please zip it and attach ...
rogermado Avatar
Posted By rogermado
Sun Apr 26 2020, 01:53 AM
@ExperimenterUK, thanks for your reply. You'll fin...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Apr 25 2020, 05:42 PM
Some simulators handle displays better than others...
rogermado Avatar
Posted By rogermado
Sat Apr 25 2020, 03:59 PM
Hello everyone, sorry in advance if i'm not in the...
PHANTOM28 Avatar
Posted By PHANTOM28
Fri Feb 28 2020, 10:25 AM
Hi.I hope you all can help me. I am relatively ne...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 21 2020, 05:05 PM
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Feb 21 2020, 04:45 AM
Yes you can do that.1. Create a channel @Thingspea...
ananyagupta Avatar
Posted By ananyagupta
Thu Feb 20 2020, 03:58 AM
With regards to the particular characters sent to ...