Skip to main content
ljuarez
Associate
July 26, 2018
Question

L9663-1 PSI5 Transceiver not communicating through SPI

  • July 26, 2018
  • 26 replies
  • 9241 views

We want to use the L9663 PSI5 Transceiver to interface a sensor. A STM32 Discovery board is being used as the SPI master, in mode 1 (CPOL = 0, CPHA = 1). The SPI clock speed is set to 10MHz.

The module configuration is:

/* SPI1 parameter configuration*/

 hspi1.Instance = SPI1;

 hspi1.Init.Mode = SPI_MODE_MASTER;

 hspi1.Init.Direction = SPI_DIRECTION_2LINES;

 hspi1.Init.DataSize = SPI_DATASIZE_8BIT;

 hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;

 hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;

 hspi1.Init.NSS = SPI_NSS_SOFT;

 hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;

 hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;

 hspi1.Init.TIMode = SPI_TIMODE_DISABLE;

 hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

 hspi1.Init.CRCPolynomial = 11;

We are sending 32 bit frames to the device formatted as specified on the datasheet (Frame definition section, pages 84-85) .

However, the IC is not responding to any SPI commands, and the MISO line stays always high. We have verified that the SPI module of the STM32 board functions properly, by interfacing a MCP2515 SPI CAN controller successfully. i.e. getting an SPI response and activity on the MISO line.

We have also verified that the number of clock cycles for each SPI transaction is correct (32 clock cycles as specified on the datasheet, page 87).

The transceiver has been supplied with one of the configurations described in the documentation (page 15), with the following values (all within the operational range):

VB = 12V - Including a 75nF capacitor between the pin and GND

VDD = 5V - Including a 75nF capacitor between the pin and GND

VASSUP = 0V (Charge pump off)

VAS = 7.6V (Using an external regulated voltage)

Included a 75nF capacitor across the pins VINTD and DGND.

Since we are using the exposed pad TQFP32 package, the pad is soldered to a GND plane. All the grounds have been kept electrically shorted, as specified on the datasheet (page 11). The TM pin is also connected to GND.

We have also confirmed that the device is switched on, by measuring the output voltage on the VINTD pin, which is 3.3V when the device is enabled, consuming around 19mA when powered up.

The question:

