I am playing around with the PMOD_timer in my PYNQ-Z2. pynq VERSION IS 2.5.
First of all, I import the overlay to use the timers:
from pynq.overlays.base import BaseOverlay
base = BaseOverlay(“base.bit”)
Then I choose pin 0 of PMODA
from time import sleep
from pynq.lib import Pmod_Timer
pt = Pmod_Timer(base.PMODA,0)
Then I want to create a square wave where I have 3.3V half of the time 0V the rest of time. Thus a clock signal. The example in the board says I have to choose a “period” variable such that the “desired period” (T) is T = 10*period
On a different note, the variable clk_period_ns is said to be the pulse width. So I choose period=20 which means T=10*period=200, and clk_period=100, which means I should have a clock signal with period 200 ns
It is saying the pulse width is equal to the clock period (you can’t really change signals within a single IOP clock, so it is a reasonable assumption). And you can adjust how many clocks a pulse will appear, by changing the argument period. So if you want a clock signal output, you should change period=2, so
will give you an output clock signal.
shows that you should not change clk_period_ns since it is determined by the microblaze clock, therefore determined by fclk0.
So if you want to change the output clock frequency, try to adjust fclk0 using our Clocks class.
But I do think if you really want to generate an adjustable clock signal, you should use Pmod_PWM instead of Pmod_Timer.
Yes, you are 100% right on the fact I want to generate an adjustable clock signal. The problem I see with Pmod_PWM is the period is restricted between 1 and 65536 as specified in the line 97 of the following link:
That means the maximum I can generate is a 1 MHz clock signal, but I would like to get more than that if possible, especially seeing as the maximum frequency I can get playing with the Clocks class is 500 MHz.
As for PMOD_timer, which on paper would allow me to get bigger frequencies, the minimum period is 3, and I am not able to generate anything like a clock signal with it (I tried many options).
I wonder if there is an alternative solution for this I have been bypassing so far.
So it can generate clock pulse in the units of number of microblaze clock cycles.
We are using it this way:
You can modify the microblaze code, or even try ipython microblaze to directly code microblaze code in jupyter, something like:
Just keep in mind that the IO pins coming out of the Pmod has a maximum clock frequency, which is around 10 - 15 MHz. Even if you are able to generate above 15MHz clock, you won’t be able to see it on the IO pins - those IO pins are not designed for extremely high clocks.