|
21 | 21 | // Revision 2 10/5/2024
|
22 | 22 | // Added support for SD to Parallel interface
|
23 | 23 | //
|
| 24 | +// Revision 3 10/11/2024 |
| 25 | +// Added variable wait states for Expanded RAM |
| 26 | +// - For 4.77 Mhz, can be changed to zero wait states for Write cycles and two for Read cycles |
| 27 | +// |
24 | 28 | //------------------------------------------------------------------------
|
25 | 29 | //
|
26 | 30 | // Copyright (c) 2024 Ted Fried
|
@@ -330,7 +334,7 @@ inline uint8_t PSRAM_Read(uint32_t address_in) {
|
330 | 334 | nibble_out = address_in >> 4; PSRAM_Write_Clk_Cycle();
|
331 | 335 | nibble_out = address_in; PSRAM_Write_Clk_Cycle();
|
332 | 336 |
|
333 |
| - GPIO8_DR = sd_pin_outputs + MUX_DATA_n_HIGH + DATA_OE_n_LOW + CHRDY_OE_n_HIGH; // Two WAIT STATES |
| 337 | + //GPIO8_DR = sd_pin_outputs + MUX_DATA_n_HIGH + CHRDY_OE_n_HIGH + DATA_OE_n_LOW; // De-assert CHRDY early for 4.77 Mhz |
334 | 338 |
|
335 | 339 |
|
336 | 340 | // Four clocks of hi-Z - Make PSRAM Data signals hi-Z during this time
|
@@ -376,7 +380,7 @@ inline uint8_t PSRAM_Write(uint32_t address_in , int8_t local_data) {
|
376 | 380 | nibble_out = address_in >> 4; PSRAM_Write_Clk_Cycle();
|
377 | 381 | nibble_out = address_in; PSRAM_Write_Clk_Cycle();
|
378 | 382 |
|
379 |
| - GPIO8_DR = sd_pin_outputs + MUX_DATA_n_HIGH + CHRDY_OE_n_HIGH + DATA_OE_n_LOW; // de-assert wait state |
| 383 | + //GPIO8_DR = sd_pin_outputs + MUX_DATA_n_HIGH + CHRDY_OE_n_HIGH + DATA_OE_n_LOW; // De-assert CHRDY early for 4.77 Mhz |
380 | 384 |
|
381 | 385 |
|
382 | 386 | // Send byte data in twp clock cycles
|
@@ -411,6 +415,8 @@ inline void Mem_Read_Cycle() {
|
411 | 415 |
|
412 | 416 | isa_data_out = PSRAM_Read(psram_address);
|
413 | 417 | GPIO7_DR = GPIO7_DATA_OUT_UNSCRAMBLE + MUX_ADDR_n_LOW + CHRDY_OUT_LOW + trigger_out; // Output data
|
| 418 | + GPIO8_DR = sd_pin_outputs + MUX_DATA_n_HIGH + CHRDY_OE_n_HIGH + DATA_OE_n_LOW; // De-assert CHRDY |
| 419 | + |
414 | 420 |
|
415 | 421 |
|
416 | 422 | while ( (gpio9_int&0xF0) != 0xF0 ) { gpio9_int = GPIO9_DR; } // Wait here until cycle is complete
|
@@ -449,13 +455,15 @@ inline void Mem_Write_Cycle() {
|
449 | 455 | else if (page_base_address == 0xE0000) { psram_address = (reg_0x260<<14) | (isa_address & 0x03FFF); }
|
450 | 456 |
|
451 | 457 | GPIO7_DR = GPIO7_DATA_OUT_UNSCRAMBLE + MUX_ADDR_n_HIGH + CHRDY_OUT_LOW + trigger_out;
|
452 |
| - GPIO8_DR = sd_pin_outputs + MUX_DATA_n_LOW + CHRDY_OE_n_HIGH + DATA_OE_n_HIGH; // Steer data mux to Data[7:0] and Assert CHRDY_n=0 to begin wait states |
| 458 | + GPIO8_DR = sd_pin_outputs + MUX_DATA_n_LOW + CHRDY_OE_n_LOW + DATA_OE_n_HIGH; // Steer data mux to Data[7:0] and Assert CHRDY_n=0 to begin wait states |
453 | 459 |
|
454 | 460 | delayNanoseconds(10); // Wait some time for buffers to switch from address to data
|
455 | 461 |
|
456 | 462 | gpio6_int = GPIO6_DR;
|
457 | 463 | data_in = 0xFF & ADDRESS_DATA_GPIO6_UNSCRAMBLE;
|
458 | 464 | PSRAM_Write(psram_address , data_in);
|
| 465 | + GPIO8_DR = sd_pin_outputs + MUX_DATA_n_LOW + CHRDY_OE_n_HIGH + DATA_OE_n_HIGH; // De-assert CHRDY |
| 466 | + |
459 | 467 |
|
460 | 468 | while ( (gpio9_int&0xF0) != 0xF0 ) { // Wait here until cycle is complete
|
461 | 469 | gpio6_int = GPIO6_DR; // Needed?
|
|
0 commit comments