Open beyonlo opened 2 years ago
The fact that the first 2 runs are slower than the rest, is most likely due to caching effects: code is stored in external SPI flash and must be transferred into the RP2040 before it can be executed. This takes time. After it's transferred in it will sit in an internal cache so it's faster next time around.
The fact that the first 2 runs are slower than the rest, is most likely due to caching effects: code is stored in external SPI flash and must be transferred into the RP2040 before it can be executed. This takes time. After it's transferred in it will sit in an internal cache so it's faster next time around.
@dpgeorge all right, understood! That explain about the strange behavior 1. And about the strange behavior 2?
Thank you!
And about the strange behavior 2?
I don't know, that is strange.
First thing I would try is to not change machine.freq()
and just leave it as a default, and run the test again.
@dpgeorge Hello
I don't know, that is strange.
First thing I would try is to not change
machine.freq()
and just leave it as a default, and run the test again.
I commented the line machine.freq()
and run again:
#freq(270_000_000)
But the results was the same, with other values of course, because clock is lower now.
Here the simple test:
pi@pi:~/rp2-pico/tests$ sudo ampy -p /dev/ttyACM0 put pwm.py
pi@pi:~/rp2-pico/tests$
>>> import pwm
array('i', [25, 14, 14, 14, 13, 10, 12, 14, 12, 12, 11, 13, 14, 11, 12, 13, 11, 12, 14, 14, 14, 14, 13, 14, 13, 14, 13, 12, 15, 15])
>>>
MPY: soft reboot
MicroPython v1.18 on 2022-01-17; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>>
>>> import pwm
array('i', [27, 26, 19, 23, 19, 20, 18, 17, 18, 20, 20, 19, 16, 17, 20, 16, 19, 18, 19, 19, 19, 19, 19, 19, 16, 21, 19, 18, 19, 20])
>>>
I need to know the estimated time as near as possible to do a better (near of real) offset in my application. Could you please give some more ideas to me to do tests to find the problem?
Ps: I remembered now that this same behaviour has happened in other tests that I did with different code with adc, etc, where the time was better in the first test after the python code is copied to the flash.
Thank you in advance!
Hi all.
I found a strange behaviour on the RPICO. I did a simple test creating a PWM, and I did a loop just changing the duty cycle (
pwm.duty_u16()
) and calculate how much microseconds the PICO execute the linepwm.duty_u16(32000)
.The intention is to measure the speed and the accuracy.
MicroPython version: 1.18
There are two strange behaviours:
1. In the every print on the tests below, you can check that the first 2 - 3 numbers on the printed array are always with number bigger than others of array. Why that?
2. Look that my first test (
import pwm
) just after I transferred thepwm.py
to the RPICO flash, the all numbers of array are lower than next tests - without copy again thepwm.py
file. I repeated the tests just doing a soft reset (CTRL+D
) and results are still all bigger. And look that (below in the Tests executed) even I get out frompicocom
and connect again, the result still happen with all numbers bigger. And, finally, if I power off and power on (usb cable disconnect and connect) the RPICO, and execute again the tests, numbers are still bigger. But, always when I transfer thepwm.py
file to RPICO, and execute a new test, values back to be lower numbers (like as the first line below). Why that?Look that first line numbers are lower than second line. First line is when the test was execute just after I trasnferred the
pwm.py
file to the RPICO flash. Second line is a test when IS NOT the first test after pwm.py is transferred.The code:
Tests executed:
Ps: the tests was executed exactly as pasted below:
Any idea what are happening?
Thank you.