This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530 SPI Write Sequence - SBL early jump to Application code - zapPhySpiRun

Other Parts Discussed in Thread: CC2530

Hi All,

I am using "ZAP-MSP430-2.5.1" code. I have a doubt regarding cc2530 SPI write from Application processor.

CASE 1:

From zap_phy_spi.c file, SPI write is as follows..

---------------------------------------------------------------------------------------------------------------------------------------------

/**************************************************************************************************
* @fn zapPhySpiRun
*
* @brief This function forces the waiting SBL on the ZNP to run.
*
* input parameters
*
* @param port - Port Id corresponding to the ZNP to run.
*
* output parameters
*
* None.
*
* @return None.
**************************************************************************************************
*/
static void zapPhySpiRun(uint8 port)
{
HalBoardDelay(zapPhySpiDly, FALSE);
while (!HAL_ZNP_SRDY_SET() && HalBoardDelayed())
{
HAL_BOARD_WAIT_MODE();
}

if (HAL_ZNP_SRDY_SET())
{
uint8 ch = SB_FORCE_RUN;

HAL_ZNP_MRDY_SET(); // MRDY must be set before talking to the slave.
HalSpiWrite(port, &ch, 1);
HAL_ZNP_MRDY_CLR(); // MRDY must be cleared before SBL will clear SRDY.
(void)getSRDY2(port);
}
}

---------------------------------------------------------------------------------------------------------------------------------------------

1. We are waiting for SRDY to become HIGH.

2. We are making MRDY to HIGH.

3. Write 0x7 to cc2530.

4. We are clearing MRDY.

5. We are waiting for SRDY to clear.

CASE 2:

From CC2530 interface Spec, the sequence is as follows,

1. We are waiting for SRDY to become LOW.

2. We are making MRDY to LOW.

3. Write POLL command to cc2530.

4. Wait for SRDY to become HIGH.

5. Read from CC2530

6. We are making MRDY HIGH.

From the above two cases,

  • in case-1 we are writing to CC2530 when SRDY is HIGH as per code.
  • in case-2 we are waiting for SRDY to become LOW, to write to CC2530.
Which is the correct method?
Regards & Thanks,
Anil.


  • Hello Anil, zapPhySpiRun() function is called to get the ZNP out from Bootloader mode and force it to the application code. To do this the ZAP Application code waits until the SRDY line goes low, this is how the bootloader code indicates that it is ready to receive command from the host to either put it in bootloader mode where it can receive new image or force ZNP out of bootloader mode and jump to ZNP application code. 

    The interpretation of the HAL_ZNP_SRDY_SET() is this is one when SRDY is low. So in your description in case 1. We still wait for SRDY to get low. When SRDY is low we set MRDY low and send the command. So, once the HAL_ZNP_SRDY_SET() = 1 (or when SRDY is low) the ZAP sends the force to application code command and the ZNP application code starts getting executed. Once in application code, you can refer to the ZNP Interface Specification document for how to communicate with the ZNP. You can also see the ZNP bootloader code at C:\Texas Instruments\ZStack-CC2530-2.5.1a\Projects\zstack\Utilities\BootLoad\CC2530ZNP

    Hope this clarifies. Regards

  • Hi Suyash Jain,

    Ok we can not use this  for Software reset. is it correct?

    After ZNP application code starts getting executed, -  We will receive a reset indication from CC2530, we have to poll to read this response. Is is correct?

    HAL_ZNP_SRDY_SET() = 1 (or when SRDY is low) --- > this was really confusing. it is clarified now, thanks for this.

    Thanks & Regards

    Anil.


  • Hello Anil,

    Are you trying to Reset the ZNP from the ZAP side, then you can use the function call znpSystemReset() with the parameter either being ZNP_RESET_HARD (watch dog reset) or ZNP_RESET_SOFT (jump to reset vector). 

    Then the ZAP will use the zapPhySpiRun() to put ZNP out of bootloader mode and in the application mode. After the ZNP jumps to application code you will recieve the reset indication from the ZNP. And you will poll the ZNP for this message. 

    Hope this clarifies. Thanks

  • Hi Suyash,

    If we use physical reset line connected to CC2530 for resetting, is it required to do zapPhySpiRun() for receiving reset indication? 

    Thanks & Regards,

    Anil.

  • Hello Anil, To receive reset indication message ZNP needs to jump to application code. Which can happen in two ways after reset...ZNP bootloader if configured for SPI mode waits for about 1 minute for host to either put it in the bootload mode or ask it to jump to application code. Which is done by sending a special character. Calling zapPhySpiRun() will cause the ZNP bootloader to jump to application code sooner than one minute and you will receive the Reset Indication message sooner or you can choose to not use this and wait a minute until the timer expires on the bootloader and it does a jump to the application code. Hope this clarifies the operation. Regards. 

  • Thanks Suyash.

    11. Forcing boot-mode or early jump to Application code.

           3. If the Application code is valid, wait for the bus master to send a 0xF8 to force boot-mode or an 0x07 to force an immediate jump to the Application code.
                        a. The default wait for UART and USB transport is 1 minute.
                        b. The default wait for SPI is 50 milliseconds.

    I have tested this and working.