Hi!
External device connected to EMC as static memory. Use A0-A5, D0-D15, CS0, WE, OE signals.
#define SWITCH_EMC EMC
#define SWITCH_BASE_ADR (0x80000000ul)
#define SWITCH_EMC_CLKDIV (2)
#define WaitWriteEn_Ns (0)
#define WaitOutEn_Ns (0)
#define WaitReadNoPage_Ns (10)
#define WaitReadPage_Ns (10)
#define WaitWrite_Ns (10)
#define WaitTurn_Ns (10)
static emc_basic_config_t emc_cfg = {
.endian = kEMC_LittleEndian,
.fbClkSrc = kEMC_IntloopbackEmcclk,
.emcClkDiv = SWITCH_EMC_CLKDIV
};
static emc_static_chip_config_t switch_static_mem_cfg = {
.chipIndex = 0,
.memWidth = kEMC_16BitWidth, /*!< Memory width. */
.specailConfig = kEMC_NoSpecials, /*!< Static configuration,a logical OR of "emc_static_special_config_t". */
.tWaitWriteEn_Ns = WaitWriteEn_Ns, /*!< The delay form chip select to write enable in unit of nanosecond. */
.tWaitOutEn_Ns = WaitOutEn_Ns, /*!< The delay from chip selcet to output enable in unit of nanosecond. */
.tWaitReadNoPage_Ns = WaitReadNoPage_Ns, /*!< In No-page mode, the delay from chip select to read access in unit of nanosecond. */
.tWaitReadPage_Ns = WaitReadPage_Ns, /*!< In page mode, the read after the first read wait states in unit of nanosecond. */
.tWaitWrite_Ns = WaitWrite_Ns, /*!< The delay from chip select to write access in unit of nanosecond. */
.tWaitTurn_Ns = WaitTurn_Ns /*!< The Bus turn-around time in unit of nanosecond. */
};
static inline void
emc_syscon_init(void) {
/* shift mode disable & burst mode disable */
SYSCON->EMCSYSCTRL |= SYSCON_EMCSYSCTRL_EMCSC(1) |
SYSCON_EMCSYSCTRL_EMCBC(1);
}
void
switch_io_init(void) {
EMC_Init(SWITCH_EMC, &emc_cfg);
emc_syscon_init();
EMC_StaticMemInit(SWITCH_EMC, NULL, &switch_static_mem_cfg, 1);
EMC_Enable(SWITCH_EMC, true);
SWITCH_PRST(PRST_OFF);
}
Reading from the device is normal.
But when trying to write to the device there is no WE signal, CS signal is set low.
WE pin configured:
IOCON->PIO[0][15] = ((IOCON->PIO[0][15] &
/* Mask bits to zero which are setting */
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_ANAMODE_MASK | IOCON_PIO_DIGIMODE_MASK)))
/* Selects pin function.
* : PORT015 (pin L4) is configured as EMC_WEN. */
| IOCON_PIO_FUNC(PIO015_FUNC_ALT6)
/* Enables or disables analog mode.
* : Disable analog Mode. */
| IOCON_PIO_ANAMODE(PIO015_ANAMODE_DISABLED)
/* Select Analog/Digital mode.
* : Digital mode. */
| IOCON_PIO_DIGIMODE(PIO015_DIGIMODE_DIGITAL));
Checked the line in GPIO mode - it works.
What could be the problem?