• AVR Freaks

Hot!WINC1500 sometimes fails to read CLOCKS_EN_REG

Author
msurmei
New Member
  • Total Posts : 9
  • Reward points : 0
  • Joined: 2009/05/12 02:00:44
  • Location: Romania
  • Status: offline
2020/04/17 10:21:54 (permalink)
0

WINC1500 sometimes fails to read CLOCKS_EN_REG

Hi,
Got some problems with running latest MLA driver for WINC1500 with a PIC18F47K42 on a custom board (build in a very similar way as the Microchip devel tools). The WINC is running as an AP and main state machine is a UDP server.
After stating up the AP, opening&binding the socket, successfully receiving a datagram, at the first sendto , the ChipWake() routine reads CLOCKS_EN_REG == 0 and after several retries the winc host driver reports Error for the sendto but the winc state is damaged enough so a restart is needed.
Same ChipWake(), used by hif_send() , behaves properly for the previous SPI operations and the reported CLOCKS_EN_REG is 7.
The workaround is to add a delay ( first DelayMs(2), the second is from the original MLA). After that everything works.
 
void ChipWake(void)
{
volatile uint32_t reg = 0, clk_status_reg = 0, trials = 0;
//printf("[redlog] Inside ChipWake\r\n");
reg = nm_read_reg(HOST_CORT_COMM);

//printf("[redlog] Inside ChipWake: HOST_CORT_COMM = %x\r\n", reg);
if(!(reg & NBIT0))
{
// use bit 0 to indicate host wakeup
nm_write_reg(HOST_CORT_COMM, reg | NBIT0);
}

reg = nm_read_reg(WAKE_CLK_REG);
//printf("[redlog] Inside ChipWake: WAKE_CLK_REG = %x\r\n", reg);
DelayMs(2);
// Set bit 1
if(!(reg & NBIT1))
{
nm_write_reg(WAKE_CLK_REG, reg | NBIT1);
}
do
{
clk_status_reg = nm_read_reg(CLOCKS_EN_REG);
printf("[redlog] Inside ChipWake: CLOCKS_EN_REG = %x\r\n", clk_status_reg);
if(clk_status_reg & NBIT2)
{
break;
}
DelayMs(2);
trials++;
if(trials > WAKUP_TRAILS_TIMEOUT)
{
dprintf("Failed to wakup the chip\n");
GenerateErrorEvent(M2M_WIFI_FAILED_TO_WAKE_CHIP_ERROR);
return;
}
} while(1);

// workaround sometimes spi fail to read clock regs after reading/writing clockless registers
nm_spi_reset();
}
I am of course worried about the last comment from the MLA designer : "sometimes spi fail to read ...". 
 
My questions are:
1) did anybody had such timing issues ? 
2) I need to understand why the delay fixed the problem, but I was not able to find detailed timing spec sheets for winc . I do not know what are the design rules for reading clockless registers and how far I am from breaking them.
 
Regards,
Mihai
#1

1 Reply Related Threads

    msurmei
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2009/05/12 02:00:44
    • Location: Romania
    • Status: offline
    Re: WINC1500 sometimes fails to read CLOCKS_EN_REG 2020/04/18 02:10:45 (permalink)
    5 (1)
    Ok, fixed ... my bad, the SPI initialization was messed up; after properly configured, issues above are gone.
    Just for the record, firmware I am using is:
    WINC1500 Host Driver:
    Chip ID: 3a0
    Firmware Version: 19.6.1
    Firmware Build Date/Time: May 23 2018, 14:39:16
    Firmware Min Driver Version: 19.3.0
    Host Driver Version: 19.3.0
    Host Driver Build Date/Time: Apr 18 2020, 12:03:32
     
    #2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5