Could someone please describe why the device is not communicating back on the MISO line?

    This topic has been closed for replies.

    26 replies

    TEvan.3
    Visitor II
    June 4, 2019

    > Does anyone know why my RSTB bit is always set ?

    The manual says the RSTB bit is cleared by "any valid SPI communication". So that might mean your SPI frames aren't valid.

    You really need to see the SPIE, FSR1 and FSR2 bits, but they aren't transmitted until you've sent a command that successfully disables "Address Multiplexing Mode". You can't do that until you can send a proper SPI command, and it looks like you can't at the moment.

    I suggest you construct commands to read SR1, SR2 and SR3 and then decode the results. That should tell you what error bits are set in those registers. You can READ registers with invalid SPI commands - you just can't WRITE them.

    I suggest you do what I did. Send all possible EIGHT variants of every command you send. I mean send the command with the CRC set to 0, 1, 2, 3, 4, 5, 6 and 7. One of them has to be "correct" because the chip will actually obey the command and won't complain.

    Tom

    FRoub
    Associate
    June 6, 2019

    Hi Tom,

    Thanks for your answer.

    The RSTB bit is still set with every spi communication but I can write in every Register and it work.

    For exemple I have change:

    GCR1[14] DIS_ADD_MUX -->address multiplexing disabled.

    GCR1[0] VAS_SEL --> 7.6V and I have mesure the voltage on the VAS pin it change from 5.3V to 7.6V

    CHCNT[10] PVAS_EN --> disabled and then the voltage on the VAS pin is 0V.

    When address multiplexing is disabled and i read register SR1there is no SPI Fault and SPIE FSR1 FSR3 are clear.

    If it help when I read SR3 register then the RSTB bit is not set and SR3[0] is clear too.

    I have already try to change the transceiver but whitout success too.

    Let me know if you have a idea of what it could be it will be great

    @Pasquale D'Argenio​ it would great too if you can tell what is wrong.

    Thanks

    Fabrice

    TEvan.3
    Visitor II
    June 11, 2019

    I've just looked at transactions my software makes with the L9663, and the RSTB bit remains set until I read SR3. This matches:

    > If it help when I read SR3 register then the RSTB bit is not set and SR3[0] is clear too.

    Actually, in my case the STATUS flags on the read of SR3 still has RSTB set (because the chip doesn't know I'm reading SR3 when it sends those Status bits), so the Status bits aren't cleared until the cycle AFTER SR3 is read.

    SR3 has a "RST" bit which is "Cleared upon read". I'd guess the RSTB bit in the Status is connected directly to that bit in SR3. And so I'd expect the only way to clear it is to read SR3.

    The Data Sheet says of the RSTB bit: "It is automatically cleared by any valid SPI communication.".

    So the RST bit isn't doing what the Data Sheet says it should. That means the chip has a design fault as it doesn't match the Specification in the Data Sheet, or the Data Sheet is faulty as it doesn't document what the chip does. Given that SR3[RST] and RSTB are the same thing I'd say the Data Sheet is wrong here.

    Ignore it. The chip does everything else just fine.

    Tom

    Salvatore CANNAVACCIUOLO
    ST Employee
    June 24, 2019

    ​ RSTB bit is cleared after a read access on SR3 register, in case, of course, the IC is no more RST.

    This will be clarified in the next revision of the datasheet, coming soon.

    Tnx a lot for the flag!

    Salvatore Cannavacciuolo

    FRoub
    Associate
    June 18, 2019

    Hi Tom,

    Thanks for your answer. I start again with this communication between the L9663 transceiver and an angular position sensor from AMS. Do you have personnaly a exemple of trames / communication mode that you used the configure the transceiver to communicate with a sensor ? It will be very helpful because I'm a little bit lost.

    My e-mail is fabrice.roubaty@edu.hefr.ch if you have something for me.

    Thanks in advance

    Fabrice

    TEvan.3
    Visitor II
    June 19, 2019

    You can't talk to an unprogrammed AMS chip with the L9663. Give up now if that's what you're trying to do.

    I assume you're looking at something like the AMS AS5172A / AS5172B?

    It won't work until it is programmed. There are standard ways to do that with PSI5, and the L9663 supports those ways very well.

    The AMS doesn't do it that way. It uses a non-standard "UART-over-PSI5" method, which bizarrely modulates the voltage at 38,400 baud downstream, and the current at 38,400 baud upstream. There's no way the L9663 can support that.

    It would have to be programmed in a special adapter, connected to a serial port, usually on a PC, and running at 38400 baud. Once programmed you could receive data from it with a L9663. These things are meant to be programmed by the thousand (or more) using a special rig on the production line of a product.

    AMS detail this programming board in the board User Guide, as a "AS5172 PSI5 Programming Board". If you have one of these you can program the chip, and then talk to it with the L9663.

    All you have to do in that case is to configure a few registers in the L9663 and then preferably have it generate interrupts when the data is ready. Then you read the data back. This is all pretty obvious from reading the L9663 Data Sheet. The hard part is you have to write a lot of support functions to generate and check all the CRCs, the Parity (GCR and other registers) and then functions to read and write specific registers over your SPI controller.

    "Frames and Mode" is a matter of configuring the L9663 with the same number of bits (10 or 16), the high or low bit rate and whether it is using Parity or CRC. When they're matched the L9663 receives the data and makes it available for reading over SPI.

    As for being "lost", I'd recommend getting the PSI5 Standard Documents and then reading them all the way through a few times. Then do the same with the L9663 manual. Keep reading it until it starts making sense. There aren't any shortcuts unless you can get someone to write the code for you targeted to your specific CPU, OS and SPI peripherals.

    Tom

    FRoub
    Associate
    July 2, 2019

    Hi Tom,

    Thanks again for your time. Yes I'm working with the AS5172B.

    I've found somebody who has programmed my sensor like that :

    A20CRC-500/1H

    A: asynchronous

    20: databits

    CRC: Error detection

    500: cycle time in us

    1: number of timeslop per cycle

    H: bit rate189kBps

    I've configure my L9663 like that before end of prograaming

    GCR1 [14]:DIS_ADD_MUX -->address multiplexing disabled. [0]VAS_SEL --> 7.6V and I have mesure the voltage on the VAS pin it change from 5.3V to 7.6V

    CHCNT [1]SYNC pulse disabled [0]PSI1_EN ---> interfaceON

    CH1_CR1 [12] DOUT1 as interrupt output [6...4] 1 time slot [6...4] BR1 189kb/s [0] SYNC1_EN 0 Asynchronous mode

    The rest is filled with default value

    Then a make a end of programming with value 0x1111

    Then page 86 Sensor data reading

    NO SID, payload 20 bits i wrote 0xC8000014 on the mosi line but the miso line receive nothing.

    After that the status register MISO lines are like that :

    SR3 : 0x0C310044

    SR2 : 0x0C280801

    SR1 : 0x0C208002

    Can you have a look and tell me what could be wrong ? You seem to have a lot of experience with psi5.

    Thanks in advance

    Fabrice

    TEvan.3
    Visitor II
    July 3, 2019

    I've never used Asynchronous mode. It should be simpler than Synchronous though.

    First thing to do is to put an oscilloscope on the PAI5 bus and see if the AS5172B is transmitting anything. Then decode a packet manually (by measuring the bits from the oscilloscope) and see if it is sending what you expect, and what you have programmed the L9663 to receive.

    > i wrote 0xC8000014 on the mosi line but the miso line receive nothing.

    You're sending "0xC8000014"? That decodes as "Sensor Data", "Channel 1", "Timeslot 1", "Low Word", and then a CRC. The L9663 should be responding with six Status Bits, a "1", the Channel Bit (you sent), a "0", 20 bits of Sensor Data and then the CRC. You're using Channel 1 and not Channel 0? Are you sure?

    Check those signals with an oscilloscope. It shouldn't be possible to get "nothing" in an SPI transfer. The L9663 should do something.

    I think your SPI Transfer isn't working.

    Tom

    FRoub
    Associate
    July 3, 2019

    I've tried to send something with both channels (0 & 1) also the following trames on the mosi line : (0x88000014 & 0xC8000010) but I still have nothing on the miso line.

    I have tried to mesure the voltage and the current on the PSI5 line 1 with an oscilloscope and a current probe.

    I have a signal like on the figure 17 page 32 at 7.8V but i see nothing with the current probe.

    When I compile my register on the transceiver the current of the transceiver goes from 27mA (default) to 50mA.

    Did I take the right sensor data reading in the figure 29 page 86 , regarding the sensor configuration I mentionned in my last comment?

    And is it true that the figure 28 is only to read the as5172 configuration (do you know what I need to write on the init_buf_id [29...27])?

    Thanks in advance

    Fabrice

    TEvan.3
    Visitor II
    July 3, 2019

    My previous answer had two points in it, but the most important one for this problem was the SECOND one. You have to get the SPI communication working first.

    I assume that you are using the "Figure 27, Page 85" transfers to read and write the registers in the L9663 and they are working fine, yes? And that you can READ register values back with the right values and you're checking the CRCs. That proves your SPI comms is working.

    The only difference between those frames (which I assume work) and the ones in Figure 29 is that the Figure 29 ones start "10xxxx" while the Figure 27 ones start "00xxxx". You should PROVE that with an oscilloscope. Make sure the Data, Clock and Chip Select lines are working. There's no use looking at anything else if this part isn't working.

    It doesn't matter at all WHAT values you're sending on MOSI. The L9663 must reply with the STATUS signals on MISO and a "1" and the Channel Bit. That has to work.

    Maybe you're doing something that is disabling the L9663 chip? Maybe you have a short between the PSI5 bus and some other signals, so that when you see " figure 17 page 32 at 7.8V" then the PSI5 bus coming on shorts to something else on the board and stops the SPI from working. To prove that, after writing whatever you wrote before trying the "Figure 29" ones, try reading some normal register back. If THAT doesn't work then you know that something you've done has stopped the chip from working. Maybe you're resetting the chip somehow? Maybe you've got the 7V doing something nasty and overloading something. You could try 5.3V instead and see if the L9663 keeps working then. Then find out what's wrong.

    What do you mean "I compile my register on the transceiver"? That doesn't make any sense in English. I'm guessing you're writing to a register on the L9663 and then the power taken by that chip goes up. That should be when you write "PSI1_EN" to the "CHCNT" register. That turns the PSI5 bus on. The current then taken on the PSI5 bus should be whatever the Sensor draws (or is programmed to draw).

    > the current of the transceiver goes from 27mA (default) to 50mA

    Measured WHERE? On Vdd or on Vsup, VB, VAS and/or VASSUP? These are all different supplies. VAS should take nothing until you enabled it. The current on Vdd isn't specified anywhere.

    WHEN THE SPI BUS IS WORKING (and not before) you can read returned values from the sensor just using the oscilloscope. Here's what my one looks like. I'm using 5 Volts, a 3 Volt Sync Pulse at 3 kHz with two frames of data being returned. You can see the frames easily here.

    0690X000009YO4pQAG.png

    Tom

    FRoub
    Associate
    July 4, 2019

    Hi Tom,

    I put VAS to 5.2V and disabled the adress multiplexing mode that I forget and it run well.

    I'm checking the value of the register with a sniffer. (Saleae logic analyzer)

    I'm not sure if i'm reading the value the right way.

    I first send the following trames NO SID, payload 20 bits i wrote 0xC8000014 and I read 0x0F3E0006 on the miso line.

    It correspond in one case : page 31 table 6 1F0 Databuffer empty and the lower 10 bits are filled with 0.

    but I also see on page 32 : In both synchronous and asynchronous mode, when a valid data is read, the buffer empty

    code 1F0 is written in the buffer.

    The question is where are the data ? I mesure that with my oscillscope :

    C1 is the voltage on the PSI-5 line

    C2 is the current modulation on the PSI-5 line that I receive back

    C3 is the interrupt line which say for a asynchronous operation : Asynchronous operation:

    The interrupt pin is set to high when the number of received data since the last reading of

    register is as large as the size of the receive buffer. The interrupt pin is set to low when all

    the buffers are empty.

    I try to read UDB1-1...4(because it think UDB1-1...4 is the fifo in asynchronous mode) but the data are read data are filled with 0 (default value of UDB1-1...4).

    Can you help me with this problem ?

    Thanks in advance

    Fabrice

    mahshid.ghaemi
    Visitor II
    July 9, 2019

    ​Hello Fabrice,

    As it is mentioned in data sheet, the contents of UDB1 determine the SYNC pulse length and it doesn't contains the sensor data. In asynchronous mode sensor data registers are working as a FIFO buffer with 6 stage.

    So in order to read the sensor data in asynchronous mode you need to read the sensor data registers through SPI frame as shown in Figure 29 (page 86).

    Please pay attention that SPI communication is out of frame, so you need to send 2 times the read SPI frame. the received MISO of second frame will be the sensor data you expect to read.

    also consider the following procedure for reading sensor data:0690X000009YZsHQAW.png

    Thanks,

    Mahshid