PyBoard SPI strange behavior

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: Latvia
Contact:

Re: PyBoard strange behavior on SPI.write(bytes)

Post by kamikaze » Wed Dec 07, 2016 1:47 pm

dhylands wrote:Which pin are you using for CS?
it's an SS pin for SPI, Y5 or X5 depending on bus

User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: Latvia
Contact:

Re: PyBoard SPI strange behavior

Post by kamikaze » Thu Dec 08, 2016 1:16 am

I have also tried to use another pin like Y4 - same problem on Ctrl+D in REPL :roll:

User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: Latvia
Contact:

Re: PyBoard SPI strange behavior

Post by kamikaze » Thu Dec 08, 2016 1:27 am

ok. now it is official. When SD card is being inserted and code (that initializes SPI and sends some init data to device) launched from it in REPL and then Ctrl+D is being pressed - BOOM, SD card error occurs.

Guys, do you have SD card and any SPI device (SSD1306 is preferable, but let's try anything for now) to test this case? :roll:

I have created a bug report

User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: Latvia
Contact:

Re: PyBoard SPI strange behavior

Post by kamikaze » Sun Dec 11, 2016 12:25 am

running test code from PYBFLASH is ok, except of its capacity... I can store only 10 frame files. Original animation is much longer and smoother. There is a more valuable problem with SD - I can't even open() and read() files while running from SD card. No CTRL+D pressing is needed. When SPI display is being initialized - there is a problem. And "import os" just hangs REPL then. So that SD card problem now is not marginal anymore.

Test animation is here

User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: Latvia
Contact:

Re: PyBoard SPI strange behavior

Post by kamikaze » Sun Dec 11, 2016 1:40 am

So here I am again.

To reproduce both ways:

1) get "display" and "frames" directories, and "animation.py" file from https://github.com/kamikaze/pyboard-examples
2) store "frames" directory on flash and SD card
3) store "display" directory and "animation.py" on flash (actually it doesn't matter where you will run the code from)
4) Run in REPL and get the output:

Code: Select all

>>> import animation
>>> animation.run_test_from_flash()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/flash/animation.py", line 24, in run_test_from_flash
  File "/flash/animation.py", line 21, in run_test
  File "/flash/animation.py", line 16, in run_animation
  File "/flash/display/ssd1322.py", line 95, in send_buffer
  File "/flash/display/common.py", line 38, in write
KeyboardInterrupt: 
>>> animation.run_test_from_sd()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/flash/animation.py", line 28, in run_test_from_sd
  File "/flash/animation.py", line 21, in run_test
  File "/flash/animation.py", line 13, in run_animation
  File "/flash/animation.py", line 7, in read_frames
OSError: [Errno 5] EIO
(First test is being killed manually by hitting Ctrl+C)

The only difference is where the code tries to get files from after SPI device is being initialized. And SD card is dead already. Unfortunately I don't have any other SPI device to prove that fault. So any help would be great. The only thing is needed:

1) initialize SPI and device
2) send some commands and/or data to SPI device
3) try to open() and read() any file from /sd/path

User avatar
kamikaze
Posts: 154
Joined: Tue Aug 16, 2016 10:10 am
Location: Latvia
Contact:

Re: PyBoard SPI strange behavior

Post by kamikaze » Mon Dec 12, 2016 1:35 am

I've found the reason (but still not a solution):

https://github.com/kamikaze/pyboard-exa ... 322.py#L64

This line turns off a sleep mode of the screen. Datasheet says that in sleep mode display consumes 10 uA. So I suppose when sleep mode turns off (display starts to show stuff only then) - more current is being consumed and something goes wrong with SD. Is it possible?

Post Reply