cancel
Showing results for 
Search instead for 
Did you mean: 

Communication via SPI with L6470 in mode daisy chain

jartigas
Associate II
Posted on October 09, 2012 at 10:45

H

ello

I'm trying to

communicate with SPI

from my application

in

C

with two

L6470

configured

in

daisy chain

mode

.

Sending

data but

I get no

response from

the pin DSO of  the first

 

L6470

.

Someone

can tell

me

the steps I should

follow to

,

for example

,

read a record

from both

chips

,

I have very clear

as

CS

signal

must act

in

this case

.

Thanks

in advance

.

#spi-daisychain-l6474-stm32f4
8 REPLIES 8
jartigas
Associate II
Posted on October 10, 2012 at 09:21

Hello

I've

gotten

the second

L6470

send data

by

SDO

.

I'm trying

to

execute the

MOVE

command

and

get

it to move

the engine

for the first

L6470

,

but I can not

make it move

the second

.

Can anyone

tell me

how I should

do to

send the commands

to the second

L6470

?.

Thank you.

jartigas
Associate II
Posted on October 16, 2012 at 10:33

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6dK&d=%2Fa%2F0X0000000bs8%2F77kJB247br0WAv6q2Xp34kem_HMRAh9okSYoKgKorQE&asPdf=false
Enrico Poli
ST Employee
Posted on November 14, 2012 at 17:27

Hello,

I suggest you to check the CS line during the communication.

When N devices are connected in chain, the microcontroller must send N bytes at each communication cycle.

Your code seems ok, but are you sure the dSPIN_Nop and dSPIN_Write_Byte functions do not change the CS line status? In this case you are able to ''talk'' with the first device, but not with the second one and you are able to ''listen'' the second one, but not the first.

Kind Regards

Enrico

jartigas
Associate II
Posted on November 19, 2012 at 16:40

Hello.

Thanks for the reply

.

I have checked

that the functions

dsPIN_Nop and dsPIN_Write_Byte

only set to 0 the

CS

line, so use fflush() function to set it to 1

.

The writing

in

both engines

working properly

me

, but reading not get it to work

.

Regards.

jartigas
Associate II
Posted on November 20, 2012 at 09:57

The result

of reading is

always

0xffff.

jartigas
Associate II
Posted on November 20, 2012 at 10:02

Sorry,

I changed

the function

of

reading on

which I put

above.

The current

is

:

uint32_t dSPIN_Get_Param(uint_8 param, uint_16 niMotor)

{

    uint32_t temp = 0;

    uint32_t temp2 = 0;

    uint32_t rx = 0;

    uint32_t rx2 = 0;

    uint_16 ncI;

    /* Send GetParam operation code to dSPIN */

    if (niMotor==1) {

        temp2 = dSPIN_Write_Byte((uint8_t)(0x00));

        temp = dSPIN_Write_Byte(dSPIN_GET_PARAM | param);

    } else {

        temp2 = dSPIN_Write_Byte(dSPIN_GET_PARAM | param);

        temp = dSPIN_Write_Byte((uint8_t)(0x00));

    }

    fflush (sDrivers.spifd_6470);

    /* MSB which should be 0 */

    temp = temp << 24;

    rx |= temp;

    temp2 = temp2 << 24;

    rx2 |= temp2;

    switch (param)

    {

        case L6470_ABS_POS: ;

        case L6470_MARK: ;

        case L6470_SPEED:

            if (niMotor==1) {

                   temp2 = dSPIN_Write_Byte((uint8_t)(0x00));

                   temp = dSPIN_Write_Byte((uint8_t)(0x00));

            } else {

                   temp2 = dSPIN_Write_Byte((uint8_t)(0x00));

                   temp = dSPIN_Write_Byte((uint8_t)(0x00));

            }

            

            fflush (sDrivers.spifd_6470);

            temp = temp << 16;

            rx |= temp;

            temp2 = temp2 << 16;

            rx2 |= temp2;

        case L6470_ACC: ;

        case L6470_DEC: ;

        case L6470_MAX_SPEED: ;

        case L6470_MIN_SPEED: ;

        case L6470_FS_SPD: ;

        case L6470_INT_SPD: ;

        case L6470_CONFIG: ;

        case L6470_STATUS:

            if (niMotor==1) {

                   temp2 = dSPIN_Write_Byte((uint8_t)(0x00));

                   temp = dSPIN_Write_Byte((uint8_t)(0x00));

            } else {

                   temp2 = dSPIN_Write_Byte((uint8_t)(0x00));

                   temp = dSPIN_Write_Byte((uint8_t)(0x00));

            }

               fflush (sDrivers.spifd_6470);

            temp = temp << 8;

            rx |= temp;

            temp2 = temp2 << 8;

            rx2 |= temp2;

            

        default:

            if (niMotor==1) {

                   temp2 = dSPIN_Write_Byte((uint8_t)(0x00));

                   temp = dSPIN_Write_Byte((uint8_t)(0x00));

            } else {

                   temp2 = dSPIN_Write_Byte((uint8_t)(0x00));

                   temp = dSPIN_Write_Byte((uint8_t)(0x00));

            }

            

               fflush (sDrivers.spifd_6470);

            rx |= temp;

            rx2 |= temp2;

    }

    sDrivers.rx = rx;

    sDrivers.rx2 = rx2;

    

    return rx;

}

The result

of reading is

always

0xffff.

Thanks.

Enrico Poli
ST Employee
Posted on December 05, 2012 at 09:16

Hello,

from my understanding the firmware seems correct. I can only suggest you to check the physical level of the communication in order to verify if there is something wrong in the connections.

Regards

Enrico

poriol
Associate
Posted on November 13, 2014 at 16:29