Hi,
I am trying to interface with a FPGA over EPI with Tiva C Series Connected LaunchPad EK-TM4C1294XL. This is my configuration:
struct GPIOPin_t {
uint32_t gpioBase;
uint8_t pin;
uint32_t altPin;
};
uint8_t bits = 16;
uint32_t frequency = 500000;
// Enable EPI
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_EPI0);
while (!(ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_EPI0)));
// Enable all GPIOs for EPI
for (uint8_t i = 0; i < 10; i++) {
ROM_SysCtlPeripheralEnable(GPIOPeriph[i]);
while (!(ROM_SysCtlPeripheralReady(GPIOPeriph[i])));
}
// Configure GPIO for use with EPI
for (uint8_t i = 0; i < bits; i++) {
MAP_GPIOPinConfigure(GPIOPin[i].altPin);
GPIOPinTypeEPI(GPIOPin[i].gpioBase, GPIOPin[i].pin);
}
// Set Divider from frequency (in this case 500 kHz)
if (frequency) {
uint32_t divider = (F_CPU / (frequency * 2) - 1) * 2;
// Enable Clock pin
MAP_GPIOPinConfigure(GPIOPin[31].altPin);
GPIOPinTypeEPI(GPIOPin[31].gpioBase, GPIOPin[31].pin);
//GPIODirModeSet(GPIOPin[31].gpioBase, GPIOPin[31].pin, GPIO_DIR_MODE_OUT);
// Enable Frame pin
MAP_GPIOPinConfigure(GPIOPin[30].altPin);
GPIOPinTypeEPI(GPIOPin[30].gpioBase, GPIOPin[30].pin);
EPIDividerSet(EPI0_BASE, divider);
}
// Enable EPI
EPIModeSet(EPI0_BASE, EPI_MODE_GENERAL);
// Set EPI Mode
EPIConfigGPModeSet(EPI0_BASE, EPI_GPMODE_CLKPIN | EPI_GPMODE_FRAME50 | EPI_GPMODE_ASIZE_NONE | EPI_GPMODE_DSIZE_32, 10, 0);
//Address map to 0xA000.0000
EPIAddressMapSet(EPI0_BASE, EPI_ADDR_PER_BASE_A | EPI_ADDR_PER_BASE_NONE);
// Calculate bit mask
if (bits >= 32) {
bits = 32;
bitMask = 0xffffffff;
} else {
bitMask = (1 << bits) - 1;
}
// Write some data to EPI
uint16_t i = 0;
while(true) {
HWREGH(EPI_PORT) = i & bitMask;
_delay_ms(1);
}
Here are the arrays used above.
uint32_t EPI::GPIOPeriph[] = {
SYSCTL_PERIPH_GPIOA,
SYSCTL_PERIPH_GPIOB,
SYSCTL_PERIPH_GPIOC,
SYSCTL_PERIPH_GPIOG,
SYSCTL_PERIPH_GPIOH,
SYSCTL_PERIPH_GPIOK,
SYSCTL_PERIPH_GPIOL,
SYSCTL_PERIPH_GPIOM,
SYSCTL_PERIPH_GPION,
SYSCTL_PERIPH_GPIOQ
};
EPI::GPIOPin_t EPI::GPIOPin[] = {
{ GPIO_PORTH_BASE, GPIO_PIN_0, GPIO_PH0_EPI0S0 }, /* 0 */
{ GPIO_PORTH_BASE, GPIO_PIN_1, GPIO_PH1_EPI0S1 }, /* 1 */
{ GPIO_PORTH_BASE, GPIO_PIN_2, GPIO_PH2_EPI0S2 }, /* 2 */
{ GPIO_PORTH_BASE, GPIO_PIN_3, GPIO_PH3_EPI0S3 }, /* 3 */
{ GPIO_PORTC_BASE, GPIO_PIN_7, GPIO_PC7_EPI0S4 }, /* 4 */
{ GPIO_PORTC_BASE, GPIO_PIN_6, GPIO_PC6_EPI0S5 }, /* 5 */
{ GPIO_PORTC_BASE, GPIO_PIN_5, GPIO_PC5_EPI0S6 }, /* 6 */
{ GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_PC4_EPI0S7 }, /* 7 */
{ GPIO_PORTA_BASE, GPIO_PIN_6, GPIO_PA6_EPI0S8 }, /* 8 */
{ GPIO_PORTA_BASE, GPIO_PIN_7, GPIO_PA7_EPI0S9 }, /* 9 */
{ GPIO_PORTG_BASE, GPIO_PIN_1, GPIO_PG1_EPI0S10 }, /* 10 */
{ GPIO_PORTG_BASE, GPIO_PIN_0, GPIO_PG0_EPI0S11 }, /* 11 */
{ GPIO_PORTM_BASE, GPIO_PIN_3, GPIO_PM3_EPI0S12 }, /* 12 */
{ GPIO_PORTM_BASE, GPIO_PIN_2, GPIO_PM2_EPI0S13 }, /* 13 */
{ GPIO_PORTM_BASE, GPIO_PIN_1, GPIO_PM1_EPI0S14 }, /* 14 */
{ GPIO_PORTM_BASE, GPIO_PIN_0, GPIO_PM0_EPI0S15 }, /* 15 */
{ GPIO_PORTL_BASE, GPIO_PIN_0, GPIO_PL0_EPI0S16 }, /* 16 */
{ GPIO_PORTL_BASE, GPIO_PIN_1, GPIO_PL1_EPI0S17 }, /* 17 */
{ GPIO_PORTL_BASE, GPIO_PIN_2, GPIO_PL2_EPI0S18 }, /* 18 */
{ GPIO_PORTL_BASE, GPIO_PIN_3, GPIO_PL3_EPI0S19 }, /* 19 */
{ GPIO_PORTQ_BASE, GPIO_PIN_0, GPIO_PQ0_EPI0S20 }, /* 20 */
{ GPIO_PORTQ_BASE, GPIO_PIN_1, GPIO_PQ1_EPI0S21 }, /* 21 */
{ GPIO_PORTQ_BASE, GPIO_PIN_2, GPIO_PQ2_EPI0S22 }, /* 22 */
{ GPIO_PORTQ_BASE, GPIO_PIN_3, GPIO_PQ3_EPI0S23 }, /* 23 */
{ GPIO_PORTK_BASE, GPIO_PIN_7, GPIO_PK7_EPI0S24 }, /* 24 */
{ GPIO_PORTK_BASE, GPIO_PIN_6, GPIO_PK6_EPI0S25 }, /* 25 */
{ GPIO_PORTL_BASE, GPIO_PIN_4, GPIO_PL4_EPI0S26 }, /* 26 */
{ GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_PB2_EPI0S27 }, /* 27 */
{ GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_PB3_EPI0S28 }, /* 28 */
{ GPIO_PORTN_BASE, GPIO_PIN_2, GPIO_PN2_EPI0S29 }, /* 29 */
{ GPIO_PORTN_BASE, GPIO_PIN_3, GPIO_PN3_EPI0S30 }, /* 30 */
{ GPIO_PORTK_BASE, GPIO_PIN_5, GPIO_PK5_EPI0S31 }, /* 31 */
{ GPIO_PORTK_BASE, GPIO_PIN_4, GPIO_PK4_EPI0S32 }, /* 32 */
{ GPIO_PORTL_BASE, GPIO_PIN_5, GPIO_PL5_EPI0S33 }, /* 33 */
{ GPIO_PORTN_BASE, GPIO_PIN_4, GPIO_PN4_EPI0S34 } /* 34 */
};
I can see the data on the first 16 pins but clock and frame is always logic high. How can I achieve that clock and frame work as desired.