Port Manipulation control by potentiometer

Hi
Recently i learned how to use DDRD for closing and opening output pins in a really fast way. It takes 62.5nF for Arduino Uno to open/close an output pin. I use this feature so to output specific frequencies at different pins for driving mosfets at high frequencies.

I wonder. Is there any way to control those frequencies by any external mean? (Instead of outputing a fixed pulse train.). In cases in which speed is not a matter, i did it with a pot connected to an analog input pin controlling a delay between open/close of a pin. But now at those speeds it doesn't look right. What is your opinion guys? Where do i have to look for that?

Thanks
Jeg

An analogRead() is very slow compared to 62.5nS (not nF).

If you want to produce a continuous stream of fast pulses using direct port writes then there may simply be no time to read the ADC with analogRead()

If you look at the Atmega datasheet you will see that it is possible to start an ADC conversion and come back later to get the result. By breaking the process into two steps it may be possible to interleave it with your port writes.

Another idea to put into your head is using one of the Hardware Timers to produce the pulses as that will work in the background and leave the rest of the Arduino free for other stuff.

...R

Robin2:
Another idea to put into your head is using one of the Hardware Timers to produce the pulses as that will work in the background and leave the rest of the Arduino free for other stuff.

...R

Thanks a lot. Timers look convinient for my case. I'll learn more about them and i'll be back to report.
By your answer i realised that i didn't mention that:

  1. I intent to use two pins (2,3)
  2. Each pin will output a specific number of pulses and then it will stop while the other pin starts pulsing. So they output senquentialy. While their output frequency is in the range between 200-400Khz, their frequency of change wll be in the range between 5KHz-40KHz.

Robin2:
An analogRead() is very slow compared to 62.5nS (not nF).

62.5 nanoSiemens equates to 16 Megohms. That may slow things down excessively :roll_eyes:

Paul__B:
62.5 nanoSiemens equates to 16 Megohms. That may slow things down excessively :roll_eyes:

I, at least TRIED to show the correct abbreviation. I guess from your comment it should be a small s for seconds - as in ns. I don't think it is useful to tell newbies that something is wrong without also showing the correct version.

...R