11 years, 4 months ago.

Can DigitalOut generate a short-pulsewidth pulse?

/media/uploads/Freddy/-----2.png in the code above, I tried to generate a pulse every 5 seconds. So how small can p be set to? It seemed like that if I set p less than 10us, there's no pulse coming out. Do you know why? Could you give me some specific reasons? Thanks!

Hi Shenghao,

The minimum wait time for the wait function is ultimately fixed by the clockspeed of the LPC1768 chip that you are using. By default, it is clocked at 12MHz, however you will find that the minimum time of the wait function is much greater than 8.3 * 10-8, which you could consider your theoretical maximum. It couldn't get this low because in the wait function there are actually a few things going on which take up clock pulses. Unfortunately, I wouldn't be able to give you a definitive answer about this, however you could try reducing it and measuring the pulses on an oscilloscope to see what you get.

posted by Matthew Else 07 Aug 2013

Thanks for your reply! Yes, I did reduce the wait time, and measured the pulse with an oscilloscope. I couldn't remember what the pulse looked like. But I am that pulse had distortion and the pulse width was still about 10us. Do you think if it has something to do with the DigitalOut interface? Maybe DigitalOut limit the frequency?

posted by Shenghao Feng 08 Aug 2013

The LPC1768 runs at 96MHz. The crystal is 12MHz, but a PLL increases that to 96MHz. DigitalOut isn't as fast as you can get it by directly writing the required registers. But if you completely remove the wait it should take about 100ns iirc. It is also a bit slower when you move 'myled = 0' directly below 'myled = 1', then it doesn't need to jump back first.

However what is your goal? Using for example PWM will be superior for generating short pulses.

posted by Erik - 08 Aug 2013

Thanks! I was trying to generate a non-periodic signal, where I can set it to high or low and control the pulse width. That's why I tried DigitalOut instead of PWM, which can only generate periodic signal. Do you by any chance know how to achieve the goal?

posted by Shenghao Feng 08 Aug 2013

What are your requirements for period and pulse widths?

posted by Erik - 08 Aug 2013
Be the first to answer this question.