FabGL
ESP32 VGA Controller and Graphics Library
|
This is a square wave generator that uses APLL internal Audio PLL clock. More...
#include <swgenerator.h>
Public Member Functions | |
void | begin (bool div1_onGPIO0, gpio_num_t div2=GPIO_NUM_39, gpio_num_t div4=GPIO_NUM_39, gpio_num_t div8=GPIO_NUM_39, gpio_num_t div16=GPIO_NUM_39, gpio_num_t div32=GPIO_NUM_39, gpio_num_t div64=GPIO_NUM_39, gpio_num_t div128=GPIO_NUM_39, gpio_num_t div256=GPIO_NUM_39) |
Initializes SquareWaveGeneratorClass and associate GPIOs to the outputs. More... | |
void | end () |
Disables all outputs. More... | |
void | play (int freq, lldesc_t volatile *dmaBuffers=nullptr) |
Sets the main frequency. More... | |
void | stop () |
Disables all outputs. More... | |
This is a square wave generator that uses APLL internal Audio PLL clock.
When FABGLIB_USE_APLL_AB_COEF = 0 (the default) the frequency range is 2651514 Hz to 62500000 Hz.
Average error is 21 Hz, Minimum error is 0, Maximum error is 1000 Hz except for range 41666667 Hz to 42708333 Hz while frequency remains fixed at 41666666 Hz (error from 0 Hz to 1041666 Hz) and except for range 42708334 hz to 43748999 Hz while frequency remains fixed at 43750000 Hz (error from 750001 Hz to 1041666 Hz).
When FABGLIB_USE_APLL_AB_COEF = 1 the frequency range is 82500 Hz to 62500000 Hz. Unfortunately the output has lot of frequency jittering.
Average error is about 7 Hz, Minimum error is 0, Maximum error is 6349 Hz.
void fabgl::SquareWaveGeneratorClass::begin | ( | bool | div1_onGPIO0, |
gpio_num_t | div2 = GPIO_NUM_39 , |
||
gpio_num_t | div4 = GPIO_NUM_39 , |
||
gpio_num_t | div8 = GPIO_NUM_39 , |
||
gpio_num_t | div16 = GPIO_NUM_39 , |
||
gpio_num_t | div32 = GPIO_NUM_39 , |
||
gpio_num_t | div64 = GPIO_NUM_39 , |
||
gpio_num_t | div128 = GPIO_NUM_39 , |
||
gpio_num_t | div256 = GPIO_NUM_39 |
||
) |
Initializes SquareWaveGeneratorClass and associate GPIOs to the outputs.
div1_onGPIO0 | If true the undivided frequency is delivered on GPIO0. |
div2 | Specifies the GPIO where to send frequency / 2 (set GPIO_NUM_39 to disable output). |
div4 | Specifies the GPIO where to send frequency / 4 (set GPIO_NUM_39 to disable output). |
div8 | Specifies the GPIO where to send frequency / 8 (set GPIO_NUM_39 to disable output). |
div16 | Specifies the GPIO where to send frequency / 16 (set GPIO_NUM_39 to disable output). |
div32 | Specifies the GPIO where to send frequency / 32 (set GPIO_NUM_39 to disable output). |
div64 | Specifies the GPIO where to send frequency / 64 (set GPIO_NUM_39 to disable output). |
div128 | Specifies the GPIO where to send frequency / 128 (set GPIO_NUM_39 to disable output). |
div256 | Specifies the GPIO where to send frequency / 256 (set GPIO_NUM_39 to disable output). |
Example:
// Outputs 25Mhz on GPIO0 and 6.25Mhz on GPIO5, for 5 seconds SquareWaveGenerator.begin(true, GPIO_NUM_39, GPIO_NUM_5); SquareWaveGenerator.play(25000000); delay(5000); // Outputs 20Mhz on GPIO and 5Mhz on GPIO5, for 10 seconds SquareWaveGenerator.play(20000000); delay(10000); SquareWaveGenerator.stop();
void fabgl::SquareWaveGeneratorClass::end | ( | ) |
Disables all outputs.
void fabgl::SquareWaveGeneratorClass::play | ( | int | freq, |
lldesc_t volatile * | dmaBuffers = nullptr |
||
) |
Sets the main frequency.
freq | Frequency in Hertz. |
dmaBuffers | Use only to provide custom DMA buffers. |
Example:
// Set 25MHz as main frequency SquareWaveGenerator.play(25000000);
void fabgl::SquareWaveGeneratorClass::stop | ( | ) |
Disables all outputs.