I try to generate 100 hz PWM and set duty cycle, that is working.
Unfortunitly, the device need to check the signal on specific point, so method 1 may be the right way.
Would someone know how to make a short delay of microseconds?
See void bleapputils_delayUs(UINT32 delay) in bleapputils.h, where parameter delay is in microseconds you want to delay. Note that this is a busy wait (spinning in a loop). If the device takes an interrupt while in this loop, then it may run longer than delay microseconds. Make sure that this is not over a few milliseconds (thumb rule is ~10mS; use timers for longer delays). PWM is really the best option.
When I set the scenarios with program as follows:
gpio_setPinOutput to GPIO_PIN_OUTPUT_HIGH
adc_readVoltage read adc pin value
gpio_setPinOutput to GPIO_PIN_OUTPUT_LOW
then I found on OSC, the duration of the pulse is always around 600 us.
Is that additional delay caused by ADC function? and how to estimate the ADC delay?
Move bleapputils_delayUs(300); outside your GPIO toggle. That is the ADC sampling delay, which includes turning on the ADC, sampling the input and turning off the ADC.