SPI on YRDKRX62N

Hello,

I want to perform SPI communication between YRDKRX62N and a slave. SPI0 can communicate with 4 slaves. However, according to the pin definitions in the library and the attached diagram on the Kit, these slave select pins have been specially configured for modules such as Wifi, LCD, Flash, and SD. But these pins are still available on the Kit, so I wonder if I can use these slave select pins for other slaves that I want to communicate with.

Parents
  • Fortunately, the Kit I am using does not have a WiFi module, so I can use one SS pin (SSL2A_A) for the slave I want to communicate with. However, I am experiencing issues when using DMA in the SPI protocol on channel 0. I am using the Renesas Peripheral Driver Library, and here is my code snippet:

    //Start my code

    uint8_t master_tx1_data[8] = {0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40};

    R_SPI_Create( 0,
                             PDL_SPI_FULL_DUPLEX | PDL_SPI_MODE_SPI_MASTER | PDL_SPI_PIN_A | PDL_SPI_PIN_SSL2_LOW,
                            PDL_SPI_FRAME_1_1,
                            PDL_NO_DATA,
                            2E6 );

    R_SPI_Command( 0,
                                   0,
                                   PDL_SPI_CLOCK_MODE_0 | PDL_SPI_MSB_FIRST | \
                                   PDL_SPI_ASSERT_SSL2 | PDL_SPI_LENGTH_8,
                                   PDL_NO_DATA);

    R_DMAC_Create(1,                                                                            // channel selection
                                 PDL_DMAC_BLOCK | PDL_DMAC_SOURCE_ADDRESS_PLUS    
                                 | PDL_DMAC_DESTINATION_ADDRESS_FIXED | PDL_DMAC_SIZE_8,
                                 PDL_DMAC_TRIGGER_SPI0_TX,                                                    // trigger selection
                                 master_tx1_data,                                                                               // source start address
                                (uint8_t *)&RSPI0.SPDR,                                                                   // destination start address
                                1,                                                                                                        // transfer count
                                8,                                                                                                        // repeat or block size 
                                PDL_NO_DATA,                                                                                // address offset
                                PDL_NO_DATA,                                                                                // source address extended repeat area
                                PDL_NO_DATA,                                                                                // destination address extended repeat area
                                PDL_NO_FUNC,                                                                               // callback function
                                0 );                                                                                                     // interrupt priority level

    R_DMAC_Control ( 1, PDL_DMAC_ENABLE,  PDL_NO_PTR, 
                                 PDL_NO_PTR, PDL_NO_DATA, 
                                 PDL_NO_DATA, PDL_NO_DATA, 
                                 PDL_NO_DATA,  PDL_NO_DATA );


    R_SPI_Transfer( 0,
                               PDL_SPI_DMAC_TRIGGER_ENABLE,
                               PDL_NO_PTR, //transmit data start address
                               PDL_NO_PTR,
                               PDL_NO_DATA,
                               PDL_NO_FUNC,
                               0 );

    //End

    Help me check why this code is not functioning properly. 

  • Hello John,

    Can you please tell more about what you mean by "not functioning properly"?

    This would be really helpful to understand what exactly happens there.

    Kind regards,

    Sergey

    If this response, or one provided by another user, answers your question, please verify the answer. Thank you!

    Renesas Engineering Community Moderator
    https://community.renesas.com/
    https://academy.renesas.com/
    https://en-support.renesas.com/knowledgeBase/

  • I tried debugging the attached program. I examined the assembly code, and when it reached the line of code "RSPI_Transfer()", the program entered into an infinite loop and couldn't exit.

    This is the SPI0 and DMA register before executing the 'RSPI_Transfer()' line of code.

    This is the SPI0 and DMA register after executing the 'RSPI_Transfer()' line of code.

    I don't know what the problem I'm facing is. Could you help me check where I might have made a mistake?

Reply
  • I tried debugging the attached program. I examined the assembly code, and when it reached the line of code "RSPI_Transfer()", the program entered into an infinite loop and couldn't exit.

    This is the SPI0 and DMA register before executing the 'RSPI_Transfer()' line of code.

    This is the SPI0 and DMA register after executing the 'RSPI_Transfer()' line of code.

    I don't know what the problem I'm facing is. Could you help me check where I might have made a mistake?

Children