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

Problem with SPI Mode 1


Best Answer baxter, 02 September 2013 - 09:47 PM

Well, everything is OK now ...

What I did:

(1) reloaded firmware V4.2.2.1 (2) started program and Saleae Logic (3) Saleae Logic crashed and wiped out all settings (4) restored settings (mode 1 and channels), did item (2) again (5) gave output as expected (e.g. mode 1)

Suspect the problem was Saleae Logic's fault from the beginning and not Netduino's.

Go to the full post


  • Please log in to reply
4 replies to this topic

#1 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 02 September 2013 - 07:56 AM

I am running Visual Basic Express 2010 with a Plus 2 and,

ClrInfo.clrVersion:					 4.2.0.0ClrInfo.clrVendorInfo:				  Netduino Plus 2 (v4.2.2.2) by Secret Labs LLCClrInfo.targetFrameworkVersion:	    4.2.0.0SolutionReleaseInfo.solutionVersion:    4.2.2.2SolutionReleaseInfo.solutionVendorInfo: Netduino Plus 2 (v4.2.2.2) by Secret Labs LLCSoftwareVersion.BuildDate:			  Jan 26 2013

I want,

SPI Mode = 1 (CPOL = 0, CPHA = 1)

 

My SPI Configuration declaration,

Dim clock_idle_state As Boolean = False 'low Dim clock_edge As Boolean = False 'trailing edge

 

Saleae Logic SPI settngs: CPOL = 0, CPHA = 1

Saleae tells me, "The initial (idle) of the CLK line does not match the settings", but I configured SPI for CLK idle low. The attached thumbnail shows clock idling high. I thought this was fixed with Firmware, v4.2.2.2.

Attached Files



#2 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 02 September 2013 - 05:04 PM

The clock seems to idle low in between transactions and I think that's what matters the most since the transitions are what drives the bus. Does clock idle low after the you have deasserted !cs? Does communication work with whatever device your trying to talk to?

#3 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 02 September 2013 - 07:17 PM

Hi hanzibal,

Well, this is all related to getting the CC3000 to work. I now have 5 CC3000 modules. four of them will not work with Valkyrie-MT's code; one works sometimes. The failure is always with Simple-Link start. The CC3000 is very picky about SPI so I decided to go through the First Host SPI Write Operation myself.  http://processors.wiki.ti.com/index.php/CC3000_Serial_Port_Interface_(SPI)

However, the point here is that I have the Netduino configured as SPI mode 1 and the Saleae configured to receive mode 1, but Netduino Plus 2 is not outputting mode 1 initially. Saleae is sampling high upon start and rejecting it as invalid mode 1.  It idles low after deasserting CS.

Public Sub New(CSPin As OutputPort, EnPin As OutputPort, Intpin As InterruptPort)        'Setup for SPI Mode 1; Set SPI Configuration vars        '================================================        Dim ChipSelect As Microsoft.SPOT.Hardware.Cpu.Pin = DirectCast(-1, Cpu.Pin)         Dim chip_select_state As Boolean = False    'active low        Dim chip_select_setuptime As UInteger = 0        Dim chip_select_holdtime As UInteger = 0        Dim clock_idle_state As Boolean = False     'low        Dim clock_edge As Boolean = False           'trailing edge        Dim clock_rate As UInteger = 400            '400kHz        Dim SPI_module As SPI.SPI_module = Spi.SPI_module.SPI1        Dim SetSPI As New SPI.Configuration(ChipSelect,                                            chip_select_state,                                            chip_select_setuptime,                                            chip_select_holdtime,                                            clock_idle_state,                                            clock_edge,                                            clock_rate,                                            SPI_module)        Me.Spi = New SPI(SetSPI)                            CS = CSPin        VBAT_Enable = EnPin        IRQ = Intpin        'handler to process IRQ line active low        AddHandler IRQ.OnInterrupt, AddressOf CC3000IRQ        CS.Write(True)        IRQ.EnableInterrupt()        F_interrupts_enabled = True    End Sub

Perhaps I am missing some setting. I tried chip select hold/setup time = nonzero --> no effect and power cycling --> no effect.

Attached Files



#4 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 02 September 2013 - 07:59 PM

More on this ...  Gutworks #15 seems to show mode 1 working, http://forums.netdui...with-p2-fw-422/ He is using Firmware v4.2.2.1. I am also using this version. Very confusing, where is my problem coming from. Maybe the answer is to reinstall the firmware.



#5 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 02 September 2013 - 09:47 PM   Best Answer

Well, everything is OK now ...

What I did:

(1) reloaded firmware V4.2.2.1 (2) started program and Saleae Logic (3) Saleae Logic crashed and wiped out all settings (4) restored settings (mode 1 and channels), did item (2) again (5) gave output as expected (e.g. mode 1)

Suspect the problem was Saleae Logic's fault from the beginning and not Netduino's.






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.