SPI signals not

I have created a simple SPI project for the S7G2-SK consisting of 2 SPI devices on top of sf_spi.

The first device is on r_sci_spi channel 0 with sf_spi SS configured for P103.  I am not able to see any activity at all on PMODA P100,1,2,3 (MOSI/MISO/CK/SS).  I have checked the peripheral configuration SCI0 on the Pins tab and things seem to be set right.

The second device is on r_sci_spi channel 1 with sf_spi_ss configured for P511.  But I have configured the peripheral SCI9 for Simple SPI operation which assigns the SPI signals to P202,3,4,5.  I am not able to see any activity on these pins, but I am able to see the SS go on P511.

What could I be doing wrong?  Am I configuring things properly?

I could upload a project if that helps.

Also, can you point me to something written on the DTC Driver for Transmission/Reception.  Not sure how to use this or if I want/need it.

Thanks,

Rick

 

  • Hi Rick,

    Have you called the open API for these instances? Does it return SSP_SUCCES?

    As you noted, the second device is on SCI channel 1, however you've configured SCI channel 9 - make sure you use the same channel in the module and pin configuration.

    In the framework module, there is a setting Chip Select Active Level - set it to Low/High as needed.

    DTC transfer drivers might help you if it's necessary to save CPU load. When using with SPI framework/driver, there are some restrictions, you can find more in the SSP User's Manual: User Guides > HAL Layer > SPI Driver > SPI Data Transfer using DTC (Data Transfer Controller). The SSP User's Manual can be downloaded from Synergy Gallery (synergygallery.renesas.com/.../support, currently the first link on the right).

    Regards,
    adboc
  • In reply to adboc:

    I need help.  I cannot make the SPI driver work on the PMODA of SK-S7G2 board.    I get SSP_ERR_UNSUPPORTED.  If you know the fix, please share with me.  Thank you.

     

    Michael

     

    SSP 1.3.0 version

    E2 Studio 5.4.0.23

    Board: S7G2 SK

     

    Here is the spi driver configuration setup. (ThreadX, Framework, SPI driver)

  • In reply to Mike:

    Hello Rick.
    I had the same problem and at last I discovered that for default the property "transfer size" of g_transfer0 and g_transfer1 is set to 2 and there is not accordance to the call (read and/or write) you have done with "SPI_BIT_WIDTH_8_BITS". You have to set the property transfer size to the value 1 in both g_transfer0 and g_transfer1.
    I hope this helps you.
  • In reply to Lui Luigi:

    Hi Lui,

    Thank you for your quick response!    I checked it right away.    The default value for the property "transfer size" is 4 in my setup.  It cannot be changed because it is locked.    How can I unlock it? Thanks.

    Michael

     

  • In reply to Lui Luigi:

    Hi Lui,

    I removed g_tranfer0 and g_transfer1.   All the transfer size properties in the framework disappear.   Now, I can get SSP_SUCCESS!   But the i2c data is not coming in because the data did not change and device ID is not correct.

    Debug shows SSP_SUCCESS, but the device ID (buf[8]) is not 0xFA (the BMC150 part).   

    I am using PMODA.  It is SPI0.  Does it mean channel 0?  I set my SPI driver channel to 0. Would your setup like this?  Thank you.

    Michael

  • In reply to Mike:

    Hi Michael,

    Would you like to use SPI or I2C on PMODA?

    For I2C you should use a different framework: the I2C Framework Device and configure a slave address in this instance and set the underlying I2C driver to use channel 1 (DTC transfers can be removed). In Pins tab, you should disable SPI0 and SCI0 or set them to use pins different than P1xx. Then enable IIC1, set SDA to P101 and SCL to P100.

    Regards,
    adboc
  • In reply to adboc:

    Hi adboc,

    Thank you for your response.   I want SPI on PMODA. 

    I looked up the schematic for PMODA and pin information.  PMODA turns out to be only a simple spi port.   It is not a SCI port that can be configured as SPI or I2C.

    Here is my current configuration.  (Hope you can see the diagrams)

     

    Dia 1: I have enabled the SPI port.   The port configuration seems correct to me.

     

    Dia 2: I use the correct SPI driver for r_rspi port (SPI0) and set up for channel 0.

    Dia 3: I configure P1_03 for the chip select signal.

    I will use a logic analyzer to see whether the MCU generates correct signal waveform on the port or not.

    Michael

  • In reply to Mike:

    Hi all,

     

    The scope waveform reveals the problem.  All the SPI sequence is only 1 byte long.   The r_spi driver deselects SSL after every 8 clocks.  This seems to be the reason why I don't get any data read.   

    So, the spi port (PMODA pin P1_3/1/0/2) is enabled correctly.   Commands are sent to the spi BC150 sensor.  But, the chip select does not remain low for the data reading portion.   Very interesting.

    Maybe I try to use the sci port (PMODB pin P4_13/11/10/12) with the spi configuration.

     

    Best,

    Michael

     

    1. SSL and SCK

    2. SSL and MOSI

  • In reply to Mike:

    Mike,

    This is normal operation when you use the chip select driven from the RSPI.
    To keep the CS asserted for the entire transfer, you must deselect the slave select SSL0 in the pin configuration for the RSPI channel and configure P103 as GPIO initially High.

    Now in the threads tab, change the SPI Mode property for the r_spi to Clock Synchronous operation. Change the sf_spi properties and set the Chip Select Port to 1 and the Chip Select Pin to 3.

    When you do WriteRead the chip select will stay asserted for the entire operation.

    -Gary
  • In reply to garyj:

    Hi Gary,

    You are right!!!  Now SSL0 stays low with your suggestion.  The only remaining problem is MISO.  It stucks at '1'.  All read data is 0xff.  Would you know why?  

    Thank you so much.  Hope I am getting closer.

    Michael

  • In reply to Mike:

    Hi Gary,

    I unplugged the sensor board. Without the sensor board, MISO pin was gnd! The read data were all zero. So, I realized I need to take care of the other four pins that connect to the senor board. I think that they (not S7G2) are causing the problem.

    I will let you know how it goes tomorrow. I have gotten pretty far today with help from you and others! I appreciate you and other developers making the difference on my progress today! Thank you!!!

    Michael
  • In reply to Mike:

    Hi Mike,

    I'm glad you have made a significant progress.

    Just to clarify, it is possible to use I2C on PMODA, it is also possible to configure any SCI mode (incl. SPI and I2C) on this PMOD. For example IIC on channel 1 or SCI on channel 0 - these ones can be configured to use P1_x pins.

    Regards,
    adboc
  • In reply to garyj:

    Hi Gary,

    Good news!

    I found the real problem.  There is a pull up resistor on the sensor board, but the pull up is not the problem of the read failure.  The problem is caused by the setting on spi clock polarity (CPOL) and clock phase (CPHA).    

    Below diagram is chip ID read.  I have the correct data (0xFA) out.  I realized that the command bit must change at the falling edge of the clock (not the rising edge).

    It is easy to have wrong settings and I did it.   There are four possible settings.  But, only two settings will work to get the correct data out.

    Setting 1: Clock low when idle / Data sampling on odd edge, data variation on even edge.

    Setting 2: Clock high when idle / Data sampling on even edge, data variation on odd edge.

    These two settings will ensure that the command bit changes at the falling clock edge and the data bit is sampled at the rising clock edge.  

     

    Now I am going to try to use PMODB (SCI_spi) instead to read the sensor's data.   Hope it will go smoothly for me.  

     

    Thank you for your wonderful help.  

    Michael

  • In reply to adboc:

    Hi Adboc,

    I finally got simple spi protocol working on PMODA.    Wow.  I did not realize it until I read your reply.

    I took a study of both PMODA and PMODB ports.  There are many possible configurations for SPI or I2C.

    PMODA :

                 P1_2  P1_1   P1_0  P1_3

    SPI0:    RSPCK MOSI  MISO  SSL0   (r_spi)

    SCI0:    SCK    MOSI  MISO  SS       (sci_spi)

    IIC1:     --        SDA    SCL   --         (r_iic)

    SCI0:    --        SDA    SCL   --         (sci_i2c)

     

    PMODB :

                 P4_12  P4_11   P4_10  P4_13

    SPI0:    RSPCK MOSI  MISO  SSL0   (r_spi)

    SCI0:    SCK    MOSI  MISO  SS       (sci_spi)

    SCI0:    --        SDA    SCL   --         (sci_i2c)

     

    I can see that I can use either SPI0 or SCI0 to configure the SPI port on PMODA and PMODB.   I can use IIC1 or SCI0 to configure the I2C port on PMODA while I can use SCI0 only to configure the I2C port on PMODA.

     

    Question 1: Now, can I use SCI0 for both PMODA and PMODB if I have 2 SPI devices?  I can have two SPI drivers that connect to SCI channel 0.  But, their chip select signals will be different.   I think that it is yes.    

    Question 2: A similar question for I2C.   I think that it is probably Yes.   Because the device address for each device is unique.  I can have two I2C drivers with two different slave device address, but I set to the same SCI channel 0.

    Look forward to hear what you think.  In the meantime, I try to configure for all the possible pin configuration for SPI and I2C.  It will be fun.

     

    Thank you so much.  I learned a lot from your tip.

    Michael

  • In reply to Mike:

    Hi Michael,

    Without pin reconfiguration at runtime, it will not be possible to use SCI0 on both PMODA and PMODB, since they use different set of pins (P1 and P4 ports). If you would like to use two SPI devices on both PMODs, I suggest using SCI0 and SPI0.

    Similarly for I2C, you should configure SCI0 and IIC1.

    Regards,
    adboc