From 74c216543cec4cde3c359929abfba8aac75ec5be Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 7 Feb 2019 13:12:35 -0500 Subject: [PATCH] atsam: Configure the atsam sram matrix register The sram matrix configuration is, bizarrely, configured with a slow default. It will typically add an extra wait state to every memory access. Set the matrix sram controller to improve the performance. Signed-off-by: Kevin O'Connor --- src/atsam/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/atsam/main.c b/src/atsam/main.c index 7dba4a2d..b6be2864 100644 --- a/src/atsam/main.c +++ b/src/atsam/main.c @@ -102,11 +102,22 @@ usb_request_bootloader(void) * Startup ****************************************************************/ +static void +matrix_init(void) +{ + // The ATSAM sram is in a "no default master" state at reset + // (despite the specs). That typically adds 1 wait cycle to every + // memory access. Set it to "last access master" to avoid that. + MATRIX->MATRIX_SCFG[0] = (MATRIX_SCFG_SLOT_CYCLE(64) + | MATRIX_SCFG_DEFMSTR_TYPE(1)); +} + // Main entry point int main(void) { SystemInit(); + matrix_init(); sched_main(); return 0; }