November 17th, 2009, 08:50 AM
Programing a development board in c to generate 101010.........on MOSI pin of spi
i have a dev board which has two spi interfaces,i want to generate a clock pulse on spi2 MOSI pin using c.i am new to enbedded programing and so dont know the basics of bit level programing.the board i am using is stm32 p103 from olimex based on arm cortex m3.
i have downloaded the spi driver from stm site.but i am unable to understand any part of the program as its too complex.any help???
November 17th, 2009, 10:39 AM
Why? If you want to do that, then you would configure the PIN as a GPIO rather than SPI and simply toggle it. In SPI you would place the data to be clocked out in the SPI data register, and start the SPI clock. This will generate the necessary 8 active transitions on the CLK while toggling teh data bits onto MOSI - you don't put "clock pulses" onto MOSI, that is for data.
Originally Posted by navs
I am speaking in general terms, I do not know the exact details of the STM32's SPI implementation, and am not about to wade through the reference manual for you (http://www.st.com/mcu/familiesdocs-1...mming%20Manual). However SPI is a very simple interface, so there are few variations on that.
November 17th, 2009, 11:26 AM
Perhaps you are trying to see something (anything!) come out the port?
Sometimes a CPU automatically generates the necessary outputs (clock and data for example) simply by writing a value to a specific register. Is that the case with your device?
If so, you could write a loop to write a value to the register over and over and then scope the pin(s) to see if anything sensible is coming out.
what are you trying to do, then?
"America's abundance was created not by public sacrifices to "the common good," but by the productive genius
of free men who pursued their own personal interests and the making of their own private fortunes. They did not
starve the people to pay for America's industrialization. They gave the people better jobs, higher wages and
cheaper goods with every new machine they invented, with every scientific discovery or technological advance --
and thus the whole country was moving forward and profiting, not suffering, every step of the way."
November 17th, 2009, 12:40 PM
November 17th, 2009, 12:40 PM
well my actual project is to interface a LCD display onto the board using spi interface.but i dont know to what extent the ready made driver code will automate the work for me.also i dont exactly know how to write c code to write binary data to a register.(is it possible to address a register in c directly).even if i could i dont know how to write a complex program like that.so i thought first i would check if i am able to send data to spi pin and if i am successful, then to go to the next step...
November 17th, 2009, 12:46 PM
Well you seem to be in over your head. It's a good place to learn to swim
Do not hook that LCD display up to your SPI interface yet. First you need to learn how to develop and test on an embedded system. Have you got a good scope handy?
I have requested this thread be moved to the Embedded Programming forum btw.
I no longer wish to be associated with this site.