So I've been at this for more than one day now, I have a SAMD51J19 chip and on the board is a QSPI Flash Memory. I've pulled up the data sheet for it and it supports a "fast read" at 120MHz with one dummy cycle.
So I programmed it in the instruction frame but when I go to read the QSPI area, nothing happens, it just reads 0's however there is suppose to be information on the flash memory already so maybe I'm doing this wrong.
Can someone look over my code below to help me figure this out, I'm sure it's probably a stupid mistake I'm making because I'm new to all of this or maybe there really is nothing on the chip but I need to first ensure the code below looks correct and that I'm doing it right?
void setup_qspiOut(var8 port, var8 pin) { PORT->Group[port].DIRSET.bit.DIRSET = (1 << pin); PORT->Group[port].OUTCLR.bit.OUTCLR = (1 << pin); PORT->Group[port].PINCFG[pin].reg = PORT_PINCFG_PMUXEN; if(pin % 2 == 0) PORT->Group[port].PMUX[pin / 2].bit.PMUXE = 7; else PORT->Group[port].PMUX[pin / 2].bit.PMUXO = 7; } void setup_qspiIn(var8 port, var8 pin) { PORT->Group[port].CTRL.bit.SAMPLING = (1 << pin); PORT->Group[port].DIRCLR.bit.DIRCLR = (1 << pin); PORT->Group[port].OUTCLR.bit.OUTCLR = (1 << pin); PORT->Group[port].PINCFG[pin].reg = PORT_PINCFG_PMUXEN | PORT_PINCFG_INEN; if(pin % 2 == 0) PORT->Group[port].PMUX[pin / 2].bit.PMUXE = 7; else PORT->Group[port].PMUX[pin / 2].bit.PMUXO = 7; } int main(void) { // Boot device Boot::boot(); // Setup QSPI Pins /* MOSI PA08 Out MISO PA09 In WP PA10 Out HOLD PA11 Out SCK PB10 Out CS PB11 Out */ setup_qspiOut(0, 8); setup_qspiIn(0, 9); setup_qspiOut(0, 10); setup_qspiOut(0, 11); setup_qspiOut(1, 10); setup_qspiOut(1, 11); // De-assert chip mode after each transfer, QSPI is dealing with a memory device QSPI->CTRLB.reg = QSPI_CTRLB_CSMODE_SYSTEMATICALLY | QSPI_CTRLB_MODE_MEMORY; // Output is on rising edge and Input is on falling edge QSPI->BAUD.reg = QSPI_BAUD_CPHA; // Give instruction for high-speed read QSPI->INSTRCTRL.bit.INSTR = 0x0B; QSPI->INSTRFRAME.reg = QSPI_INSTRFRAME_DUMMYLEN(1) | QSPI_INSTRFRAME_DDREN | QSPI_INSTRFRAME_TFRTYPE_READMEMORY | QSPI_INSTRFRAME_DATAEN | QSPI_INSTRFRAME_ADDREN | QSPI_INSTRFRAME_INSTREN; // Enable QSPI QSPI->CTRLA.bit.ENABLE = true; var32 tmp = get32(0x04000000); }