• AVR Freaks

Harmony Configured SPI Receive Always Returns 0

Author
AnotherEngineer
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2020/08/19 13:23:31
  • Location: 0
  • Status: offline
2020/09/25 06:55:27 (permalink)
4 (1)

Harmony Configured SPI Receive Always Returns 0

I've used the MPLAB Harmony Configurator to setup SERCOM6 as SPI on an ATSAME54P20A. Whenever I use the following Harmony API to send/receive:
 
SERCOM6_SPI_WriteRead(&txBuffer, txSize, &rxBuffer[0], rxSize);
 
The receive buffer always returns all 0's. Now I have verified that the SPI slave device is responding and that signals other than 0 are making it onto the MISO pin.
 
I have attached my SPIConfig.PNG which shows the settings. I've attached SPIConfig2.PNG which shows the SPI Driver and project graph setup.
 
SERCOM6_SPI_Initialize() is called during start-up from SYS_Initialize.
 
The init appears to set the pin properly:
 
    /* Configure Data Out Pin Out , Master Mode,
     * Data In and Pin Out,Data Order and Standby mode if configured
     * and Selection of the Clock Phase and Polarity and Enable the SPI Module
     */
    SERCOM6_REGS->SPIM.SERCOM_CTRLA = SERCOM_SPIM_CTRLA_MODE_SPI_MASTER | SERCOM_SPIM_CTRLA_DOPO_PAD0 | SERCOM_SPIM_CTRLA_DIPO_PAD3 | SERCOM_SPIM_CTRLA_CPOL_IDLE_HIGH | SERCOM_SPIM_CTRLA_CPHA_TRAILING_EDGE | SERCOM_SPIM_CTRLA_DORD_MSB | SERCOM_SPIM_CTRLA_ENABLE_Msk ;


Transmissions are working fine but the receive data is always 0. This has been tried on multiple pieces of hardware as well so I don't believe it is a hardware issue. I've included BusSIgnals.PNG that shows the signals on the MCU pin.
 
Is there a configuration I am overlooking? A bug in the framework? Some errata that I'm overlooking?
 
Guidance on how to resolve this would be greatly appreciated.

Attached Image(s)

#1

1 Reply Related Threads

    AnotherEngineer
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2020/08/19 13:23:31
    • Location: 0
    • Status: offline
    Re: Harmony Configured SPI Receive Always Returns 0 2020/09/25 09:11:55 (permalink)
    0
    Well issue solved miraculously on it's own. I set a break point in the SERCOM6_SPI_InterruptHandler in plib_sercom6_spi.c at the receivedData = .... as shown below:
     
           if((SERCOM6_REGS->SPIM.SERCOM_INTFLAG & SERCOM_SPIM_INTFLAG_RXC_Msk) == SERCOM_SPIM_INTFLAG_RXC_Msk)
            {
                receivedData =  SERCOM6_REGS->SPIM.SERCOM_DATA;

                if(sercom6SPIObj.rxCount < sercom6SPIObj.rxSize)
    ....
     
       I then used the IoView to watch the incoming data, monitored it as it passed through to the buffer and then ever since it has worked in this debug session.
      
    #2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5