Hi,
I am using lpc1768. By using Timer, i have generated a square wave with time period of 16ms. The ON period should be 1ms and OFF period should be 15ms. I used two match registers MR0 and MR1. I done with MR0 for OFF period and MR1 for ON period. But am getting the signal as 15ms as ON period and 1ms as OFF period. Plz suggest some solutions.
Thank You
Well, you would normally have one match register produce a interrupt+reset while the other only produces an interrupt.
And you make MR0 = 15ms and MR1 = 16ms. Or MR0 = 1ms and MR1 = 16ms.
Then you get a 16ms cycle that either have 1+15 or 15+1 - both alternatives can give the correct output - the only difference is with of the periods it starts with directly when you initialize the timer.
But in the end, it is important to note that things often doesn't work on first try. The task then isn't to rewrite the code randomly and see what happens. You instead take one step back and try to compare what you think you instructed the processor to do, with that the processor manual describes the processor to do. And the debugger can be used to look at state and compare with the state you assumed you would have.
Random "work around" changes are seldom producing good solutions.
Actually in the MCR register i have given reset and interrupt in both MR) and MR1 register. Thats why i didnt get. Now am getting the expected signal.
And that was why I explicitly wondered why you played with two match registers while still configuring the timer to reset on every match making it impossible to reach any second match value.
So next thing - are you aware that if you use the match output pins, then you can have the timer drive these pins with zero ISR involved? And zero jitter from interrupt response time or varying code paths of any code sequences?