I'm using an Armmite to make a Frequency Multiplier. I have an Interrupt routine
that uses Timer0 to measure the period of a sequence of pulses. It then
multiplies the period by a fractional ratio to produce the period of the new
frequency. It's always 50% duty cycle.
Do I use HWPWM and constantly update the the period in a while loop?
Like this in C. HWPWM = (0.5, 8, Period);
Should I only update HWPWM when Period changes?
Should I update Period in the Interrupt Routine?
I don't want spurious rate changes.
Should I use FREQOUT, or PULSEOUT, or PWM?
Frequency multiplier
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Frequency multiplier
> I'm using an Armmite to make a Frequency Multiplier. I have an Interrupt
routine that uses Timer0 to measure the period of a sequence of pulses. It then
multiplies the period by a fractional ratio to produce the period of the new
frequency. It's always 50% duty cycle.
>
> Do I use HWPWM and constantly update the the period in a while loop?
> Like this in C. HWPWM = (0.5, 8, Period);
> Should I only update HWPWM when Period changes?
> Should I update Period in the Interrupt Routine?
I'd use HWPWM, but probably write to the registers directly to do the variation.
The only trick is if the period is decreasing, and the count is already past the
reset point, and you update the register, you'll get a very lonnnnngggggg
period, as the comparisons are equal to not greater than.
So in that case you would have to wait for the counter to roll over to 0 to do
the update.
routine that uses Timer0 to measure the period of a sequence of pulses. It then
multiplies the period by a fractional ratio to produce the period of the new
frequency. It's always 50% duty cycle.
>
> Do I use HWPWM and constantly update the the period in a while loop?
> Like this in C. HWPWM = (0.5, 8, Period);
> Should I only update HWPWM when Period changes?
> Should I update Period in the Interrupt Routine?
I'd use HWPWM, but probably write to the registers directly to do the variation.
The only trick is if the period is decreasing, and the count is already past the
reset point, and you update the register, you'll get a very lonnnnngggggg
period, as the comparisons are equal to not greater than.
So in that case you would have to wait for the counter to roll over to 0 to do
the update.
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Frequency multiplier
What counter is used for HWPWM? I'll update the period after the counter resets
to zero, whether period increases or decreases. Or I can check to see if the
count is less than 'period' before I update.
to zero, whether period increases or decreases. Or I can check to see if the
count is less than 'period' before I update.
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Frequency multiplier
> What counter is used for HWPWM? I'll update the period after the
counter resets to zero, whether period increases or decreases. Or I can check to
see if the count is less than 'period' before I update.
>
Potentially all 4 counters, details in the source for HWPWM, which is in the
BASIClib directory.
counter resets to zero, whether period increases or decreases. Or I can check to
see if the count is less than 'period' before I update.
>
Potentially all 4 counters, details in the source for HWPWM, which is in the
BASIClib directory.