Skip to main content
gl2
Associate III
April 22, 2015
Solved

UART, I2C, SPI. How to use one of these?

  • April 22, 2015
  • 8 replies
  • 2776 views
Posted on April 22, 2015 at 11:01

Hello,

I have this ultrasonic sensor(HY-SRF05 blue): cf in attachment.

I have to manage 3 of this sensors simultaneously. How? I have the board SPC560P-DISP. In datasheet there's written of to use the I2C interface or UART or SPI. But I don't know how do. There's a documentation? 

Thanks.

Best regards,

Gianluca.

    This topic has been closed for replies.
    Best answer by Erwan YVIN
    Posted on October 14, 2016 at 11:03

    Hello Auhagen ,

    See you an example of the components for I2C Emulation Software

    using to match with LCD Arduino.

    you can take some functions to reintegrate the code in your project

    Anyway, i will push on github the code (I2C SW Components).

    You will be able to contribute.

    Best regards

    Erwan

    ________________

    Attachments :

    i2c_components.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0S7&d=%2Fa%2F0X0000000bZ6%2FJB1fbAUJm2HNNVAaEj2yl6TRKX51srXhbR3tjTxIUYw&asPdf=false

    8 replies

    Erwan YVIN
    ST Employee
    April 22, 2015
    Posted on April 22, 2015 at 13:29

    Hello Gianluca ,

    There is no I2C HW onSPC560P-DISP. we have a project to create some I2C drivers (SW) UART and SPI are existing onSPC560P-DISP For SPI , i do not see MISO and MOSI and CLK on the reference manual of your capter i would use some Threads and some External Interrupts with your board. an External IRQ on the ECHO PIN you need 10us TTL impulse for INPUT. with ARDUINO :

    // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
    digitalWrite(TRIG_PIN, LOW);
    delayMicroseconds(2);
    digitalWrite(TRIG_PIN, HIGH);
    delayMicroseconds(10);
    digitalWrite(TRIG_PIN, LOW);
    duration = pulseIn(ECHO_PIN,HIGH);

    withSPC560P-DISP (SPC5Studio) :

    palClearPad(PORT_A, TRIG_PIN);
    delayTwoMicroSec();
    palSetPad(PORT_A, TRIG_PIN);
    delayTenMicroSec();
    palClearPad(PORT_A, TRIG_PIN);
    // Pulse In To created in your Handler Interruption (Rising Edge / Falling Edge)

    Best regards Erwan
    gl2
    gl2Author
    Associate III
    April 23, 2015
    Posted on April 23, 2015 at 15:53

    Hello Erwan,

    I'm using this code for my handle interruption:

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

    But I don't understand what to put in this function.I know what a interrupt and I know created threads in C. But I don't understand why you should use a interrupt. It'scorrect to use the vector 43? Then, the TRIG_PIN is set in Input mode? And ECHO_PIN? Thanks. Best regards, Gianluca.
    Erwan YVIN
    ST Employee
    April 23, 2015
    Posted on April 23, 2015 at 18:48 Hello Gianluca , vector43 <=> EIRQx should be the ECHO_PIN. Configure Rising Edge & Falling Edge for Interruption and measure (by the tick system) according to your sensor. you measure the time of echo.

    // convert the time (ms) into a distance
    distanceCm = duration / 1 / 2 ;

    Best regards Erwan
    torben
    Associate
    October 10, 2016
    Posted on October 10, 2016 at 15:10

    Hello Erwan,

    is there an i2c software driver available for this microcontroller?

    Thank you in advance!

    Erwan YVIN
    ST Employee
    October 11, 2016
    Posted on October 11, 2016 at 11:43

    Hello Auhagen ,

    Yes , there is SPC560P-DISP I2C SW code.

    we have planned to create a I2C component. (HW & SW)

    i will send you some beta source code asap used for students projects compliant for LCD components.

            Best regards

                        Erwan

    torben
    Associate
    October 11, 2016
    Posted on October 11, 2016 at 16:38

    That would be great. Thank you.

    Best regards

    Torben

    Erwan YVIN
    Erwan YVINBest answer
    ST Employee
    October 14, 2016
    Posted on October 14, 2016 at 11:03

    Hello Auhagen ,

    See you an example of the components for I2C Emulation Software

    using to match with LCD Arduino.

    you can take some functions to reintegrate the code in your project

    Anyway, i will push on github the code (I2C SW Components).

    You will be able to contribute.

    Best regards

    Erwan

    ________________

    Attachments :

    i2c_components.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0S7&d=%2Fa%2F0X0000000bZ6%2FJB1fbAUJm2HNNVAaEj2yl6TRKX51srXhbR3tjTxIUYw&asPdf=false
    torben
    Associate
    November 8, 2016
    Posted on November 08, 2016 at 19:39

    Hello Erwan,

    sorry for taking so long to reply. Unfortunately there are lots of errors when i try write a reply in the forum with the pc at work.

    Every bit of code that you can provide me would be helpful. Anyways, i must finish other components of the firmware first. So it isn't that urgent.

    Best Regards,

    Torben