I know that when the timer match the M1, I can let the mat pin to be up, down or toggle. But how to control the initial state of the MAT pin?

I'm using LPC1343CodeBase on a port1343 experiment board.

It's a for a simple non blocking servo command. Period is 20ms. Output should be HIGH for 1 or 1.5ms then LOW for the rest of the period.

I use prescale to have ms long duration with the 16 bit timer. M3 is triggering the reset.

I have an imperfect solution: using PWD and being LOW for (20-1)ms and up after that.


1 Answer 1


Set / Reset bits 0 to 3 of EMR register (EM0 to EM3). Example for clear the external MATCH1:

LPC_TIMER0->EMR &= ~0x02;

Of course, depends on your compiler. Please, next time provide further details... Note that if the match outputs are configured as PWM output, the function of the external match registers is determined by the PWM rules (Section 15.8.13 “Rules for single edge controlled PWM outputs” on page 271).

  • \$\begingroup\$ Sorry, but i don't think it works: with TMR_TMR16B1EMR = TMR_TMR16B1EMR_EMC0_TOGGLE; // | TMR_TMR16B1EMR_EM0; i've got 1.66 V(3.3/2) in output, so reset doesnt reset the MAT \$\endgroup\$ Jun 28, 2014 at 16:12
  • \$\begingroup\$ Is it possible to mimick the PWM without being in PWM mode ? I'd like the output to be High then low, but th PWM mode is low then high. \$\endgroup\$ Jun 28, 2014 at 16:17
  • \$\begingroup\$ I'm sure it works. After all, many of my projects involving M0, M3, M4 are based on this idea. If you give us further details about the application, probably had already solved the issue. For example, you have not told us whether or not using the PWM mode (despite my previous comment). You must be forgetting some IO setting (eg IOCON, etc ...). Read the User Manual. \$\endgroup\$ Jun 28, 2014 at 19:22
  • \$\begingroup\$ Also, if you do LPC_TIMER0->EMR = xxxx (a complete assignment), you will "override" that previous setting, which I suggested to you (LPC_TIMER0->EMR &= ~0x02). Prefer to use bit masks, instead. \$\endgroup\$ Jun 28, 2014 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.