The most basic program for SPI communication

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Mrinal
Level 4
Level 4
First solution authored 50 replies posted 25 replies posted

After going through a few application notes and datasheets of the SPI module, I wrote a very basic program to send one bite data through the SPI.

   

But the oscilloscope does not show any thing on the MOSI pin.

   

(All default settings of the SPI module)

   

My program is:

   

  SPI1_Start();
  SPI1_SpiUartWriteTxData(82);

   

Now the binary equivalent of 82 should be sent through the MOSI pin, but that pin does not generate pulses at all.

   

Where am I going wrong 😞

0 Likes
8 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received
        Did you check your pull up resistors? Post you program so we can check it for correct operation.   
0 Likes
Mrinal
Level 4
Level 4
First solution authored 50 replies posted 25 replies posted

My program only contains those two lines of codes mentioned above.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Are you sure you are looking at the correct pins? Are the pins configured correctly as digital outputs?

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Post your program!!!

0 Likes
Mrinal
Level 4
Level 4
First solution authored 50 replies posted 25 replies posted

There are no external pins in the SPI component.

   

My program is:

   

 SPI1_Start();
  SPI1_SpiUartWriteTxData(82);

   

 

   

That's all, just two lines apart from the automatically generated codes.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Without your project nobody can look at your component configuration, or try it at home.

0 Likes
Mrinal
Level 4
Level 4
First solution authored 50 replies posted 25 replies posted

I would certainly post the schematic and entire project file, but there's nothing much there.

   

1. I simply dragged and dropped a SCB module, named it SPI1 and configured it as SPI master.

   

2. In the C file, I added the following code

   

 SPI1_Start();
  SPI1_SpiUartWriteTxData(82);

   

3. I am not getting any signal on the MOSI pin in the pioneer kit.

   

(There is no slave connected)

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Since you didn't want to post your project. I am sending you a project that has a SPi master and an SPi slave with a led light read out that displays the states. There is a PDF file that explains the program at the end of the workspace explorer  program.

0 Likes