AnsweredAssumed Answered

PN7462 SPI Communication

Question asked by Amol Borase on Mar 14, 2019
Latest reply on Apr 1, 2019 by Amol Borase

Dear all,

We are working on PN7462 based product. For development we are using MCUXpresso IDE v10.2.0_759, Debugger LPC Link-2 and software example PN7462AU_ex_phExHif of version v05.07.01 with some modification to implement SPI as a Slave and other microcontroller we are using as a Master.

when we are sending data from Master to PN7462, So in slave side sometimes it receives 0, otherwise it goes into function "Wait for Event" and on MISO pin of Slave. We have tried continuously sending single byte data with small delay in between two consecutive requests.

We have connected SPI pins of slave like this (As per document UM10858):
ATX_A - NSS
ATX_B - MOSI
ATX_C - MISO
ATX_D - SCK

 

Code :

int main(void)
{
      uint8_t bCount, pwLength=0,eStatus=0,bHifSelection=0;

 

      phFlashBoot_Main();

      bHifSelection = PH_REG_GET_FIELD(PCR_SYS_REG,HIF_SELECTION);

 

      /** Configure IRQ and Data ready ping to LOW on bootup*/
      // PH_REG_CLEAR_BIT(PCR_PADOUT_REG, PADOUT_IRQ);
      // PH_REG_SET_BIT(PCR_PADOUT_REG,PADOUT_IRQ);

 

      // /** Configure the Data Ready pin as OUTPUT */
      // PH_REG_SET_BITN(PCR_PADGPIO1_REG,
      // PCR_PADGPIO1_REG_GPIO1_EN_OUT_POS);

 

      // /** De-Assert the Data Ready pin.*/
      // PH_REG_CLEAR_BIT(PCR_PADOUT_REG, PADOUT_GPIO1);

      /*Configuring GPIO's 4,5,6,7,8 as Inputs*/
      // for(bCount = 4 ; bCount < 9 ;bCount ++)
      // {
      // phhalPcr_ConfigPuPd(bCount,false,true);
      // phhalPcr_ConfigInput(bCount,true,false,false,false,true,false);
      // }

      /* Create the Event group for HIF transactions */
      gphExHif_Hw_HifEvents = phRtos_EventGroupCreate();

      /* Execute the Hif Application */
      phExHif_HifTask();

      return 0;
}

 

static void phExHif_HifTask(void)

{
      uint16_t wLength;
      phStatus_t eStatus;
      uint8_t bCommChannel = 2,temp[256]={0},i=0;
      uint8_t bHifInterface = 2;
      gphExHif_Hw_Ct_Init = false;

 

      phhalPcr_ConfigOutput(4, true,false);
      phhalPcr_ConfigOutput(5, true,false);
      // if ((PH_EXHIF_HW_GET_GPIO_VAL(PH_EXHIF_HW_GPIO_IN_PORT_L)
      // | PH_EXHIF_HW_GET_GPIO_VAL(PH_EXHIF_HW_GPIO_IN_PORT_H))) {
      // LOG_TXT("Waiting for activity on HIF SEL PINS\n");
      // }

      /* Used for synchronisation between Master(LPC1769) and Slave(PN7462AU).
      * Wait till all the Ingress GPIO ports go LOW
      */
      // while ((PH_EXHIF_HW_GET_GPIO_VAL(PH_EXHIF_HW_GPIO_IN_PORT_L)
      // | PH_EXHIF_HW_GET_GPIO_VAL(PH_EXHIF_HW_GPIO_IN_PORT_H)));

 

      bHifInterface = phExHif_Hw_InPort_Init();

 

      while (1)
      {

            eStatus = PH_ERR_SUCCESS;

            // phLED_SetStatus(LED_B);
            /** Read the Hif-Interface Gpio configs and Wait until Ingress ports NOT Equal to Zero */
            // while (!(PH_EXHIF_HW_GET_GPIO_VAL(PH_EXHIF_HW_GPIO_IN_PORT_L)
            // | PH_EXHIF_HW_GET_GPIO_VAL(PH_EXHIF_HW_GPIO_IN_PORT_H)));

            // PH_HAL_GPIO_SETGPIOVAL(4,true);
            // for(i=0;i<0xFFF;i++);
            // PH_HAL_GPIO_SETGPIOVAL(4,false);

         do

         {
                 /** Initialize the Hif hardware. */

                 /** OutPort Initialization */
                // bCommChannel = phExHif_Hw_OutPort_Init();

                // PH_REG_SET_BIT(PCR_PADOUT_REG, PADOUT_GPIO1);

               /** Receive data over the HIF interface */
               eStatus = phExHif_Hw_HostInterface_Receive(&wLength);

               if(gphExHif_Hw_RxBuffer[0]==0x5A)
               {
                     PH_HAL_GPIO_SETGPIOVAL(4,true);
                     // temp[i++] = gphExHif_Hw_RxBuffer[0];
               }

 

               TxBuffer[0] = 0xAB;
               wLength = 1;

 

/** Forward the received packets to selected communication channels. */


            eStatus = phExHif_Hw_Transmit(bCommChannel, bHifInterface, wLength,(uint32_t *) TxBuffer);

            if (eStatus != PH_ERR_SUCCESS)
            {
                  PH_HAL_GPIO_SETGPIOVAL(5,true);
            }

            // /** Output Port De-Initialization */
            eStatus = phExHif_Hw_DeInit(bCommChannel);

            PH_HAL_GPIO_SETGPIOVAL(5,false);
            PH_HAL_GPIO_SETGPIOVAL(4,false);
            /** De-Assert the Data Ready pin for synchronization. */
            // PH_REG_CLEAR_BIT(PCR_PADOUT_REG, PADOUT_GPIO1);

            /** For synchronization,Wait till all the Ingress GPIO ports go LOW to ensure a transaction is complete */
            // while ((PH_EXHIF_HW_GET_GPIO_VAL(PH_EXHIF_HW_GPIO_IN_PORT_L)
            // | PH_EXHIF_HW_GET_GPIO_VAL(PH_EXHIF_HW_GPIO_IN_PORT_H)))
            // ;
    } while (0);
   }

}

 

Observations :

1) We are getting constant 4V on MISO pin. We are not sure why it is 4 V instead of 3.3 V.
2) PN7462 is rarely able to detect receive interrupt, even when we are sending 1 byte of data every 50 mSecs.
3) Whenever we get receive interrupt in PN7462, the length of received data changes randomly. Also under such circumstances, we get 0 in receive buffer of PN7462 irrespective of what data has been sent from the master.

 

Please guide us to resolve the problem

Thanks in advance,

Attachments

Outcomes