• AVR Freaks

AnsweredHot!SQI Clock not running

Author
snellr314
Starting Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/09/01 11:54:37
  • Location: 0
  • Status: offline
2020/05/20 11:40:17 (permalink)
0

SQI Clock not running

I'm using a PIC32MZ2048EFM144 with Harmony v3 and the sample project on custom hardware hooked up to SST26VF016B Flash memory. I can't seem to get the SQI driver to do anything (any voltage or toggling) on its outputs. Any tips? I keep getting "Driver is not ready" from DRV_MEMORY_Open().
 
Here are a few key parts of the code I'm afraid might need tweaking.
void SQI1_Initialize(void)
{
    // Reset and Disable SQI
    SQI1CFG = _SQI1CFG_RESET_MASK;

    // Set Config Register values
    SQI1CFG = ( SQI1_CFG_DMA_MODE | _SQI1CFG_BURSTEN_MASK |
                SQI1_CFG_DATAEN | SQI1_CFG_CHIP_SELECT) ;

     // SQICLK configuration
    SQI1CLKCON = _SQI1CLKCON_EN_MASK; // Enable Clock

    while (!(SQI1CLKCON & _SQI1CLKCON_STABLE_MASK)); // Wait for clock to become stable

    SQI1CLKCON |= SQI1_CLKCON_CLK_DIV;

    // Enable the SQI Module
    SQI1CFG |= _SQI1CFG_SQIEN_MASK;

    SQI1INTSIGEN = 0x00000000;
    SQI1INTEN = 0x00000000;
    SQI1INTSTAT = 0;

    SQI1CMDTHR = (SQI1_CMDTHR_RXCMDTHR(0x20) | SQI1_CMDTHR_TXCMDTHR(0x20));
    SQI1INTTHR = (SQI1_INTTHR_RXINTTHR(0x01) | SQI1_INTTHR_TXINTTHR(0x01));
    SQI1THR = SQI1_THR_THRES(0x01);

    SQI1INTEN = (_SQI1INTEN_PKTCOMPIE_MASK | _SQI1INTEN_BDDONEIE_MASK);
    SQI1INTSIGEN = (_SQI1INTSIGEN_PKTCOMPISE_MASK | _SQI1INTSIGEN_BDDONEISE_MASK);

    // Flash status check
    SQI1MEMSTAT = SQI1_MEMSTAT_STATCMD_VAL | SQI1_MEMSTAT_STATBYTES_VAL |
                      SQI1_MEMSTAT_STATTYPE_VAL | SQI1_MEMSTAT_STATPOS_VAL;

    IEC5SET = SQI1_INTERRUPT_ENABLE_MASK;

}

void SQI1_DMASetup(void)
{
    SQI1CFGbits.MODE = SQI_DMA_MODE;

    SQI1INTENbits.PKTCOMPIE = 0;
    SQI1INTENbits.PKTCOMPIE = 1;

    SQI1INTENbits.BDDONEIE = 0;
    SQI1INTENbits.BDDONEIE = 1;

    IEC5SET = SQI1_INTERRUPT_ENABLE_MASK;
}

 

/*** DEVCFG0 ***/
#pragma config DEBUG = OFF
#pragma config JTAGEN = OFF
#pragma config ICESEL = ICS_PGx1
#pragma config TRCEN = OFF
#pragma config BOOTISA = MIPS32
#pragma config FECCCON = OFF_UNLOCKED
#pragma config FSLEEP = OFF
#pragma config DBGPER = PG_ALL
#pragma config SMCLR = MCLR_NORM
#pragma config SOSCGAIN = GAIN_LEVEL_3
#pragma config SOSCBOOST = ON
#pragma config POSCGAIN = GAIN_LEVEL_3
#pragma config POSCBOOST = ON
#pragma config EJTAGBEN = NORMAL
#pragma config CP = ON

