Fastest clock generated by GPIO
Posted: Mon Jul 15, 2019 2:10 am
Hello people,
I think a clock 2.66MHz would be too slow which is generated by a code shown below, under the condition of 240MHz CPU.
Q1. Is it too slow?
Q2. If so, could anybody show source code for faster?
Thank you.
void test(void)
{
gpio_set_direction(22, GPIO_MODE_OUTPUT);
gpio_set_direction(23, GPIO_MODE_OUTPUT); // LED
PORT |= (1 << 23);
vTaskDelay(1000 / portTICK_RATE_MS);
PORT &= ~(1 << 23);
portMUX_TYPE mutex = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL(&mutex);
tag_loop:
PORT |= (1 << 22);
PORT &= ~(1 << 22);
goto tag_loop;
portEXIT_CRITICAL(&mutex);
}
void app_main()
{
test();
}
I think a clock 2.66MHz would be too slow which is generated by a code shown below, under the condition of 240MHz CPU.
Q1. Is it too slow?
Q2. If so, could anybody show source code for faster?
Thank you.
void test(void)
{
gpio_set_direction(22, GPIO_MODE_OUTPUT);
gpio_set_direction(23, GPIO_MODE_OUTPUT); // LED
PORT |= (1 << 23);
vTaskDelay(1000 / portTICK_RATE_MS);
PORT &= ~(1 << 23);
portMUX_TYPE mutex = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL(&mutex);
tag_loop:
PORT |= (1 << 22);
PORT &= ~(1 << 22);
goto tag_loop;
portEXIT_CRITICAL(&mutex);
}
void app_main()
{
test();
}