I wonder if anyone knows what the range of SPI Baud rates are for the Micro:Bit (v2)? The docs give an example setup of baudrate = 1000000
(ie 1MHz).
I have built a PIC based SPI client (slave) that drives a 20x4 line 'old fashioned' LCD display. This receives nicely from the Micro:bit.
I have tried increasing the Micro:bit SPI baudrate to ridiculous levels (10MHz) and also slowing it to 10 baud but everything still works as though the Micro:bit is still set at 1MHz.
Also, what is the max SPI buffer size on the Micro:bit please?
Any ideas please?
SPI baud rate
Re: SPI baud rate
The microbit port of MicroPython is a bit different to regular MicroPython and is based on the CoDAL.
It does seem like this is supposed to work though, when you construct a microbit.SPI instance
https://github.com/microbit-foundation/ ... _spi.c#L82
which then does
https://github.com/microbit-foundation/ ... l.cpp#L230
and then
https://github.com/lancaster-university ... I.cpp#L192
(that last one gives you the limits)
Are you able to confirm with a scope or logic analyser that setting the baudrate parameter has no effect? (Although it certainly sounds like it doesn't).
The last link above also has the transfer function, which uses
Code: Select all
#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA)
#define SZLIMIT 0xffff
#else
#define SZLIMIT 0xff
#endif
Re: SPI baud rate
Thanks, Jimmo. I can get it on a scope in a couple of weeks so that will be interesting.
Re: SPI baud rate
I noticed this sometime ago, the test I did was to write 10KB sequentially to sram with a timer at the end of the loop. Entering a frequency of 600000 (and anything above that) I got a time of ~2.7 seconds. That was the best I could do with the test I was using.
I did the same test using JavaScript setting a frequency of 1000000 and got a time of 0.8 seconds. I could not better that even when I raised the frequency value. Going below 1MHz the time increased significantly.
Not a very scientific test but the difference in times gave me a pretty good idea of how bad the Python spi is if you need the speed.
I am interested in seeing the results of your scope readings, I would love to be able to have the same speed in Python as I got in Java but I'm not sure that is possible.
I did the same test using JavaScript setting a frequency of 1000000 and got a time of 0.8 seconds. I could not better that even when I raised the frequency value. Going below 1MHz the time increased significantly.
Not a very scientific test but the difference in times gave me a pretty good idea of how bad the Python spi is if you need the speed.
I am interested in seeing the results of your scope readings, I would love to be able to have the same speed in Python as I got in Java but I'm not sure that is possible.