Fastest clock generated by GPIO

whoyoume
Posts: 23
Joined: Fri Sep 07, 2018 2:42 am

Fastest clock generated by GPIO

Postby whoyoume » 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();
}

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Fastest clock generated by GPIO

Postby WiFive » Mon Jul 15, 2019 2:44 am

There are many topics about this, for a clock you can use ledc. If you are trying to do something else you can use rmt, ulp, or high level ints.

username
Posts: 539
Joined: Thu May 03, 2018 1:18 pm

Re: Fastest clock generated by GPIO

Postby username » Mon Jul 15, 2019 3:03 am

I get 10mhz doing this.

Code: Select all

void app_main()
{
	gpio_pad_select_gpio(BLINK_GPIO);
	gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
	
	
	while (1)
	{
		GPIO.out_w1ts = (1 << BLINK_GPIO);
		GPIO.out_w1tc = (1 << BLINK_GPIO);
	}


}

whoyoume
Posts: 23
Joined: Fri Sep 07, 2018 2:42 am

Re: Fastest clock generated by GPIO

Postby whoyoume » Tue Jul 16, 2019 5:54 pm

Thank you for your advice. I've got 9.908MHz.

Who is online

Users browsing this forum: No registered users and 72 guests