External Interrupts

ChibiOS public support forum for topics related to the STMicroelectronics SPC56x family of automotive micro-controllers.
Post Reply
GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm

External Interrupts

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: External Interrupts

Post 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
GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm

Re: External Interrupts

Post by GianlucaLaManna »

Ok, I will try with ICU drivers temporarily.
Thanks.

Best regards,
Gianluca.
Post Reply