External Interrupts

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

External Interrupts

Postby GianlucaLaManna » Mon Apr 27, 2015 7:45 pm

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: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: External Interrupts

Postby Giovanni » Mon Apr 27, 2015 9:58 pm

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
Location: Palermo, Italy

Re: External Interrupts

Postby GianlucaLaManna » Tue Apr 28, 2015 8:29 am

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

Best regards,
Gianluca.


Return to “SPC56x Support”

Who is online

Users browsing this forum: No registered users and 1 guest