Maple Mini SPI Slave - data get corrupt

Maple Rev3, Maple Rev 5 and Maple Ret 6, iTead Maple etc
ncw2k69
Posts: 10
Joined: Tue Jul 26, 2016 7:52 pm

Maple Mini SPI Slave - data get corrupt

Postby ncw2k69 » Wed Jul 27, 2016 8:56 pm

Hi everyone,
I need help! :(
On SPI protocol in slave mode, after some time (5-10min) the byte that i received from master is corrupt, data on logic analyzer shows correctly.
After i try to send a byte to master, the spi interface becomes unresponsive, but the rest of code works.
I tested with 2 maple mini boards, one in master mode and the other in slave, they seems to work ok, but doesn't work with the other cpu i described above.
I'm trying to split apart the mainboard cpu from a display with keypads. After using the logic analyzer i assumed that the comunnication protocol is SPI, i have a single data line (receive-transmit), clock line, chip select and a key request line that goes high when a key is pressed. Package size is one byte (8bits) and SPI mode/phase is 1,1 sor spi_mode_3

For writhing code i use leaflab ide, the green one...

On arduino uno, the program runs correctly

User avatar
Pito
Posts: 612
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Maple Mini SPI Slave - data get corrupt

Postby Pito » Wed Jul 27, 2016 8:59 pm

Mind the SPI slave mode clock speed is usually limited. So double check the SPI clock speeds.

ncw2k69
Posts: 10
Joined: Tue Jul 26, 2016 7:52 pm

Re: Maple Mini SPI Slave - data get corrupt

Postby ncw2k69 » Wed Jul 27, 2016 9:02 pm

the cpu i'm trying to comunicate is around 175khz... or something like that, is a very old one.
in my case the spi master (cpu) sends the clock, not the slave
... or i'm doing something wrong

User avatar
Pito
Posts: 612
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Maple Mini SPI Slave - data get corrupt

Postby Pito » Wed Jul 27, 2016 9:11 pm

Your
MM is the Slave
Old_CPU is the Master? Is the old_cpu 3.3V SPI signaling?

ncw2k69
Posts: 10
Joined: Tue Jul 26, 2016 7:52 pm

Re: Maple Mini SPI Slave - data get corrupt

Postby ncw2k69 » Wed Jul 27, 2016 9:15 pm

Mainboard CPU (Master) - Maple Mini (Slave) on SPI 2 - when i do spi.transfer i get a corrupted byte
Maple Mini (Master) - Display with keypad (Slave) SPI 1 - this one works perfectly

Old cpu is 5V and i use a logic convertor from 5v to 3.3v

I'm trying to place Maple Mini between Cpu and Display

User avatar
Pito
Posts: 612
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Maple Mini SPI Slave - data get corrupt

Postby Pito » Wed Jul 27, 2016 9:19 pm

Logic convertor = issues :)
What kind of it do you use?

ncw2k69
Posts: 10
Joined: Tue Jul 26, 2016 7:52 pm

Re: Maple Mini SPI Slave - data get corrupt

Postby ncw2k69 » Wed Jul 27, 2016 9:20 pm

in my area i use this one https://www.robofun.ro/logic-level-conv ... 0convertor
i think is a sparkfun clone, or someting...

User avatar
Pito
Posts: 612
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Maple Mini SPI Slave - data get corrupt

Postby Pito » Wed Jul 27, 2016 9:32 pm

When the Old_CPU is the master, how do you do the Slave's reading the SPI register? Not sure MapleMini has got the Slave mode implemented via spi.transfer..
http://www.stm32duino.com/viewtopic.php ... =10#p13036

ncw2k69
Posts: 10
Joined: Tue Jul 26, 2016 7:52 pm

Re: Maple Mini SPI Slave - data get corrupt

Postby ncw2k69 » Wed Jul 27, 2016 9:37 pm

Spi.beginSlave and then a made a new method that check if i have data in buffer, if true, i do spi.read or spi.transfer
I will post the code i use after i get back from work :roll:

stevestrong
Posts: 727
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Maple Mini SPI Slave - data get corrupt

Postby stevestrong » Thu Jul 28, 2016 8:28 am

reception buffer overflow? (but only after a while? hmmm)
How do you differentiate between spi.read and spi.transfer?
Actually, when receiving SPI data, some data will be anyway read out from the master, and if you don't set it, random data may disturb your spi master.


Return to “Maple”

Who is online

Users browsing this forum: No registered users and 1 guest