HI,
We need to generate the PWM with clock period of 500ms with duty cycle of 50%. Here we configured the register as per the datasheet, which are as follows
SYSCON->SYSAHBCLKCTRL0 |= 1 << 25 ;
SYSCON->PRESETCTRL0 |= 1 << 25; SYSCON->SYSAHBCLKCTRL0 |= 1<<7; SWM0->PINASSIGN.PINASSIGN4 = 0X00000000; SWM0->PINASSIGN.PINASSIGN4 = (0X18) << 24 ;//0X18;// P0_24 PIN SELECTED SYSCON->SYSAHBCLKCTRL0 &= ~(1<<7); //DISABLE clock for switch matrix. CTIMER->TCR |= 1 << 1; CTIMER->PR = 0X00; CTIMER->MCR |= 1 << 9 | 1 << 10 | 1 << 27 | 1 << 0 | 1 << 1; CTIMER->MR[3] =10000; CTIMER->MSR[3]=10000; CTIMER->MR[0] =5000; CTIMER->MSR[0]=5000; CTIMER->PWMC |= 1<<3; CTIMER->TCR |= 1<<0 ; while(1);
This is the code which we developed. But there is no difference in pin status. We use
P0_24 for this PWM generation.
We not get the point of exact usage of EMR, Match shadow register.
Kindly navigate us to move further
Solved! Go to Solution.
Hi @Dhaya
Based on the code you provided, it seems you are trying to generate a PWM signal with a 50% duty cycle and a 500ms period using the LPC804's CTIMER. I noticed a few issues in the code that might be causing the problem:
SYSCON->SYSAHBCLKCTRL0 |= (1 << 25);
CTIMER->PWMC |= (1 << 3);
CTIMER->MCR |= (1 << 10) | (1 << 0);
With these changes, your code should look like this:
SYSCON->SYSAHBCLKCTRL0 |= (1 << 25); SYSCON->PRESETCTRL0 |= (1 << 25);
SYSCON->SYSAHBCLKCTRL0 |= (1 << 7); SWM0->PINASSIGN.PINASSIGN4 = 0X00000000; SWM0->PINASSIGN.PINASSIGN4 = (0X18) << 24; SYSCON->SYSAHBCLKCTRL0 &= ~(1 << 7);
CTIMER->TCR |= (1 << 1); CTIMER->PR = 0X00; CTIMER->MCR |= (1 << 10) | (1 << 0);
CTIMER->MR[3] = 10000; CTIMER->MR[0] = 5000;
CTIMER->PWMC |= (1 << 3); CTIMER->TCR |= (1 << 0);
while (1);
However, this code will generate a PWM signal with a 20ms
Hello @Dhaya,
Could you please take a look at LPC804 SDK's CTIMER PWM examples? It might be useful to develop your code.
We not get the point of exact usage of EMR, Match shadow register.
LPC804 User Manual. Chapter 16: LPC804 Standard counter/timer (CTIMER) explains both registers:
[LPC804 User Manual. Chapter 16. LPC804 Standard counter/timer (CTIMER). Section 16.5. Pin description]
As User Manual mentions the EMR controls whether the P0_24 is going to toggle, go low, high or do nothing when a match occurs between the TC and MR[3:0]. Section 16.6.10 of the User Manual explains how to configure the EMR.
About the MSR, User Manual's Section 16.6.13. Match Shadow Registers mentions: "The Match Shadow registers contain the values that the corresponding Match Registers are (optionally) reloaded with at the start of each new counter cycle."
The MSR could be used when you have to monitor the value of the CTIMER, for example, if you want to use it to generate a periodic event. The value of the timer could be read at any time by reading the value of the Match Shadow Register. In the example recommended it is not used to generate a PWM signal.
Best regards, Raul.
Hi @Dhaya
Based on the code you provided, it seems you are trying to generate a PWM signal with a 50% duty cycle and a 500ms period using the LPC804's CTIMER. I noticed a few issues in the code that might be causing the problem:
SYSCON->SYSAHBCLKCTRL0 |= (1 << 25);
CTIMER->PWMC |= (1 << 3);
CTIMER->MCR |= (1 << 10) | (1 << 0);
With these changes, your code should look like this:
SYSCON->SYSAHBCLKCTRL0 |= (1 << 25); SYSCON->PRESETCTRL0 |= (1 << 25);
SYSCON->SYSAHBCLKCTRL0 |= (1 << 7); SWM0->PINASSIGN.PINASSIGN4 = 0X00000000; SWM0->PINASSIGN.PINASSIGN4 = (0X18) << 24; SYSCON->SYSAHBCLKCTRL0 &= ~(1 << 7);
CTIMER->TCR |= (1 << 1); CTIMER->PR = 0X00; CTIMER->MCR |= (1 << 10) | (1 << 0);
CTIMER->MR[3] = 10000; CTIMER->MR[0] = 5000;
CTIMER->PWMC |= (1 << 3); CTIMER->TCR |= (1 << 0);
while (1);
However, this code will generate a PWM signal with a 20ms