/*** DEVCFG1 ***/
#pragma config FNOSC = SPLL
#pragma config DMTINTV = WIN_127_128
#pragma config FSOSCEN = OFF
#pragma config IESO = ON
#pragma config POSCMOD = HS
#pragma config OSCIOFNC = OFF
#pragma config FCKSM = CSECMD
#pragma config WDTPS = PS16384
#pragma config WDTSPGM = STOP
#pragma config FWDTEN = OFF
#pragma config WINDIS = NORMAL
#pragma config FWDTWINSZ = WINSZ_25
#pragma config DMTCNT = DMT31
#pragma config FDMTEN = OFF

/*** DEVCFG2 ***/
#pragma config FPLLIDIV = DIV_1
#pragma config FPLLRNG = RANGE_5_10_MHZ
#pragma config FPLLICLK = PLL_FRC
#pragma config FPLLMULT = MUL_50
#pragma config FPLLODIV = DIV_2
#pragma config UPLLFSEL = FREQ_24MHZ

/*** DEVCFG3 ***/
#pragma config USERID = 0xffff
#pragma config FMIIEN = ON
#pragma config FETHIO = ON
#pragma config PGL1WAY = ON
#pragma config PMDL1WAY = ON
#pragma config IOL1WAY = ON
#pragma config FUSBIDIO = ON

/*** BF1SEQ0 ***/

