• AVR Freaks

Hot!SPI2 on Harmony PIC32MZ not working.

Author
arpatel
Starting Member
  • Total Posts : 52
  • Reward points : 0
  • Joined: 2019/01/09 23:24:14
  • Location: 0
  • Status: offline
2019/04/17 23:58:52 (permalink)
0

SPI2 on Harmony PIC32MZ not working.

Hi I have tied SPI2 to Si4362 radio device on my PIC32MZ2048EFM064 MCU.
There is no activity on PINS SPI. I have used following code, it stucks at bufferWrite.
Does anybody know the issue?
  switch ( appData.state )
    {
        /* Application's initial state. */
        case APP_STATE_INIT:
        {
            SYS_PRINT("USART STARTED\r\n");
            spi = DRV_SPI0_Open(0,DRV_IO_INTENT_READWRITE|DRV_IO_INTENT_EXCLUSIVE);
            if(spi != DRV_HANDLE_INVALID)
                appData.state = APP_STATE_SERVICE_TASKS;
            
            break;
        }
        case APP_STATE_SERVICE_TASKS:
        {
            txData[0]= 0x02;
            txData[1]= 0x00;
            txData[3]= 0x00;
            SYS_PRINT("SPI STARTED\r\n");
           DRV_SPI0_BufferAddWrite2 (txData, 2, NULL, NULL,&bufferHandle2);
           while(DRV_SPI0_BufferStatus(bufferHandle2) != DRV_SPI_BUFFER_EVENT_COMPLETE);
           SYS_PRINT("SPI POWERON SENT\r\n");
            appData.state = APP_STATE_RECEIVE;
           break;
        }
        case APP_STATE_RECEIVE:
        {
           txData[0]= 0x01;
           txData[1]= 0x00;
           bufferHandle = DRV_SPI0_BufferAddWriteRead2 (txData, 2,rxData,2, NULL, NULL,&bufferHandle2);
           while(DRV_SPI0_BufferStatus(bufferHandle2) != DRV_SPI_BUFFER_EVENT_COMPLETE);
           SYS_PRINT("SPI RECEIVED\r\n");
           SYS_PRINT(rxData);
            appData.state = APP_STATE_IDLE;
            
            break;
        }

It always returning buffer pending as as status.
Is there any example available for Si4362 device??
post edited by arpatel - 2019/04/18 00:55:53
#1

5 Replies Related Threads

    Nome BuTT
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2015/09/19 04:19:09
    • Location: Karachi,Pakistan
    • Status: offline
    Re: SPI2 on Harmony PIC32MZ not working. 2019/04/18 03:18:02 (permalink)
    0
     

    Hi
    I think you are passing wrong argument in 
    DRV_SPI0_BufferAddWrite2 (txData, 2, NULL, NULL,&bufferHandle2);
    First will be handle and second will buffer soo on....
     
    it should be like this..
    DRV_SPI_BufferAddWrite2 ( DRV_HANDLE handle, void *txBuffer,size_t size,DRV_SPI_BUFFER_EVENT_HANDLER completeCB,
    void * context, DRV_SPI_BUFFER_HANDLE * jobHandle )
    post edited by Nome BuTT - 2019/04/18 03:27:18
    #2
    arpatel
    Starting Member
    • Total Posts : 52
    • Reward points : 0
    • Joined: 2019/01/09 23:24:14
    • Location: 0
    • Status: offline
    Re: SPI2 on Harmony PIC32MZ not working. 2019/04/22 02:05:35 (permalink)
    0
    I reckon you are talking about dynamic library implementation which require handle in first place. While I have used static library which doesn’t need handle.
    #3
    arpatel
    Starting Member
    • Total Posts : 52
    • Reward points : 0
    • Joined: 2019/01/09 23:24:14
    • Location: 0
    • Status: offline
    Re: SPI2 on Harmony PIC32MZ not working. 2019/04/23 18:56:41 (permalink)
    0
    I am trying to interface Si4362 to PIC32MZ2048EFM064 with SPI2, but there is no success.
    Has anyone done this before please guide me.
     
    #4
    arpatel
    Starting Member
    • Total Posts : 52
    • Reward points : 0
    • Joined: 2019/01/09 23:24:14
    • Location: 0
    • Status: offline
    Re: SPI2 on Harmony PIC32MZ not working. 2019/04/25 17:04:15 (permalink)
    0
    I have changed my PIN for SS2 and now its working.
    IS SS2 auto enable only for Frame Mode?
    Still, It stuck when I check buffer status.
       appData.drvSPIWRBUFHandle = DRV_SPI_BufferAddWrite(appData.drvSPIHandle,(SPI_DATA_TYPE *)txbuffer, num_of_bytes, 0, 0);
      while(DRV_SPI_BUFFER_EVENT_COMPLETE != DRV_SPI_BufferStatus(appData.drvSPIWRBUFHandle));
     
    It stucks at while loop, always return pending status.
    Am I doing anything wrong?
    #5
    arpatel
    Starting Member
    • Total Posts : 52
    • Reward points : 0
    • Joined: 2019/01/09 23:24:14
    • Location: 0
    • Status: offline
    Re: SPI2 on Harmony PIC32MZ not working. 2019/04/26 00:56:25 (permalink)
    0
    Hi Guys,
    I have got it working,it was TRIS setting value.
    Harmony always have problem with correct TRIS setting.
    Thanks
     
    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5