Hi,
So I am trying to communicate between an STM32f411 ( SPI Master ) and an Atmega328P (Spi Slave)
The first thing I notice is that when sending a Char from the master, the CLK Pulses are NOT present
so no SPI communication can take place.
I tried Software and also Channel 1, Same Problem
Please Fix this ASAP, as Nothing is working Here I tried I2c Slave on 328p Not working, I tried Uart Software on 328p Not Working
posted the Uart bug no one responded.
I am very disappointed!
SPI Master STM32f411
-
- Posts: 173
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 03, 2020 7:23 pm
- Has thanked: 52 times
- Been thanked: 25 times
Re: SPI Master STM32f411
Hi LeightM
Thanks for your reply for now I am just making sure everything works so
What I am doing is just INIT SPI master, Enable chip select, send char, 1 second delay and loop
have the scope connected to the CLK pin, but no clock is being outputted .
In the same file, I have a W25 flash and a micro SD card that use the SPI ( different Chip select ) and are working fine
so it should not be a matter of Config Register ,
Here is a quick FCFX attaced.
Thanks for your reply for now I am just making sure everything works so
What I am doing is just INIT SPI master, Enable chip select, send char, 1 second delay and loop
have the scope connected to the CLK pin, but no clock is being outputted .
In the same file, I have a W25 flash and a micro SD card that use the SPI ( different Chip select ) and are working fine
so it should not be a matter of Config Register ,
Here is a quick FCFX attaced.
- Attachments
-
- SPI TEST.fcfx
- (13.64 KiB) Downloaded 214 times
-
- Valued Contributor
- Posts: 421
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 76 times
- Been thanked: 232 times
Re: SPI Master STM32f411
I don't (yet) see anything wrong with the generated C code.
It's certainly very odd if it doesn't even toggle the clock output in software mode.
I presume the B1 CS pin is toggling, to prove the loop is running?
Could you do a simple "LED flash test" loop on A5 (CLK), using an output icon?
It's certainly very odd if it doesn't even toggle the clock output in software mode.
I presume the B1 CS pin is toggling, to prove the loop is running?
Could you do a simple "LED flash test" loop on A5 (CLK), using an output icon?
Re: SPI Master STM32f411
Hi LeighM,
Thanks for your reply,
your comment about connecting an LED got me thinking, maybe the scope is not triggering
and slave is not working which is why I don't have any rs232 out of the uart.
So I connected the logic analyzer to investigate, and sure enough to my surprise there it was
this is when sending a char.
. .
now when I try to receive 2x chars something strange is happening the master sends 0x55 twice
. .
is this something normal or I am doing wrong?
Thanks for your reply,
your comment about connecting an LED got me thinking, maybe the scope is not triggering
and slave is not working which is why I don't have any rs232 out of the uart.
So I connected the logic analyzer to investigate, and sure enough to my surprise there it was
this is when sending a char.
. .
now when I try to receive 2x chars something strange is happening the master sends 0x55 twice
. .
is this something normal or I am doing wrong?
-
- Valued Contributor
- Posts: 1367
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 330 times
- Been thanked: 475 times
Re: SPI Master STM32f411
Hi
Sorry if I'm off track here, been busy and only paying cursory glances through posts.
SPI is always bidirectional. When you wish to send anything it must be "clocked" in and out. That's easy to imagine when sending, but when receiving from a Slave, something must also be getting clocked out of the Master simultaneously (and vice-versa). As you send you also receive.
I've not had a chance to look at your chart, but it sounds perhaps like a buffer hasn't been cleared or set properly. I won't realistically get a chance to look at anything until the weekend (at best).
No doubt Leigh will explain things far better than I ever could
Regards
Sorry if I'm off track here, been busy and only paying cursory glances through posts.
SPI is always bidirectional. When you wish to send anything it must be "clocked" in and out. That's easy to imagine when sending, but when receiving from a Slave, something must also be getting clocked out of the Master simultaneously (and vice-versa). As you send you also receive.
I've not had a chance to look at your chart, but it sounds perhaps like a buffer hasn't been cleared or set properly. I won't realistically get a chance to look at anything until the weekend (at best).
No doubt Leigh will explain things far better than I ever could
Regards
Re: SPI Master STM32f411
Hi chipfrier , thanks for your reply
Yes , clock should always be provided by the master
And since the master is sending a char and then trying to receive another 2 chars , it should be providing clock for the slave to send the data , now the slave is not working but i have some questions,
Why the master is sending 0x55 when it should be only
Providing CLK and listening for incoming data ?
Also I was expecting the master to continue providing CLK until a sort of timeout kicks in , which it is also not happening
Yes , clock should always be provided by the master
And since the master is sending a char and then trying to receive another 2 chars , it should be providing clock for the slave to send the data , now the slave is not working but i have some questions,
Why the master is sending 0x55 when it should be only
Providing CLK and listening for incoming data ?
Also I was expecting the master to continue providing CLK until a sort of timeout kicks in , which it is also not happening
-
- Valued Contributor
- Posts: 1367
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 330 times
- Been thanked: 475 times
Re: SPI Master STM32f411
Hi
Each device Master/Slave has a buffer that simumtaneously gets clocked out/in. Whenever the Master sends anything this buffer is clocked out. Same in receive, as it receives the buffer contents are also clocked out. There is no scenario whereby you would only be providing a "clock" without transmitting data.
I can't find it just now, but I have a document somewhere that helps explain, meanwhile the attached from AD may help slightly. Benj (I think) wrote an informative piece on SPI / I2C in the Wiki.
Sorry to be brief heading out now.
Regards
Each device Master/Slave has a buffer that simumtaneously gets clocked out/in. Whenever the Master sends anything this buffer is clocked out. Same in receive, as it receives the buffer contents are also clocked out. There is no scenario whereby you would only be providing a "clock" without transmitting data.
I can't find it just now, but I have a document somewhere that helps explain, meanwhile the attached from AD may help slightly. Benj (I think) wrote an informative piece on SPI / I2C in the Wiki.
Sorry to be brief heading out now.
Regards
- Attachments
-
- SPI-Interface.pdf
- (427.14 KiB) Downloaded 207 times