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.

CC2530ZNP SPI Transport not sending data to application processor

Other Parts Discussed in Thread: Z-STACK, CC2530

Hi,

I am using Z stack Energy 1.1.0 installed and i have flashed cc2530 with C:\Texas Instruments\Z-Stack Energy 1.1.0\Projects\zstack\ZAP\ZNP-HexFiles\CC2530ZNP-Pro.hex 

-Configured CFG0 and CFG1 both high on CC2530  for enabling SPI trasport and 32khz clock presenace                                         -application processor configured SPI as master and cc2530 as slave, MSB, Mode0, 4Mhz

Now, following power up procedure at shown in CC2530ZNP Interface Specification.pdf page 17.

My problem in receving this SYS_RESET_IND. as explain below"

"6. Application processor receives the SYS_RESET_IND message using the POLL command. When SPI transport is used CC2530 will set SRDY low to indicate the message is available and the application processor should retrieve the message.
7. The application processor receives the SYS_RESET_IND message."

After power up application processor continuously polling for SRDY to go LOW, and I got LOW during polling and i received data as 00 00 00 00. I only receive these zeros and if i am not waiting for SRDY to low and if i try to read SPI data on buffer i got random garbage values. As i should have  

                                                                                                                 

  • As i should have 06 41 80 01 02 00 02 05 01.
  • After reading out 00 00 00 00, then see if SRDY is asserted. If so then try reading the buffer again with POLL, and you should get the SYS_RESET_IND message. Sometimes the first message is all zeroes.
  • Hi Derek,

    Thanks for your kind reply. As on power on reset procedure i found for some time SRDY kept "LOW" then it goes to "HIGH"

    During this time i am reading //*  data = SPI.transfer(0x00)  *// to read data from SPI using arduino Mega. I have attached screen shot.

    void initCC2530(void)
    {
    //SPI.end();
    //step3 initialize SPI:
    Serial.println("initCC2530");
    digitalWrite(RESET_N, LOW); //step1
    digitalWrite(CFG01Pin, HIGH); //step2
    digitalWrite(CFG00Pin, HIGH); //step2
    SPI.begin();//step3 initialize SPI:
    digitalWrite(RESET_N, HIGH); //step4 //Step 5
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    //Serial.println(SPI.transfer(0x00));
    // Serial.println(SPI.transfer(0x00));
    //Serial.println(SPI.transfer(0x00));
    //Serial.println(SPI.transfer(0x00));
    //Serial.println(SPI.transfer(0x00));
    }

    void loop()
    {
    REST_READ();
    delay(5000);
    while(true){
    if(digitalRead(SReadyPin) == LOW)
    {
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    Serial.println(SPI.transfer(0x00));
    }
    if (Serial.available() > 0) {
    inByte = Serial.read();
    if (inByte == 48)
    {
    initCC2530();
    }
    if (inByte == 49)
    {
    REST_READ();
    }
    if(inByte == 50)
    {
    SYS_SREQ();
    }

    }
    }
    }

  • i was reviewing zap_phy_spi.c

    * @fn spiSREQ
    *
    * @brief This function effects a synchronous transaction with the ZNP slave
    * according to the RPC protocol for the SREQ.
    *
    * input parameters
    *
    * @param port - Port Id corresponding to the ZNP to which to send the message.
    * @param pBuf - Pointer to the buffer to Tx across the SPI.
    *
    * output parameters
    *
    * @param pBuf - Pointer to the data received across the SPI.
    *
    * @return SUCCESS or FAILURE.

     here it says portID for each znp module
    does we need to give it to CC2530 ?

  • You can refer to the discussion at e2e.ti.com/.../884349
  • Hi,

    For SPI delay for extint from bootloader is in millseconds, and it doesn't make any sence for my problem.

    as i am waiting more than that. You can see i am getting data but it is not in correct form as it should be.

    Kindly suggest more precise description about SPI interface. TO correctly decode from it.

    Huhhhh..It is really frustrating.

  • For more information about the ZNP SPI interface, check out Anaren's website. They make a module that uses ZNP. There's a ton of information on there.

    www.anaren.com/.../Main_Page

    Logic Analyzer traces:

    www.anaren.com/.../Category:Logic_Analyzer_Trace

  • I check the logic analyser Trace, but it is all the same as described in ti documents.

    It's really frustrating experience with TI and Zigbee Devices... It's really Simply Not working for SPI transport.

    I changed my microcntroller from Arduino to PIC18F24k22,  There is correct SRDY goes LOW and HIGH at sending bytes to and and in responce i got 00 00 00 00 00 00 00 00 00. Nothing else than that...CFG0 and CFG1 both are high.  

    I am attaching my code here. Please someone please help me in that.

    #define USE_OR_MASKS
    #include <p18cxxx.h>
    #include "spi.h"
    //-----variables-------------------------
    unsigned char SPI_POLL[4]={0x00,0x00,0x00,0x00};
    unsigned char RESET_IND_CMD[4]={0x01,0x41,0x00,0x00};
    unsigned char *SPI_Recv;
    unsigned char serial_data=0x00;
    unsigned char temp; 
    unsigned char ptemp;
    unsigned char sync_mode=0;
    unsigned char bus_mode=0;
    unsigned char smp_phase=0;
    int poll_sent=0;
    int poll_sent1=1;
    unsigned char rDATA[21]="HI This is Dhaval";
    //------control pin------------------
    //#define RESET_N    LATAbits.LATA0    
    #define MRDY  LATAbits.LATA5  //output
    #define SRDY  PORTAbits.RA4   //input
    #define CS LATAbits.LATA3       //output 
    #define confSRDY TRISAbits.TRISA4  
    #define confMRDY TRISAbits.TRISA5  
    #define confCS TRISAbits.TRISA3
     
    //----LED------------------------------
    #define LD1  LATCbits.LATC1       // RC1
    #define LD2  LATCbits.LATC2       // RC2
    #define LD3  LATBbits.LATB2  //RB2
    #define LED1_on()  LD1 = 1;        // High
    #define LED2_on()  LD2 = 1;       // High
    #define LED3_on()  LD3 = 1;       // High
    #define LED1_off()   LD1 = 0;    // Low
    #define LED2_off()   LD2 = 0;   // Low 
    #define LED3_off()   LD3 = 0;   // Low 
    //------SPI------------------------------
    //#define sync_mode  SPI_FOSC_4  //Configure SPI MASTER  module to transmit in master mode 
    //#define bus_mode  MODE_00
    //#define smp_phase  SMPEND 
    //#define SB_FORCE_BOOT   0x10
    //#define SB_FORCE_RUN    (SB_FORCE_BOOT ^ 0xFF)
    //****************** SPI MASTER *******************************
    //**************************************************************
    unsigned int i=0;
    #define FREQ 16000000    // Frequency = 16MHz
    #define baud 9600
    #define spbrg_value (((FREQ/64)/baud)-1)    // Refer to the formula for Baud rate calculation in Description tab
    void delayzz(int tms)            // Timer 
    {	int i, j;
    	for(i=0;i<tms;i++)
         {
    		for(j=0;j<2;j++) 
             {       /* Well its Just a Timer */   }}}
    void serialInit(void)
    {  
        TRISCbits.TRISC1 = 0;
        TRISCbits.TRISC2 = 0;
        TRISCbits.TRISC6 = 1;  //TX
        TRISCbits.TRISC7 = 1;  //RX
        PMD0bits.UART1MD = 0;
        SPBRG1=spbrg_value;                                // Fill the SPBRG register to set the Baud Rate
        RCSTA1bits.SPEN=1;                                     // To activate Serial port (TX and RX pins)
        TXSTA1bits.TXEN=1;                                     // To enable transmission
        TXSTA1bits.SYNC=0;
        RCSTA1bits.CREN=1;                                     // To enable continuous reception
        LED1_on();       //  Glow led 1
    	LED2_on();      // OFF  led 2 
    }
    void tx_data(unsigned char data1)
    {
        TXREG1=data1;                                     // Store data in Transmit register
        while(PIR1bits.TX1IF==0);                             // Wait until TXIF gets low
    }
    void txS(unsigned char *trdptr, unsigned int tlength)
    {
      unsigned char ttemp;
      while(tlength)                // stay in loop until length = 0
      {
        ttemp = *trdptr++;
        tx_data(ttemp);
        tlength--;
        delayzz(1000); 
      }  
    }
    unsigned char rx_data(void)
    {
        while(PIR1bits.RC1IF==0);                            // Wait until RCIF gets low
        return RCREG1;                                   // Retrieve data from reception register
    }
    int srdy1H0L(void)
    {  
       unsigned char test1;
       confSRDY=1;  //as pinput SRDY  PORTAbits.RA4   //input
       test1 = 0xFF&PORTA;
       test1 = 0x10&test1;  // 0 0 0 1  0 0 0 0
       if(test1 == 0x10) return 1;
       return 0;
    }
    
    int srdyLOW(void)
    {
     if(!srdy1H0L()) return 1;
      return 0;
    }
    int srdyHIGH(void)
    {
      if(srdy1H0L()) return 1;
      return 0;
    }
    void OpenSPIX(unsigned char sync_mode1, unsigned char bus_mode1, unsigned char smp_phase1)
    {
      TRISCbits.TRISC3 = 0;       // define clock pin as output SCLK
      TRISCbits.TRISC4 = 1;       // define SDI pin as input  //MOSI	
      TRISCbits.TRISC5 = 0;       // define SDO pin as output  //MISO
      confCS = 0; //CS as output
      
      SSP1ADD = 0x27;  //0c 27 09
      SSP1STAT &= 0x3F;                // power on state 
      SSP1CON1 = 0x00;                 // power on state         
      SSP1CON1bits.SSPM0 = 0;
      SSP1CON1bits.SSPM1 = 1;   // select serial mode SYNC_MODe Fosc_4=16Mhz/4=4 Mhz
      SSP1CON1bits.SSPM2 = 0;
      SSP1CON1bits.SSPM3 = 0;
      PMD1bits.MSSP1MD=0;
      SSP1CON1bits.SSPEN =1;;   // enable synchronous serial port 
      SSP1CON1bits.CKP = 0;     //clock polarity CPOL=0, CKP=0         
      SSP1STATbits.SMP=1;      //sample phase  at end
      SSP1STATbits.CKE = 1;    // data transmitted on falling edge, active to idle
    }
    
    
    
    void initCC2530(void)
    {   
        CloseSPI();	
        PMD1bits.MSSP1MD=0;
        confSRDY=1;     //SRDY
        confMRDY=0;     //MRDY LATCbits.LATC6
        confCS=0;  //CS as output		      // Turn off SPI modules  if was previosly on 
        OpenSPIX(SPI_FOSC_16,MODE_10,SMPMID); 
       // poll_sent=1;
    }
    
    //------------------------------------------------------------
    //
    //      POLL CMD
    //
    //------------------------------------------------------------
    int POLL_CMD(void)
    {  
      unsigned char *wrptr; 
      int p=0;
       tx_data('a');
     MRDY=0; 
     CS=0;
     // poll_sent = 0;
    if(poll_sent == 0)
    {
     if(!PORTAbits.RA4)
      {  
          while(WriteSPI(0x00));
          while(WriteSPI(0x00));
          while(WriteSPI(0x00));
          tx_data('b');
          //while(WriteSPI(0x00));
          delayzz(100);
          poll_sent=1; 
          //CS=1;
      }  
    }
    if(poll_sent == 1)
    {
       if(PORTAbits.RA4)
        {  
           //CS=0;
           rDATA[0] = ReadSPI();
           delayzz(100);   
           rDATA[1] = ReadSPI();
           delayzz(100);   
           rDATA[2] = ReadSPI();
           delayzz(100);   
           rDATA[3] = ReadSPI();
           delayzz(100);   
           rDATA[4] = ReadSPI();
           delayzz(100);   
           rDATA[5] = ReadSPI();
           delayzz(100);   
           rDATA[6] = ReadSPI();
           delayzz(100);   
           rDATA[7] = ReadSPI();
           delayzz(100);   
           rDATA[8] = ReadSPI();
           delayzz(100);   
           CS=1;
           MRDY=1;
           poll_sent =0;
           delayzz(1000);
           tx_data('c');
           txS(rDATA,0x09);
           delayzz(1000);
           poll_sent1=0;
           return 1;    
        }
       return 0;
     }
    }
    int SYS_VER(void)
    {  
      unsigned char *wrptr; 
      int p=0;
       tx_data('d');
     MRDY=0; 
     CS=0;
     // poll_sent = 0;
    if(poll_sent1 == 0)
    {
     if(!PORTAbits.RA4)
      {  
          while(WriteSPI(0x00));
          while(WriteSPI(0x21));
          while(WriteSPI(0x02));
          tx_data('e');
          //while(WriteSPI(0x00));
          delayzz(100);
          poll_sent1=1; 
          //CS=1;
      }  
    }
    if(poll_sent1 == 1)
    {
       if(PORTAbits.RA4)
        {  
           //CS=0;
           rDATA[0] = ReadSPI();
           delayzz(100);   
           rDATA[1] = ReadSPI();
           delayzz(100);   
           rDATA[2] = ReadSPI();
           delayzz(100);   
           rDATA[3] = ReadSPI();
           delayzz(100);   
           rDATA[4] = ReadSPI();
           delayzz(100);   
           rDATA[5] = ReadSPI();
           delayzz(100);   
           rDATA[6] = ReadSPI();
           delayzz(100);   
           rDATA[7] = ReadSPI();
           delayzz(100);   
           rDATA[8] = ReadSPI();
           delayzz(100);   
           CS=1;
           MRDY=1;
           poll_sent1 =0;
           delayzz(1000);
           tx_data('f');
           txS(rDATA,0x09);
           delayzz(1000);
           //poll_sent=0;
           return 1;    
        }
       return 0;
     }
    }
    
    //----------------------------------------------------------------
    //
    //      MAIN 
    //
    //-----------------------------------------------------------------
    void main(void)
    {
       int w=0;
       int x=0;
       int k=0;
       serialInit();
       	for(k=0;k<=10;k++)
    	{
       		delayzz(1000);
            LED1_on();       
      		delayzz(1000);
            LED2_on();
     		delayzz(1000);
            LED1_off();
            LED2_off();
    	}
       initCC2530();   
       poll_sent=0; 
    while(1)
    {   
       //if(srdyHIGH())
       //{
         LED1_on();
         LED2_on();
         delayzz(1000);
         //tx_data('M');
         delayzz(1000);
         POLL_CMD();
         LED1_off();
         LED2_off();
         delayzz(1000);
         delayzz(1000);
         SYS_VER();
       // } 
     }
    }

  • Hello, currently I am also trying to programing for application processor and I have a little mistake like you, can you help me. My email is nguyenphulinh1102@gmail.com. Can you contact to me by my email

    Thank you very much!

  • Which Z-Stack version and HW do you use? Do you use prebuilt ZNP image in Z-Stack or you build ZNP by yourself?
  • I am using UNO ( Arduino) and Version I used is Mesh 1.0.0
  • What CC2530 HW EVB do you use?