Discussion in "ARM Development" started by    mayank058    Jan 7, 2015.
Wed Jan 07 2015, 11:23 am
#1
hello Sir,
I am working on a project generation of multichannel pulse on CRO using MCB2300 board. I am able to generate multichannel pulse on CRO. but the pulse width and duty cycle is same in both the pulse..so please tell me how to generate multichannel pulse of different pulse width and duty cycle from different ports of MCB2300 board on CRO. please tell me the progreme code.
Fri Jan 09 2015, 10:22 am
#2
Are you using timers to generate PWM? You need to post your code to get better help on this.

[Topic moved to ARM Discussion Forum]
Fri Jan 09 2015, 04:22 pm
#3
sir I am using keil uvision 4 for the programming and my programm code is...
#include <LPC23xx.H> /* include for LPC23xx */
void PWMInit()
{
/* considering LPC2368 */
PINSEL3 |= (0x02<<8); /* reset PWM counter */
PWM1TCR = 0x02; /* setup match control to reset on MR0 */
PWM1MCR = 0x02; /*Reset on PWWMR0*/
/* select single edge for PWM1.1... and enable PWM1.2 o/p */
PWM1PCR = (1 << 10); /* setup PWM period */
PWM1MR0 = 12000000000/500; /* setup PWM duty cycle (50%) */

PWM1MR2 = PWM1MR0/2; /* start counter and enable PWM */
PWM1MR0 = 0;
PWM1TCR = 0x81; /* enable LER */
PWM1LER = 0x04;
}
void PWMI2nit()
{
/* considering LPC2368 */
PINSEL7 |= (0x03<<18); /* reset PWM counter */
PWM1TCR = 0x02; /* setup match control to reset on MR0 */
PWM1MCR = 0x02; /*Reset on PWWMR0*/
/* select single edge for PWM1.1... and enable PWM1.2 o/p */
PWM1PCR = (1 << 10); /* setup PWM period */

PWM1MR0 = 12000000000/500; /* setup PWM duty cycle (50%) */

PWM1MR2 = PWM1MR0/2; /* start counter and enable PWM */
PWM1TCR = 0x81; /* enable LER */
PWM1LER = 0x08;
}
int main()
{
PWMInit();
PWMI2nit();
while(1);
}
Mon Jan 12 2015, 10:31 am
#4
You're using single edge PWM. To keep different PWM duty cycle, Keep PWM period in MR0 and duty cycle in MR1 and MR2.
i.e. for PWM[1] duty cycle set MR1, PWM[2] set MR2. MR0 will be period time for both PWMs. e.g.
// This is just an example
MR0 = 100;
MR1 = 50; /* 50% duty on PWM1 */
MR2 = 20; /* 20% duty on PWM2 */
Mon Jan 12 2015, 11:21 am
#5
sir,
output is still the same, again duty cycle and pulse width is same in both waves.
I made an another programme for this problem. but when I used the programme only one pulse is generated as output. My new programme code is
#include <LPC23xx.H> /* include for LPC23xx */
void PWMInit()
{
/* considering LPC2368 */
PINSEL3 |= (0x02<<8); /* reset PWM counter */
PWM1TCR = 0x08; /* setup match control to reset on MR0 */
PWM1MCR = 0x02; /*Reset on PWWMR0*/
/* select single edge for PWM1.1... and enable PWM1.2 o/p */
PWM1PCR = (1 << 10); /* setup PWM period */
PWM1MR0 = 12000000000/500; /* setup PWM duty cycle (50%) */
PWM1MR2 = PWM1MR0/2; /* start counter and enable PWM */
PWM1TCR = 0x81; /* enable LER */
PWM1LER = 0x04;
}
void PWMI2nit()
{
/* considering LPC2368 */
PINSEL7 |= (0x03<<20); /* reset PWM counter */
PWM1TCR = 0x08; /* setup match control to reset on MR0 */
PWM1MCR = 0x02; /*Reset on PWWMR0*/
/* select single edge for PWM1.1... and enable PWM1.2 o/p */
PWM1PCR = (1 << 11); /* setup PWM period */
PWM1MR0 = 12000000000/500; /* setup PWM duty cycle (50%) */
PWM1MR3 = PWM1MR0/2; /* start counter and enable PWM */
PWM1TCR = 0x81; /* enable LER */
PWM1LER = 0x08;
}
int main()
{

PWMInit();
PWMI2nit();
while(1);
}
Thu Jan 15 2015, 10:24 am
#6
You're still setting same duty cycle for both PWM channels.
PWM1MR2 = PWM1MR0/2; 
PWM1MR3 = PWM1MR0/2;

This means both PWM2 and PWM3 will be 50%. change it to something like say,
PWM1MR2 = PWM1MR0/4; 
PWM1MR3 = PWM1MR0/2;

so PWM2 is now 25% and PWM3 is 50%.
Fri Jan 16 2015, 12:25 pm
#7
dear sir,
I used all these methods.. when i changed the duty cycle, it generates only one pulse. so,please tell me a complete programme code to generate two pulse of different pulse width and duty cycle.
Sun Jan 18 2015, 11:34 am
#8
I remember i created small library for lpc23xx series for PWM generation. I need to dig into my hard drive to find out
Mon Jan 19 2015, 11:17 am
#9
dear sir,
Please do it for me..
Tue Jan 20 2015, 10:05 am
#10
I found another issue with your code:
calling PWMInit() will enable PWM2
PWM1PCR = (1 << 10); /* setup PWM period */

and calling PWMI2nit() will disable PWM2 and enable PWM3
PWM1PCR = (1 << 11); /* setup PWM period */

same is the case with PWM1LER register, you're overwriting values in the registers. instead of equating directly use ORing.
PWM1LER |= 0x08;

as per your code, you can never see both PWM working. are you sure this is the right code you've posted?

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am