Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[ARM] [ASK]SPI sending data problem

Status
Not open for further replies.

Ahmad Edi Saputra

Junior Member level 2
Joined
Apr 2, 2015
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
209
i am gonna send data via SPI, but i don't have any idea why my data doesn't send correctly, i send it from STM32f4 discovery board to Arduino (as console slave). if i send my data with debugging mode it send correctly, but if i send normally, it doesn't send properly. does anyone have an idea about it?
 

When you ask a question please add some references for us like schematic/code etc.
 

What is debugging mode and normal mode in your case???
 

When you ask a question please add some references for us like schematic/code etc.

i just connect PA5, PA6, and, PA7 STM32f407vg to SCK MISO and MOSI Arduino, and PA4 to SS Arduino, i am sure it is correct because sometimes my data can be send correctly

yesterday i read some sample of code that MISO on STM32f4 is used as input not alternative function, which one is correct? as input or alternative function. i use as alternative function before, and i haven't tried to change it as input yet.
 

What is debugging mode and normal mode in your case???

debugging is i use ST link on KEIL MDK5, with start debugging mode, so i run my code one by one and when i do, my data is send correctly.

normal mode i mean like i download my program into my STM32F4 and let it execute its code, i just wiring my board, i download my program, and i open serial monitor arduino, and i see my data doesnt send correctly, for example i send 3 byte data 0xFF 0x40 0x50. if i send via debug mode, it mean my data will send one byte one at a time, on serial monitor is appeared 0xFF 0x40 0x50. but if i send all of it directly, sometime i got value 0x0F 0x40, 0x51 or any wrong value
 

Hello!

Your description is still very vague. Here are some things you can check:
- You send from STM32f4xxx. Are you sure that you are not sending too fast for Arduino?
- Have you checked clock phase, clock polarity?
- Have you checked that one is master and one is slave (i.e not both slaves or both masters)?
- What do you call "sometimes" (sometimes data is sent correctly). I mean, if you send random data
one byte at a time, you have one chance on 256 that the data will be right.
etc...

Dora.
 

Have you checked that your SPI modes are compatible?
There are 4 different modes of data/clocking phases, so your two devices has to be compatible to each other.

The differnece between debug and release mode is timing, due to the extra debug code inserted in your program. This indicates that your SPI are synced the in a wrong mode.
 

Hello!

Your description is still very vague. Here are some things you can check:
- You send from STM32f4xxx. Are you sure that you are not sending too fast for Arduino?
- Have you checked clock phase, clock polarity?
- Have you checked that one is master and one is slave (i.e not both slaves or both masters)?
- What do you call "sometimes" (sometimes data is sent correctly). I mean, if you send random data
one byte at a time, you have one chance on 256 that the data will be right.
etc...

Dora.

i think, yes its too fast, because when i give some delay between one data to another, its work with delay about 100ms, thats why sometimes my data is sent correctly, i've checked all of it, i use mode 0 for stm as master and arduino as slave. so when i send data from 0 to 255, sometimes i got up to 20 error number, the rest 235 i receive correcly.

my question is, how do i know the spi timing between one data to another data, how big delay is really needed? i just tink that sending data throw SPI just about SCK freq, if slave have ability to receive master SCK clock frequency data will be sent correcly
 

Have you checked that your SPI modes are compatible?
There are 4 different modes of data/clocking phases, so your two devices has to be compatible to each other.

The differnece between debug and release mode is timing, due to the extra debug code inserted in your program. This indicates that your SPI are synced the in a wrong mode.

i've checked, i use spi mode 0 for both.

did you mean my program is inserted by debug code that cause my program get wrong?
 

Hello!

That's not a delay problem. It's a matter of how fast the clock is. I don't know too much
about Arduino, but the uno for example, uses small cheap processors, the frequency
of which might be quite low.
If the Arduino SPI clock should be at most, say, 10 MHz and the ARM clock is 20, I think
you can understand that there will be a problem.
Usually, there is a setup for a SPI peripheral. Check in the STM32 docs how to set the
SPI clock frequency.

Dora.
 

SPI clock (SCK) arduino is up to 2MHz, and i've set SCK STM32 about 2 MHz, my calculation is APB2 is 2x slower than processor, so 168 (STM clock) /2 = 89MHz. then i divide 89/256(prescaler), not even 1MHz right? but if i send directly for example 3 byte 0xFF 0x45 0x34 i receive 0xF0 0x22 0xDD or any wrong number, but when i insert delay between sending data its sent correctly. i've ever tested with PN532 NFC reader, and sometimes i have some error respon too, SCK of pn532 is up to 5MHz
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top