2020-11-27 05:16:22 -05:00
|
|
|
//
|
|
|
|
// FILE: demo_cache.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: demo
|
|
|
|
// URL: http://www.adafruit.com/products/1002
|
|
|
|
// URL: https://github.com/RobTillaart/HT16K33
|
|
|
|
|
2021-05-26 09:01:19 -04:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
#include "HT16K33.h"
|
|
|
|
|
|
|
|
HT16K33 seg(0x70);
|
|
|
|
|
|
|
|
uint32_t start, stop, d1, d2;
|
|
|
|
|
2021-05-26 09:01:19 -04:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
|
|
|
|
|
|
|
seg.begin();
|
|
|
|
Wire.setClock(100000);
|
|
|
|
seg.displayOn();
|
|
|
|
seg.brightness(2);
|
|
|
|
seg.displayClear();
|
|
|
|
seg.blink(0);
|
|
|
|
}
|
|
|
|
|
2021-05-26 09:01:19 -04:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
// Note: UNO fails for speed above 850K
|
|
|
|
// UNO 750K and 800K are using same clock divider
|
|
|
|
Serial.println("\nSPEED \tNOCACHE \tms/call \tCACHE\t\tms/call \tRATIO");
|
|
|
|
for (uint32_t sp = 100000; sp < 900000; sp += 50000)
|
|
|
|
{
|
|
|
|
test_cache(sp);
|
|
|
|
}
|
|
|
|
Serial.println();
|
|
|
|
}
|
|
|
|
|
2021-05-26 09:01:19 -04:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
void test_cache(uint32_t speed)
|
|
|
|
{
|
|
|
|
Wire.setClock(speed);
|
|
|
|
Serial.print(speed);
|
|
|
|
Serial.print("\t");
|
|
|
|
seg.cacheOff();
|
|
|
|
start = millis();
|
|
|
|
for (int16_t counter = -999; counter < 10000; counter+=10)
|
|
|
|
{
|
|
|
|
seg.displayInt(counter);
|
|
|
|
}
|
|
|
|
d1 = millis() - start;
|
|
|
|
Serial.print(d1);
|
|
|
|
Serial.print("\t\t");
|
|
|
|
Serial.print(d1 / 1100.0, 3);
|
|
|
|
Serial.print("\t\t");
|
|
|
|
delay(100);
|
|
|
|
|
|
|
|
seg.cacheOn();
|
|
|
|
start = millis();
|
|
|
|
for (int16_t counter = -999; counter < 10000; counter+=10)
|
|
|
|
{
|
|
|
|
seg.displayInt(counter);
|
|
|
|
}
|
|
|
|
d2 = millis() - start;
|
|
|
|
Serial.print(d2);
|
|
|
|
Serial.print("\t\t");
|
|
|
|
Serial.print(d2 / 1100.0, 3);
|
|
|
|
Serial.print("\t\t");
|
|
|
|
Serial.println(1.0 * d1 / d2, 3);
|
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
|
2021-12-19 09:24:23 -05:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
// -- END OF FILE --
|
2021-12-19 09:24:23 -05:00
|
|
|
|