SPI usage - Netduino Plus 2 (and Netduino Plus 1) - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

SPI usage


  • Please log in to reply
3 replies to this topic

#1 Wernfried

Wernfried

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts

Posted 04 January 2015 - 09:12 PM

I'm new using SPI, may be I'm doing it totally wrong.

 

I Need to switch an RF device and I figured out how the code Looks like. One short pulse has to be 250µs. Sending the code using a parallel port togehter woth a Delay functions works well.

 

Since the Delay Loop in .Net can be interrupted I had the idea using the MOSI of the SPI to generate the code. Thus I implemented a short test, but is seems the code is sent to fast. Thats why I made the following test:

 

The SPI config is the following:

            SPI.Configuration rcConfig = new SPI.Configuration(
                Pins.GPIO_PIN_D8,
                true,
                0,
                0,
                false,
                false,
                4,
                SPI.SPI_module.SPI1
            );

I declared a clock rate of 4KHz, which is a 250µs cycle. Then I send 1000 byte

            byte[] xxx = new byte[1000];
            for (int i = 0; i < 1000; i++) xxx[i] = 0xaa;
            spi.Write(xxx);

On the MOSI port (11) I expect a signal for about 2 seconds (1000 Byte x 8 bit x 250µs), but it is much lesser then a second.

 

Where is my fault? Does 4KHz mean, one Byte is sent within 250µs and not one Bit as I expected?

How can I send a code with a duration of 250µs for one bit?

 

 



#2 bulletprooffool

bulletprooffool

    Member

  • Members
  • PipPip
  • 12 posts

Posted 02 February 2015 - 08:19 AM

Hi - I am watching this as I have a similar project )but am not as far down the track as you)

Would you be able to share your method for interpreting the RF in the first place though?

 

Thanks



#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 02 February 2015 - 09:23 AM

Hi Wernfried,

With STM32 micros, peripheral clocks (UART, SPI, etc.) have a lower bound. If you specify a rate slower than that lower bound, they'll "bottom out" (unable to divide the clock any further).

You can work around this by lowering the MCU speed or mucking with the peripheral clocks--but at a base level NETMF's SPI feature will only go as slow as the biggest divisor lets it go.

If you run at, say, 60KHz, does the clock track accurately?

Chris

#4 Wernfried

Wernfried

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts

Posted 02 February 2015 - 02:43 PM

Thanks, this is what I figured out from another post in this forum.

 

I could workaround with sending not only 12 bits, but let's say 120 bits, where 10 bits have the state of the one. It acts as a zoom of the 12 bits to 120 bits. Thus I can run with the original MCU speed.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.