#pragma config TSEQ = 0xffff
#pragma config CSEQ = 0x0

 
DRV_HANDLE DRV_MEMORY_Open
(
    const SYS_MODULE_INDEX drvIndex,
    const DRV_IO_INTENT ioIntent
)
{
    DRV_MEMORY_CLIENT_OBJECT *clientObj = NULL;
    DRV_MEMORY_OBJECT *dObj = NULL;
    uint32_t iClient;

    /* Validate the driver index */
    if (drvIndex >= DRV_MEMORY_INSTANCES_NUMBER)
    {
        SYS_DEBUG_PRINT(SYS_ERROR_INFO, "DRV_MEMORY_Open(): Invalid driver index.\n");
        return DRV_HANDLE_INVALID;
    }

    dObj = &gDrvMemoryObj[drvIndex];

    /* Check if the driver is ready to be opened */
    if (dObj->status != SYS_STATUS_READY)
    {
        if (DRV_MEMORY_IsReady(dObj) != SYS_STATUS_READY)
        {
            SYS_DEBUG_PRINT(SYS_ERROR_INFO, "DRV_MEMORY_Open(): Driver is not ready.\n");
            return DRV_HANDLE_INVALID;
        }
    }

 
#1
friesen
Super Member
  • Total Posts : 2148
  • Reward points : 0
  • Joined: 2008/05/08 05:23:35
  • Location: Indiana, USA
  • Status: offline
Re: SQI Clock not running 2020/05/20 16:04:28 (permalink)
4 (1)
You might need pullups on some or all sqi pins.  Search forum for sqi problems, depending on version there are some issues, its a beta driver per docs.  There are some other fixes needed.

Erik Friesen
#2
optimus_jack
Senior Member
  • Total Posts : 100
  • Reward points : 0
  • Joined: 2017/02/16 03:02:47
  • Location: 0
  • Status: offline
Re: SQI Clock not running 2020/05/20 20:07:32 (permalink)
4 (1)
Hi,
Did you get a chance to look at the already developed application for PIC32MZEF2048EFH144?
https://github.com/Microchip-MPLAB-Harmony/core/tree/master/apps/driver/memory/async/nvm_sst26_read_write/firmware/src/config/pic32mz_ef_sk/peripheral/sqi
 
https://github.com/Microchip-MPLAB-Harmony/core/tree/master/apps/driver/sqi_flash/sst26/sst26_flash_read_write/firmware
 
https://github.com/Microchip-MPLAB-Harmony/csp/tree/master/apps/sqi/sqi_read_write/firmware
 
When you say clock is not running, did you enable REFCLK2 for SQI? Compare the generated code of your plib_clk.c with the existing application mentioned above. If not enabled in your application then this will surely solve your problem.
#3
snellr314
Starting Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/09/01 11:54:37
  • Location: 0
  • Status: offline
Re: SQI Clock not running 2020/05/21 04:22:39 (permalink)
0
Thanks for the feedback. I think my clocking code is identical. To begin with I didn't have REFCLK2 enabled but I did find that on the forums. So I believe it is in place, as per below. But I'm not seeing any clock toggling. I enabled the pullup on the clock line and still nothing.
 

void CLK_Initialize( void )
{
bool int_flag = false;
int_flag = (bool)__builtin_disable_interrupts();
/* unlock system for clock configuration */
SYSKEY = 0x00000000;
SYSKEY = 0xAA996655;
SYSKEY = 0x556699AA;
if (int_flag)
{
__builtin_mtc0(12, 0,(__builtin_mfc0(12, 0) | 0x0001)); /* enable interrupts */
}

/* Set up Reference Clock 2 */
/* REFO2CON register */
/* ROSEL = SYSCLK */
/* DIVSWEN = 1 */
/* RODIV = 2 */
REFO2CON = 0x20200;
/* Enable oscillator (ON bit) */
REFO2CONSET = 0x00008000;
 
/* Peripheral Module Disable Configuration */
PMD1 = 0x1000;
PMD2 = 0x3;
PMD3 = 0x1fc01fc;
PMD4 = 0x1e0;
PMD5 = 0x211f3f00;
PMD6 = 0x10030001;
PMD7 = 0x500000;
/* Lock system since done with clock configuration */
int_flag = (bool)__builtin_disable_interrupts();
SYSKEY = 0x33333333;
if (int_flag) /* if interrupts originally were enabled, re-enable them */
{
__builtin_mtc0(12, 0,(__builtin_mfc0(12, 0) | 0x0001));
}
}

#4
ric
Super Member
  • Total Posts : 28008
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: SQI Clock not running 2020/05/21 04:56:36 (permalink)
2 (1)
Are you doing any transfers?
My understanding is the SQI clock is the same as SPI, it only toggles while data is being transferred, not continuously.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#5
snellr314
Starting Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/09/01 11:54:37
  • Location: 0
  • Status: offline
Re: SQI Clock not running 2020/05/21 04:59:17 (permalink)
0
It is failing on getting the JEDEC id, which is part of the driver's initialization.
#6
snellr314
Starting Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/09/01 11:54:37
  • Location: 0
  • Status: offline
Re: SQI Clock not running 2020/05/22 07:42:33 (permalink)
4 (1)
I'll be honest. I don't know what changed, but it's working now. Not the path to resolution that I'd like, but the code works now: synchronous and asynchronous. Again, I don't know what changed. Maybe restarting my computer and MPLAB was what had to happen...
 
Thanks everyone for your comments previous.
#7
optimus_jack
Senior Member
  • Total Posts : 100
  • Reward points : 0
  • Joined: 2017/02/16 03:02:47
  • Location: 0
  • Status: offline
Re: SQI Clock not running 2020/05/24 23:53:14 (permalink)
4 (1)
Hi Snellr314,
It may have worked because of a HARD reset of the device. At times the External Flash (here SST26) requires a HARD RESET as it may be in an unknown state if there was a soft reset on the MCU which happens normally while programming through MPLABX IDE.
#8
snellr314
Starting Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/09/01 11:54:37
  • Location: 0
  • Status: offline
Re: SQI Clock not running 2020/05/25 04:04:28 (permalink)
0
That is a possibility.
#9
snellr314
Starting Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/09/01 11:54:37
  • Location: 0
  • Status: offline
Re: SQI Clock not running 2020/07/03 09:06:02 (permalink)
4 (1)
The issue reared its ugly head again so I took the chance to troubleshoot further. It appears that the SYS_FS_AUTOMOUNT_ENABLE feature in harmony doesn't work for an uninitialized flash chip (no MBR). I have to mount myself (potentially taking multiple attempts) the first time. 
 
#10
optimus_jack
Senior Member
  • Total Posts : 100
  • Reward points : 0
  • Joined: 2017/02/16 03:02:47
  • Location: 0
  • Status: offline
Re: SQI Clock not running 2020/07/05 20:28:42 (permalink) ☼ Best Answerby snellr314 2020/07/06 04:10:00
0
Hi Snellr314,
 
Yes The h3 File system framework will not auto mount if the media is not formatted. You have to use SYS_FS_Mount() and then format the media once mount is done
#11
Jump to:
© 2020 APG vNext Commercial Version 4.5