8000 Update DMAMemcpy.ino (#2481) · marklove5102/arduino-pico@f18fa88 · GitHub
[go: up one dir, main page]

Skip to content

Commit f18fa88

Browse files
Update DMAMemcpy.ino (earlephilhower#2481)
Use 64-bit cycle counts to avoid occasional overflows.
1 parent 07b7d97 commit f18fa88

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libraries/rp2040/examples/DMAMemcpy/DMAMemcpy.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ void verify(const char *name, uint32_t *src) {
2828
void loop() {
2929
uint64_t start, stop;
3030

31-
start = rp2040.getCycleCount();
31+
start = rp2040.getCycleCount64();
3232
for (int i = 0; i < 1000; i++) {
3333
memcpy(dest, src, 4 * 1024);
3434
memcpy(src, dest, 4 * 1024);
3535
}
36-
stop = rp2040.getCycleCount();
36+
stop = rp2040.getCycleCount64();
3737
verify("CPU", src);
3838
verify("CPU", dest);
3939
Serial.printf("CPU: %lld clock cycles for 4K\n", (stop - start) / 1000);
4040

41-
start = rp2040.getCycleCount();
41+
start = rp2040.getCycleCount64();
4242
for (int i = 0; i < 1000; i++) {
4343
rp2040.memcpyDMA(dest, src, 4 * 1024);
4444
rp2040.memcpyDMA(src, dest, 4 * 1024);
4545
}
46-
stop = rp2040.getCycleCount();
46+
stop = rp2040.getCycleCount64();
4747
verify("DMA", src);
4848
verify("DMA", dest);
4949
Serial.printf("DMA: %lld clock cycles for 4K\n\n\n", (stop - start) / 1000);

0 commit comments

Comments
 (0)
0