Page 1 of 1

How to detect short circuit?

Posted: Tue Sep 24, 2019 11:03 am
by huguyuge
Hi,

How to detect if some pin is short-circuited? I tried to google `esp idf short circuit` but got nothing useful. Could you please give me some guidance? documents, links, etc.

Thank you

Re: How to detect short circuit?

Posted: Thu Sep 26, 2019 5:06 pm
by KanyeKanye

Code: Select all

void initialise() {
	gpio_pad_select_gpio(PIN_NUM);
	gpio_set_direction(PIN_NUM, GPIO_MODE_INPUT);
	gpio_set_pull_mode(PIN_NUM, GPIO_PULLUP_ONLY);

	xTaskCreatePinnedToCore(&task, "task", 2048, NULL, TASK_PRIORITY, NULL, TASK_CORE_ID);
}
void task(void *pvParameters) {
	TickType_t xLastWakeTime = xTaskGetTickCount();
	while (1) {
		if (gpio_get_level(PIN_NUM) == 0) {
			// ...
		}
		vTaskDelayUntil(&xLastWakeTime, 50 / portTICK_RATE_MS);
	}
}