Is there any example code on how to map the flash device on the SAM board in memory mapped mode ?
I'm trying to read a section of flash, and I had it working the other day, but now I can't get it to work without generating a data abort exception.
This is what I have so far, following the guide in the HWR and using same polarity & speed that I have working in another application on the same HW.
What I find is that the ARM core freezes on the *pREG_SPI2_CTL |=BITM_SPI_CTL_MMSE; line and doesn't continue. No SPI error bits are set.
// Enable SPI2 memory map mode
*pREG_SPI2_CTL &= ~BITM_SPI_CTL_EN;
*pREG_SPI2_RXCTL = BITM_SPI_RXCTL_REN;
*pREG_SPI2_TXCTL = BITM_SPI_TXCTL_TEN | BITM_SPI_TXCTL_TTI;
*pREG_SPI2_DLY = BITM_SPI_DLY_LAGX | BITM_SPI_DLY_LEADX | (3 << BITP_SPI_DLY_STOP);
// Anomaly 20000062 - Writes to the SPI_SLVSEL Register Do Not Take Effect: Write twice
*pREG_SPI2_SLVSEL |= ENUM_SPI_SLVSEL_SSEL1_EN;
*pREG_SPI2_SLVSEL |= ENUM_SPI_SLVSEL_SSEL1_EN;
*pREG_SPI2_MMRDH = ( 3 << BITP_SPI_MMRDH_ADRSIZE) | ( 0x03u << BITP_SPI_MMRDH_OPCODE);
*pREG_SPI2_MMTOP = 0x04000000;
*pREG_SPI2_CLK = 0x50;
*pREG_SPI2_CTL = ENUM_SPI_CTL_MASTER | BITM_SPI_CTL_EMISO | ENUM_SPI_CTL_SIZE32 | ENUM_SPI_CTL_ASSRT_SSEL | BITM_SPI_CTL_SELST | ENUM_SPI_CTL_FAST_EN;
*pREG_SPI2_CTL |=BITM_SPI_CTL_MMSE;
*pREG_SPI2_CTL |= BITM_SPI_CTL_EN;