diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fmc-test/src/main.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/fmc-test/src/main.c b/src/fmc-test/src/main.c index 69c5bb0..ce04bee 100644 --- a/src/fmc-test/src/main.c +++ b/src/fmc-test/src/main.c @@ -34,6 +34,8 @@ //------------------------------------------------------------------------------ RNG_HandleTypeDef rng_inst; +volatile uint32_t data_diff = 0; +volatile uint32_t addr_diff = 0; //------------------------------------------------------------------------------ @@ -88,26 +90,25 @@ int main(void) led_off(GPIO_PIN_LED_BLUE); // vars - int test_ok; + volatile int data_test_ok = 0, addr_test_ok = 0, successful_runs = 0; // main loop (test, until an error is detected) while (1) { // test data bus - test_ok = test_fpga_data_bus(); + data_test_ok = test_fpga_data_bus(); + // test address bus + addr_test_ok = test_fpga_address_bus(); // check for errors (abort testing in case of error) - if (test_ok < TEST_NUM_ROUNDS) break; - - - // test address bus - test_ok = test_fpga_address_bus(); + if (data_test_ok < TEST_NUM_ROUNDS) break; // check for errors (abort testing in case of error) - if (test_ok < TEST_NUM_ROUNDS) break; + if (addr_test_ok < TEST_NUM_ROUNDS) break; // toggle yellow led to indicate, that we are alive led_toggle(GPIO_PIN_LED_YELLOW); + successful_runs++; } // error handler @@ -135,6 +136,7 @@ int test_fpga_data_bus(void) // run some rounds of data bus test for (c=0; c<TEST_NUM_ROUNDS; c++) { + data_diff = 0; // try to generate "random" number hal_result = HAL_RNG_GenerateRandomNumber(&rng_inst, &rnd); if (hal_result != HAL_OK) break; @@ -150,9 +152,8 @@ int test_fpga_data_bus(void) // compare (abort testing in case of error) if (buf != rnd) { - uint32_t diff = buf; - diff ^= rnd; - diff = 0; // place breakpoint here if needed + data_diff = buf; + data_diff ^= rnd; break; } } @@ -173,12 +174,13 @@ int test_fpga_address_bus(void) // run some rounds of address bus test for (c=0; c<TEST_NUM_ROUNDS; c++) { + addr_diff = 0; // try to generate "random" number hal_result = HAL_RNG_GenerateRandomNumber(&rng_inst, &rnd); if (hal_result != HAL_OK) break; // we only have 2^22 32-bit words - rnd &= 0x00FFFFFC; + rnd &= 0x00FFFFFC; // don't test zero addresses (fpga will store data, not address) if (rnd == 0) continue; @@ -198,9 +200,8 @@ int test_fpga_address_bus(void) // compare (abort testing in case of error) if (buf != rnd) { - uint32_t diff = buf; - diff ^= rnd; - diff = 0; // place breakpoint here if needed + addr_diff = buf; + addr_diff ^= rnd; break; } } |