You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've modified your implementation a little bit to work with arbitrary bit counts both in integer/decimal parts of the number as well as in "PWM" value which I actually use to feed to the 12-bit DAC. I've used C, so:
There are some hacks such as ticking during init, however by changing DECIMAL_BITS define it is possible to change decimal resolution as well as produce values in different ranges. Also I was using timer interrupts to perform "ticks", so there is no need to call for millis().
Example of usage:
#include<stdio.h>#include<math.h>#include"fpm.h"intmain(intargc, char**argv) {
structsin_wave*wave=create_sin_wave(100, 8);
for (uint32_ti=0; i<200; i++) {
tick_sin_wave(wave);
printf("%d,%d\n", i, wave->bitval);
}
delete_sin_wave(wave);
return0;
}
The text was updated successfully, but these errors were encountered:
Hi!
I've modified your implementation a little bit to work with arbitrary bit counts both in integer/decimal parts of the number as well as in "PWM" value which I actually use to feed to the 12-bit DAC. I've used C, so:
There are some hacks such as ticking during init, however by changing
DECIMAL_BITS
define it is possible to change decimal resolution as well as produce values in different ranges. Also I was using timer interrupts to perform "ticks", so there is no need to call formillis()
.Example of usage:
The text was updated successfully, but these errors were encountered: