kendryte / kendryte-standalone-sdk

Standalone SDK for kendryte K210
https://kendryte.com
Apache License 2.0
440 stars 161 forks source link

SPI slave interface send out the first bit wrong. #128

Open Winnaries opened 3 years ago

Winnaries commented 3 years ago

BUG REPORT

Expected behavior

The first bit transmitted to the master, after READ_BLOCK, is 0xff.

Actual behavior

The first bit transmitted to the master, after READ_BLOCK, is 0x7f where the first and MSB is dropped, as you can see in the picture.

image

Test code

Please follow this implementation https://github.com/kendryte/kendryte-standalone-demo/tree/develop/spi_slave, but instead of initializing test_data_temp[1024] values via master's WRITE_BLOCK, please initialize it on the slave to the values in the shown in the picture above. Notice that we have to reorder the bytes as followed, because default frame_width for READ_BLOCK is 32.

FYI: Those values are a part of JPEG header, namely the first four bytes.

/* slave test_data init */
test_data_temp[0] = 0xe0; 
test_data_temp[1] = 0xff; 
test_data_temp[2] = 0xd8; 
test_data_temp[3] = 0xff; 

Document version

Q: Which branch are you on? If you know the Git revision then add it here as well. A: develop

Hardware

Which hardware do you use? A: Sipeed M1W

System

Q: What system do you use? A: linux_x86

ramonaerne commented 2 years ago

Did you notice that the pin setup is wrong spi_master.c#L27 MISO and MOSI pin are the same.