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 clocking in single shifting bit each time...


  • Please log in to reply
4 replies to this topic

#1 Dave M.

Dave M.

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 28 June 2013 - 04:52 PM

I've been having trouble interfacing with a device using SPI, and finally I decided to use my logic analyzer to monitor the data.  The chip has a NOP command, so basically I'm just calling SPI.WriteRead( new byte[1] {0}, new byte[1] {0}) in a tight loop to see what happens.

 

It looks like the first NOP goes out correctly, but each successive NOP actually clocks out a bit where it shouldn't be.  The additional bit looks like it shifts down each time, which makes no sense to me.  Can anyone provide me with ideas as to what could cause this sort of behavior?

 

I imagine that the data in the MISO column is just whatever the device is sending back in response to what command it *thinks* it's getting from the Netduino, so for now I'm concentrating on making sure that only zeroes get clocked out in my test app.

 

Here is my SPI configuration code:

SPI.Configuration l6470 = new SPI.Configuration( Pins.GPIO_PIN_D2, false, 0, 0, true, false, 1000, SPI_Devices.SPI1);SPI spi = new SPI( l6470);OutputPort standby = new OutputPort( Pins.GPIO_PIN_D3, true); // standby / rst is active low

Attached Files



#2 Dave M.

Dave M.

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 28 June 2013 - 05:00 PM

I had gone straight to the SPI protocol analyzer last time, instead of looking at the traces.  In the second attachment in my original post, you will see that SCK transitions from high to low for some strange reason, so perhaps this is what's causing the problem.  But why wouldn't SCK stay high after transmitting each byte???



#3 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 28 June 2013 - 08:23 PM

I'd be looking at the SPI config and wondering if the device you are connecting to is say expecting the clock to be high when not in use but you'd configured the SPI on the Netduino to be low when not in use.

 

If you need more help it might be an idea to post a link to the datasheet for the device in question plus the SPI config code.

 

Regards,

Mark


To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#4 Dave M.

Dave M.

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 01 July 2013 - 02:13 PM

Thanks for your input, Mark.  I'm using an ST L6470 stepper driver.  I'll attach the datasheet and the screenshot to my original post.  I believe I have the SPI configuration correct, but clearly something is wrong so I'd appreciate any extra eyes on the timing diagram!  :)



#5 Dave M.

Dave M.

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 01 July 2013 - 10:23 PM

Maybe I should have posted my firmware info as well.  From this post, it sounds like people have had issues with SPI, though that still might not be what's causing my problem.

 

Oops... and I just realized that I am running on a Netduino Plus, not a NP2, so I have no idea what is expected, considering that I have the SDK for the NP2 installed on this computer.  I'll try my NP2 instead to see if there's any difference.

Pinging... TinyCLRHalSystemInfo.halVersion:               4.2.0.0HalSystemInfo.halVendorInfo:            Netduino Plus (v4.2.0.1) by Secret Labs LLCHalSystemInfo.oemCode:                  255HalSystemInfo.modelCode:                255HalSystemInfo.skuCode:                  65535HalSystemInfo.moduleSerialNumber:       FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFHalSystemInfo.systemSerialNumber:       FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFClrInfo.clrVersion:                     4.2.0.0ClrInfo.clrVendorInfo:                  Netduino Plus (v4.2.0.1) by Secret Labs LLCClrInfo.targetFrameworkVersion:         4.2.0.0SolutionReleaseInfo.solutionVersion:    4.2.0.0SolutionReleaseInfo.solutionVendorInfo: Netduino Plus (v4.2.0.1) by Secret Labs LLCSoftwareVersion.BuildDate:              Sep 19 2012SoftwareVersion.CompilerVersion:        410894FloatingPoint:                          TrueSourceLevelDebugging:                   TrueThreadCreateEx:                         TrueLCD.Width:                              0LCD.Height:                             0LCD.BitsPerPixel:                       0AppDomains:                             TrueExceptionFilters:                       TrueIncrementalDeployment:                  TrueSoftReboot:                             TrueProfiling:                              FalseProfilingAllocations:                   FalseProfilingCalls:                         FalseIsUnknown:                              False





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.