Skip to content

Commit

Permalink
Fix pulse timing and initial state of error flag
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyparrish committed Aug 31, 2024
1 parent 9ab2e87 commit c846f37
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
7 changes: 7 additions & 0 deletions firmware/fast-gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,20 @@
#endif


// Without the nop, these pulses happen in about 115ns. The nop adds about 8ns
// to the process, but without it, voltage bottoms out too high (around 1.5V).
// To be a reliable zero on our flip-flops, we need 0.9V max, and we need the
// low pulse width to be at least 7ns. With this nop, the signal stays under
// 0.9V for about 20ns.
#define FAST_PULSE_ACTIVE_LOW(PIN) { \
FAST_CLEAR(PIN); \
asm("nop"); \
FAST_SET(PIN); \
}

#define FAST_PULSE_ACTIVE_HIGH(PIN) { \
FAST_SET(PIN); \
asm("nop"); \
FAST_CLEAR(PIN); \
}

Expand Down
4 changes: 3 additions & 1 deletion firmware/firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ void setup() {
init_all_hardware();

#ifdef RUN_TESTS
if (!is_error_flagged()) {
if (is_error_flagged()) {
Serial.println("Error flagged, skipping tests!\n");
} else {
run_tests();
}
#endif
Expand Down
9 changes: 7 additions & 2 deletions firmware/registers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ int is_error_flagged() {
uint8_t read_register(int register_address) {
FAST_WRITE(REG_PIN__A0, register_address & 1);
FAST_WRITE(REG_PIN__A1, register_address & 2);

// FIXME: need to delay here?
// The data sheet for the 74HCT670 says the data will be available after at
// most 295ns at 2V, and 59ns at 4.5V. (Not given for 3.3V) Here we wait 1
// us to be sure that we are reading the right data. It is okay to read a
// register a little more slowly. Writing to SRAM and reading from the
// network are the critical operations in terms of speed.
// https://www.ti.com/lit/ds/symlink/cd74hct670.pdf
delayMicroseconds(1);
return FAST_READ_MULTIPLE(REG_PIN__D_MASK, REG_PIN__D_SHIFT);
}
3 changes: 3 additions & 0 deletions software/player/src/segavideo_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ static void loadMenuColors() {
void segavideo_menu_init() {
kprintf("segavideo_menu_init\n");

// Clear the error flag, which may boot up in a random state.
clearPendingError();

// Load menu palettes.
loadMenuColors();

Expand Down

0 comments on commit c846f37

Please sign in to comment.