Bakisha wrote: Thu Jul 06, 2023 3:26 pm
Try to get CPU at known state, run some simple program...
I've never run asm directly in a sketch but I'll look for examples, I've seen it in other people's code.
Bakisha wrote: Thu Jul 06, 2023 3:26 pm
Maybe add some pin toggle as a test for digital analyzer.
Good idea, this should be a good exercise and I can use the oscilloscope.
Bakisha wrote: Thu Jul 06, 2023 3:26 pm
Maybe set bluepills interrupt priority.
I thought interrupt would be the fastest way... but now I realize there's no way to set interrupt priority in this library?
And this has led me to another idea that is working... (see below)
Bakisha wrote: Thu Jul 06, 2023 3:26 pm
Try to compile with O1,O2,O3...
Setting optimizations O1, O2 & O3 within the Arduino IDE doesn't seem to effect loop performance of the code below. I can verify the build flags are present in the build output, but no effect I can detect in the code.
Bakisha wrote: Thu Jul 06, 2023 3:26 pm
Or add some hardware (HCT) latch and read it with bluepill.
^^^ Last one is what I'm trying most to avoid
However! When I use code like this without interrupts:
Code: Select all
void loop() {
while (true) {
while( ! ((value = GPIOB->IDR) & (1<<3)) ) {
counter++;
}
if (counter != previous_counter) {
Serial.write("Counter = ");
Serial.println(counter);
displayBits32(value);
counter = 0; previous_counter = 0;
}
}
}
I'm getting valid data! Normally the "counter" value is 1, 2 or 3. I've never seen 4. This leads me to wonder where the overhead is coming from. If the sampling rate is anywhere near 72Mhz, and DS is low for at least 450ns, then how could we only sample the register 2 or 3 times???
Some sample output (0x00, 0x01, 0xFF)
Code: Select all
Counter = 3
00000000 00000000 00000000 00111000
Counter = 3
00000000 00000000 00000001 00111000
Counter = 2
00000000 00000000 11111111 00111000
To get faster sampling, I think i'll have to drop the convenient Arduino IDE toolchain and look towards something more bare metal like platformio/toolchain-gccarmnoneeabi as I saw a project like
BlueSCSI uses.