#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2009
    Posts
    5
    Rep Power
    0

    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???
  2. #2
  3. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1802
    Originally Posted by navs
    i want to generate a clock pulse on spi2 MOSI pin
    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.

    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.

    Clifford
  4. #3
  5. um, Hello?
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    FN23fc
    Posts
    719
    Rep Power
    160
    Perhaps you are trying to see something (anything!) come out the port?

    If so...

    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.

    If not...
    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."
    --Ayn Rand
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    May 2004
    Posts
    3,417
    Rep Power
    887
    This thread should be moved to the Embedded Programming forum.
    I no longer wish to be associated with this site.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2009
    Posts
    5
    Rep Power
    0
    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...
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    May 2004
    Posts
    3,417
    Rep Power
    887
    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.

IMN logo majestic logo threadwatch logo seochat tools logo