Reply by Andy Berney September 27, 20072007-09-27
Have a look on NXP's website for the LPC2129 user manual... it's all in
there...
UM_LPC21XX_LPX22XX_2.pdf...

Andy

-----Original Message-----
From: l... [mailto:l...]On Behalf Of
ranjani krishnan
Sent: 27 September 2007 03:07
To: l...
Subject: [lpc2000] Generating PWM in LPC2129
hai,

I am new to this ARM LPC2129. I want to generate 6 PWm signals for the
MOSFET driver to control my motor. Can anyone tell how to set the frequency
of PWM signals.What is the relation between the value given in MR0
register(given in hexadecimal value) and frequency ?How to generate 6PWM
signals with 60 degree delay?

regards,
ranjani

Rangarajan Varadan wrote:
hi Giorgio:
Here's what I understand
I see you have divided 12 MHz & are routing a 1.2 M clock to the Timer0.

is there any particular reason for doing T0ESR = 0x1<<0 ?

When you do the T0CLR, you are clearing the T0 interrupts
But What are you loading into T0VALUE?

By doing T0CTRL = 0x80 you enable count down & are counting down at
clockrate.

but as soon as you enable the countdown the T0VALUE keeps changing
It would perhaps be hard to determine your test & test2 values.
I guess you have declared them as unsigned ints but if some math you do
happens to become -(-) then you may end up having a value thats bigger than
the limit of unsigned int.

I don't think your problem is related to the T0ESR line, it is perhaps due
to the math.

Heres what I do for a 10 s delay,
I get the timer to countdown to 0 for 10 seconds, by loading 0x7441E into
T0VALUE.
When the countdown is complete I reload the same value by configuring
T0CTRL = 0xC8
this works with default/power on reset CGU configuration.

Cheers
Ranga

----- Original Message ----
From: akira699
To: l...
Sent: Wednesday, September 26, 2007 8:55:02 AM
Subject: [lpc2000] Timer 0 clock on LPC2888

Hi,

I'm working on LPC2888 and I tring to get a 1 MHz clock for timer0.

I have wrote this code:

main ()

{ DWORD test,test2;

DWORD config;

T0CTRL = 0;

APB1SCR = 0x01; // Select stage 1

APB1FSR1 =0x1; // Select Fast clk

APB1FDCR =0x02; // Reset

// Clear RUN bit in FDCR, fractional divider 3

APB1FDCR &= ~0x01;

// Reset FDR by setting bit 1(FDRES), set FDSTRCH bit,

// MADD is 0x48(72), MSUB is 0xF8(248), where m = 0x50, n = 0x8.

// FDR is divided by 10.

config = (((0xf8 << 8) | 0x48) << 3)

/*| (0x1 << 2)*/ | (0x1 << 1);

APB1FDCR = config;

// Clear Reset(FDRES) bit

config &= ~0x2;

APB1FDCR = config;

// Set RUN bit(FDRUN).

config |= 0x1;

APB1FDCR = config;

// Enable Select Register setting. ESR with 0 bit fields.

// bit 0 ESR_EN is 1 causing spreading stage output clock under

// the control of the fractional divider, which runs slower

// than the selection stage clock.

T0ESR = (0x1<<0);

T0CLR = 0;

T0CTRL=0x80; // Enable counter

test=0xFFFFFFFF- T0VALUE;

do { test2=0xFFFFFFFF- T0VALUE-test;

} while (test2<12000000) ; // 10 second

test=0;

}

In this sample I should get 10 second delay but the timer don't work.

If I remove the T0ESR instruction than the delay is 1 second (no

clock divider from FDCR).

Why the timer is hang with T0ESR=1 instruction?

Thanks for your help

Best regards,

Giorgio







__________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who
knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid96545433



---------------------------------
Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user
panel and lay it on us.

An Engineer's Guide to the LPC2100 Series

Reply by ranjani krishnan September 27, 20072007-09-27
hai,

I am new to this ARM LPC2129. I want to generate 6 PWm signals for the MOSFET driver to control my motor. Can anyone tell how to set the frequency of PWM signals.What is the relation between the value given in MR0 register(given in hexadecimal value) and frequency ?How to generate 6PWM signals with 60 degree delay?

regards,
ranjani

Rangarajan Varadan wrote:
hi Giorgio:
Here's what I understand
I see you have divided 12 MHz & are routing a 1.2 M clock to the Timer0.

is there any particular reason for doing T0ESR = 0x1<<0 ?

When you do the T0CLR, you are clearing the T0 interrupts
But What are you loading into T0VALUE?

By doing T0CTRL = 0x80 you enable count down & are counting down at clockrate.

but as soon as you enable the countdown the T0VALUE keeps changing
It would perhaps be hard to determine your test & test2 values.
I guess you have declared them as unsigned ints but if some math you do happens to become -(-) then you may end up having a value thats bigger than the limit of unsigned int.

I don't think your problem is related to the T0ESR line, it is perhaps due to the math.

Heres what I do for a 10 s delay,
I get the timer to countdown to 0 for 10 seconds, by loading 0x7441E into T0VALUE.
When the countdown is complete I reload the same value by configuring T0CTRL = 0xC8
this works with default/power on reset CGU configuration.

Cheers
Ranga

----- Original Message ----
From: akira699
To: l...
Sent: Wednesday, September 26, 2007 8:55:02 AM
Subject: [lpc2000] Timer 0 clock on LPC2888

Hi,

I'm working on LPC2888 and I tring to get a 1 MHz clock for timer0.

I have wrote this code:

main ()

{ DWORD test,test2;

DWORD config;

T0CTRL = 0;

APB1SCR = 0x01; // Select stage 1

APB1FSR1 =0x1; // Select Fast clk

APB1FDCR =0x02; // Reset

// Clear RUN bit in FDCR, fractional divider 3

APB1FDCR &= ~0x01;

// Reset FDR by setting bit 1(FDRES), set FDSTRCH bit,

// MADD is 0x48(72), MSUB is 0xF8(248), where m = 0x50, n = 0x8.

// FDR is divided by 10.

config = (((0xf8 << 8) | 0x48) << 3)

/*| (0x1 << 2)*/ | (0x1 << 1);

APB1FDCR = config;

// Clear Reset(FDRES) bit

config &= ~0x2;

APB1FDCR = config;

// Set RUN bit(FDRUN).

config |= 0x1;

APB1FDCR = config;

// Enable Select Register setting. ESR with 0 bit fields.

// bit 0 ESR_EN is 1 causing spreading stage output clock under

// the control of the fractional divider, which runs slower

// than the selection stage clock.

T0ESR = (0x1<<0);

T0CLR = 0;

T0CTRL=0x80; // Enable counter

test=0xFFFFFFFF- T0VALUE;

do { test2=0xFFFFFFFF- T0VALUE-test;

} while (test2<12000000) ; // 10 second

test=0;

}

In this sample I should get 10 second delay but the timer don't work.

If I remove the T0ESR instruction than the delay is 1 second (no

clock divider from FDCR).

Why the timer is hang with T0ESR=1 instruction?

Thanks for your help

Best regards,

Giorgio







__________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid96545433



---------------------------------
Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us.