Page 1 of 1

External Interrupts

Posted: Mon Apr 27, 2015 7:45 pm
by GianlucaLaManna
Hello,
I have this ultrasonic sensor(HY-SRF05 blue).
I have to manage 3 of this sensors simultaneously. I have the board SPC560P-DISP.

My code is this:

Code: Select all

palClearPad(PORT_A, TRIG_PIN);
osalThreadSleepMicroseconds(2);
palSetPad(PORT_A, TRIG_PIN);
osalThreadSleepMicroseconds(10);
palClearPad(PORT_A, TRIG_PIN);


The datasheet says use a pulse at 10us and then measure Rising Edge / Falling Edge. But how?
Maybe with some interrupt. But I don't know how works on my board.
I'm using this code for my handle interruption:

Code: Select all

#define INTERRUPT vector43
 
OSAL_IRQ_HANDLER(INTERRUPT) {
  OSAL_IRQ_PROLOGUE();
 
  OSAL_IRQ_EPILOGUE();
}

I don't know if it's correct.

Best regards,
Gianluca.

Re: External Interrupts

Posted: Mon Apr 27, 2015 9:58 pm
by Giovanni
Hi,

All sleep functions round the specified time to the rick resolution. System tick is 1mS so you can't sleep 10 microseconds using those functions. For such small delays you need to use a software loop delays or a physical timer.

If you need to measure pulses then you may use the ICU driver.

Giovanni

Re: External Interrupts

Posted: Tue Apr 28, 2015 8:29 am
by GianlucaLaManna
Ok, I will try with ICU drivers temporarily.
Thanks.

Best regards,
Gianluca.