Hello,
Using ESP32, I generate a clock of 9.9MHz by a code as below.
Could anyone please show me if it would be the highest clock?
and, if it would be constantly.
I afraid there would be jitter or deficiency, but I could not check it because I have not logger for so that long period.
Thank you.
// ESP32
//
#define PORT (*((volatile uint32_t*)GPIO_OUT_REG))
#define PIN_OUT 23
//#define PIN_H PORT |= (1 << PIN_OUT)
//#define PIN_L PORT &= ~(1 << PIN_OUT)
#define PIN_H PORT = (1 << PIN_OUT)
#define PIN_L PORT = 0
void setup()
{
pinMode(PIN_OUT, OUTPUT);
noInterrupts();
tag_loop:
PIN_H;
PIN_L;
goto tag_loop;
}
void loop()
{
}
Highest clock by GPIO
-
- Posts: 9769
- Joined: Thu Nov 26, 2015 4:08 am
Re: Highest clock by GPIO
Don't try to bitbang things like this and expect a good result. There's other cores on the system accessing hardware, so even if you disable interrupts (which you should not do for long in the first place, by the way, as it can break when things like NVS access or some hardware workarounds hapen) you won't get timing that's guaranteed consistent. Instead, use one of the many, may peripherals to generate signals: in your case, the LEDC PWM generator would work beautifully, for instance.
Who is online
Users browsing this forum: jimmy98035@gmail.com and 93 guests