ULP with ultrasonic sensor HC-SR04 / JSN-SR04T
Posted: Wed Apr 06, 2022 10:42 pm
Hello there, I am looking for advice from users with experience with programming ULP processor on ESP32 board (ESP32-WROOM-32 / ESP32-S).
ESP32 main processor Xtensa will sleep in deep-sleep mode and ULP processor will be operating.
I want to use ESP32 with ultrasonic sensor HC-SR04 or JSN-SR04T.
Both sensors have Trigger and Echo signal.
Trigger is used for sending waves and Echo for their receiving.
In standard program, let's say Arduino Core there is used pulseIn() function that can return number of milliseconds from Echo pin state from LOW to HIGH - when wave was received.
I don't know how to implement that in Assembly for ULP processor, because I haven't use Assembly in my life and it is something totally different for thinking about programming for me. It looks like I can use only RTC_IO pins and RTC_SLOW memory for ULP processor program storage and also for sharing datas between main application and ULP processor.
I have studied ESP-IDF documentation related to ULP processor and its instructions, but I don't know how to create two things:
ESP32 main processor Xtensa will sleep in deep-sleep mode and ULP processor will be operating.
I want to use ESP32 with ultrasonic sensor HC-SR04 or JSN-SR04T.
Both sensors have Trigger and Echo signal.
Trigger is used for sending waves and Echo for their receiving.
In standard program, let's say Arduino Core there is used pulseIn() function that can return number of milliseconds from Echo pin state from LOW to HIGH - when wave was received.
I don't know how to implement that in Assembly for ULP processor, because I haven't use Assembly in my life and it is something totally different for thinking about programming for me. It looks like I can use only RTC_IO pins and RTC_SLOW memory for ULP processor program storage and also for sharing datas between main application and ULP processor.
I have studied ESP-IDF documentation related to ULP processor and its instructions, but I don't know how to create two things:
- How to measure time? From what i see in documentation I can only use ticks for measurement, that means 150k per second? How can I handle this value, when there is just 16-bit register so that is not enough, that's 65535 max value...
- How to wait in program until GPIO read is HIGH?