Configuration structure for an External Bus Interface (EBI) chip select.
This structure defines all timing and control parameters for a single chip select on the External Bus Interface. It controls setup times, pulse widths, cycle lengths, and operational modes for interfacing with external memory or peripheral devices.
The timing parameters are specified in clock cycles and use formulas to extend the range of values that can be represented in the limited bit fields.
- Note
- All timing values are expressed in EBI clock cycles. Calculate actual times by dividing by your EBI clock frequency.
-
Setup + Pulse widths should not exceed the total cycle length. The hold time is implicitly: Hold = Total_Cycles - (Setup + Pulse)
- Warning
- Incorrect timing configuration can result in data corruption, device malfunction, or bus hangs. Always consult your external device datasheet for minimum timing requirements.
Timing Diagram Reference
Read Cycle:
NCS: ────┐ ┌──────
│ │
└───────────────────┘
│<-setup->│<─pulse->│<hold>│
NRD: ────────┐ ┌──────────
│ │
└───────────┘
│<-setup->│<-pulse->│
DATA: ------------X===VALID===X------
│<TDF>│
uint16_t nrd_cycles
Definition ebi.h:1162
Write Cycle:
NCS: ──────┐ ┌──────
│ │
└───────────────────┘
│<-setup->│<-pulse->│<hold>│
NWE: ────────────┐ ┌─────────
│ │
└───────────┘
│<-setup->│<-pulse->│
DATA: ------------X===VALID===X---------
- See also
- EBI_CS_BusWidth_t
-
EBI_CS_ByteAccess_t
-
EBI_CS_NWait_t
-
EBI_CS_WrMode_t
-
EBI_CS_RdMode_t
Expand for Example Usage
Examples
- Example 1: Fast SRAM configuration (70ns access time)
.nrd_setup = 2,
.ncs_rd_pulse = 11,
.nrd_pulse = 11,
.nrd_cycles = 15,
.ncs_wr_setup = 2,
.nwe_setup = 2,
.ncs_wr_pulse = 11,
.nwe_pulse = 11,
.nwe_cycles = 15,
.tdf_cycles = 2,
};
iprintf("Fast SRAM configured: 70ns access time\r\n");
uint8_t ncs_rd_setup
Definition ebi.h:1154
@ EBI_WRITE_MODE_NWE
Write controlled by write enable (NWE) signal.
Definition ebi.h:596
@ EBI_READ_MODE_NRD
Read controlled by read enable (NRD) signal.
Definition ebi.h:687
@ EBI_BYTE_ACCESS_WRITE
Use write enable signal to access individual bytes on 16-bit bus.
Definition ebi.h:432
@ EBI_NWAIT_DISABLED
NWAIT signal ignored, all timing from configuration registers.
Definition ebi.h:522
@ EBI_BUS_WIDTH_16
16-bit data bus width (D0-D15)
Definition ebi.h:376
Configuration structure for an External Bus Interface (EBI) chip select.
Definition ebi.h:1153
- Example 2: Slow flash memory configuration (120ns access)
.nrd_setup = 2,
.ncs_rd_pulse = 12,
.nrd_pulse = 12,
.nrd_cycles = 16,
.ncs_wr_setup = 3,
.nwe_setup = 3,
.ncs_wr_pulse = 20,
.nwe_pulse = 20,
.nwe_cycles = 26,
.tdf_cycles = 3,
};
iprintf("Flash memory configured with NWAIT support\r\n");
@ EBI_BYTE_ACCESS_SELECT
Use chip select signal to access individual bytes on 16-bit bus.
Definition ebi.h:431
@ EBI_NWAIT_FROZEN
NWAIT can freeze/extend the access cycle indefinitely.
Definition ebi.h:523
@ EBI_BUS_WIDTH_8
8-bit data bus width (D0-D7)
Definition ebi.h:375
- Example 3: Simple 8-bit I/O device (minimal timing)
.nrd_setup = 3,
.ncs_rd_pulse = 6,
.nrd_pulse = 6,
.nrd_cycles = 10,
.ncs_wr_setup = 3,
.nwe_setup = 3,
.ncs_wr_pulse = 6,
.nwe_pulse = 6,
.nwe_cycles = 10,
.tdf_cycles = 1,
};
iprintf("Simple I/O device configured\r\n");
@ EBI_WRITE_MODE_NCS
Write controlled by chip select (NCS) assertion.
Definition ebi.h:595
@ EBI_READ_MODE_NCS
Read controlled by chip select (NCS) assertion.
Definition ebi.h:686
- Example 4: Extended timing range using formula (slow device)
.nrd_setup = 10,
.ncs_rd_pulse = 200,
.nrd_pulse = 200,
.nrd_cycles = 220,
.ncs_wr_setup = 10,
.nwe_setup = 10,
.ncs_wr_pulse = 200,
.nwe_pulse = 200,
.nwe_cycles = 220,
.tdf_cycles = 5,
};
iprintf("Very slow device configured: 2us access time\r\n");
@ EBI_NWAIT_READY
NWAIT sampled to determine device ready state.
Definition ebi.h:524
- Example 5: Helper function to calculate timing from nanoseconds
void CalculateEBI_Timing(uint32_t clockFreqMHz, uint32_t setupNs,
uint32_t pulseNs, uint32_t holdNs,
{
float nsPerCycle = 1000.0f / clockFreqMHz;
uint8_t setupCycles = (uint8_t)((setupNs + nsPerCycle - 1) / nsPerCycle);
uint8_t pulseCycles = (uint8_t)((pulseNs + nsPerCycle - 1) / nsPerCycle);
uint8_t holdCycles = (uint8_t)((holdNs + nsPerCycle - 1) / nsPerCycle);
uint16_t totalCycles = setupCycles + pulseCycles + holdCycles;
iprintf("Calculated timing: %u setup, %u pulse, %u hold cycles\r\n",
setupCycles, pulseCycles, holdCycles);
}
void UserMain(void *pd) {
CalculateEBI_Timing(150, 20, 70, 10, &myConfig);
while(1) {
}
}
#define TICKS_PER_SECOND
System clock ticks per second.
Definition constants.h:49
uint8_t nrd_pulse
Definition ebi.h:1159
uint8_t nwe_setup
Definition ebi.h:1157
uint16_t nwe_cycles
Definition ebi.h:1163
EBI_CS_RdMode_t rdMode
Definition ebi.h:1169
uint8_t ncs_wr_setup
Definition ebi.h:1156
uint8_t ncs_wr_pulse
Definition ebi.h:1160
uint8_t nwe_pulse
Definition ebi.h:1161
uint8_t ncs_rd_pulse
Definition ebi.h:1158
EBI_CS_WrMode_t wrMode
Definition ebi.h:1168
EBI_CS_BusWidth_t busWidth
Definition ebi.h:1165
uint8_t tdf_cycles
Definition ebi.h:1164
EBI_CS_NWait_t nWait
Definition ebi.h:1167
uint8_t nrd_setup
Definition ebi.h:1155
void init()
System initialization. Ideally called at the beginning of all applications, since the easiest Recover...
- Example 6: Validating timing configuration
{
iprintf("Error: tdf_cycles must be 0-15\r\n");
return false;
}
iprintf("Error: Read setup+pulse exceeds total cycles\r\n");
return false;
}
iprintf("Error: Write setup+pulse exceeds total cycles\r\n");
return false;
}
iprintf("EBI timing configuration valid\r\n");
return true;
}
void ConfigureEBI_WithValidation() {
.ncs_rd_pulse = 10, .nrd_pulse = 10,
.nrd_cycles = 15,
.ncs_wr_setup = 2, .nwe_setup = 2,
.ncs_wr_pulse = 10, .nwe_pulse = 10,
.nwe_cycles = 15,
.tdf_cycles = 2,
};
if (ValidateEBI_Timing(&config)) {
iprintf("Configuration validated and applied\r\n");
}
}