Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 10 months ago.
sending data in SPI
Hi I am using STM32446RE. From google, I saw some one use STM32 library to control the SPI input and output. But I am thinking to use mbed instead. I found that in the hardware created by someone else, it is using PA4, PA5, PA6 and PA7 to be interfacing pins for SPI, corresponding to CS, SCK, MISO and MOSI.
I know that in the program I found online, they break 1 word into bits, it send one bit out at a time?
Anyway, the idea is to scan each bit, if the bit is HIGH, set MOSI to high, or set it to low.
I just found that nucleo also support an example of SPI. But it is far more simpler. But I don't know if the following make sense or not and I want to know if it will do the same thing as STM32 library or not.
Also, if I want to use different pins as NSS, SCLK, MISO and MOSI. Can I create the class in the following way?
PI device(PA_5, PC_6, PA_7);
PA_5=MOSI PA_6=MISO and PA_7=SCK,
1 Answer
8 years, 10 months ago.
Please try to understand SPI in more detail. From your comments above all you would achieve is very confused compiler with errors. Take a look here https://developer.mbed.org/handbook/SPI for more information on SPI , then look here for a tutorial on classes http://www.cplusplus.com/doc/tutorial/classes/ , there is a tutorial on classes on this site somewhere, and probably a more simple tutorial else where. If you want more detailed help then tell us more about what you are trying to do, the information you give above will not work with the mbed compiler or many other uCs SPI, mbed uses 8 or 16 bits of data (bytes or words).