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.WriteRead() returns junk


  • Please log in to reply
25 replies to this topic

#21 FelixEmman

FelixEmman

    Member

  • Members
  • PipPip
  • 25 posts

Posted 25 February 2011 - 01:39 PM

CW2, does it still do this in the newest firmware releases (v4.1.0.6 RC2, v4.1.1 a7, and v4.1.2 a0)?
We found a few bugs in the .NET MF AT91 SPI code which were fixed about a month ago...
If there are specific issues, we should start a thread about them and see if we can get them resolved in the v4.1.1 beta.
Chris

I've looked through the NETMF source, and AT91 code is doing what CW2 indicated. I could send you a saleae analyzer SPI capture where you can see how MISO/MOSI/CS are being asserted, at very different times ... basically the signal just looks "dirty". It's probably because of the initialization that takes place at each SPI transfer. That SPI code leaves a lot to desire.

Hey FelixEmman,

What do you need? The latest production source should be posted. We are working on getting alpha/beta source up soon too so you can always build the latest "daily" code. The only things I know of which aren't posted right now are beta code.

Really quick...we have the source for 4.1.0.6 all ready to go. If you want to PM me with your e-mail address, I can send it to you. We're planning on calling 4.1.0.6 "gold" and changing RC2 to RTM in the next few days...we're just waiting the traditional 2 weeks to make sure no critical last-minute issues crop up.

Chris

Well, from what I understand the published code in the downloads section is still a few alphas/betas behind, so it doesn't include some of the code fixes. I'd assume hackers would still like to have the latest source, but I can understand the time lag until you guys make it to CodePlex. Probably more important, would be a Wiki where people could post tutorials and recipes for doing different things. I struggled all afternoon and last night to build 4.1.0.5 using GCC 4.4 and 4.2, with no success, I keep getting errors. There are scattered posts with bits and pieces on how this task could be achieved but ... it seems that what works for someone does not work for someone else. That unfortunate... I've been trying to build this source so I could start figuring out how to write a native SPI driver of some kind to fit my needs.
Either way please consider a Wiki in the near future. It's very time consuming to find good information in the forum, and it's often very scattered. The bigger this forum gets, the harder that will become. Again, no hard feelings.

I can wait a few more days for the next code release. I'll keep on trying to build the existing source in the meantime, that's my priority right now.

#22 ANW

ANW

    New Member

  • Members
  • Pip
  • 3 posts

Posted 26 February 2011 - 11:35 PM

Hi Folks Been trying to get SPI working to an ADXL345 accelerometer since I got my Netduino recently. After reading specs, these forums and the codebase, and with the use of a scope I found the following: The AT91 SPI driver specifically excludes the NPCS0/NSS pin (Netduino D4) from being used as chip select (CS) by the driver, but doesn't throw an exception if selected in the config. Presumably, this has something to with its mode in SPI slave role (which of course is not supported), tho I can't see why that should be so. I'm posting this for future reference, as it certainly was not obvious to me. Any chance this can be corrected (either to working or throwing exception)? Looking forward to the proper wiki/source reposititories :).

#23 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 27 February 2011 - 12:49 AM

The AT91 SPI driver specifically excludes the NPCS0/NSS pin (Netduino D4) from being used as chip select (CS) by the driver,
but doesn't throw an exception if selected in the config.


Hi ANW,

You should be able to use any of the digital pins as chip select, including the NSS pin.

I'll have to go back and check, but I believe that the code you're looking at deals with the special case of having the MCU control that SPI CS line vs. the .NET MF firmware.

If you are trying to use one of the digital pins as CS and it isn't working for you (but you can confirm that another digital pin does work, please let me know...and we can research further.

Welcome to the Netduino community,

Chris

#24 ANW

ANW

    New Member

  • Members
  • Pip
  • 3 posts

Posted 27 February 2011 - 01:13 AM

Hi ANW,

You should be able to use any of the digital pins as chip select, including the NSS pin.

I'll have to go back and check, but I believe that the code you're looking at deals with the special case of having the MCU control that SPI CS line vs. the .NET MF firmware.

If you are trying to use one of the digital pins as CS and it isn't working for you (but you can confirm that another digital pin does work, please let me know...and we can research further.

Welcome to the Netduino community,

Chris


Hi Chris,
Initially my Netduino has the latest release firmware 4.1.0 upd 5.
On this version the NSS pin would change static state according to the flag in the SPI config, but
never change state when SPI communications ran.
I could manipulate this pin outside SPI using normal outputpin control, but this was not precise enuough for my slave chip.

I updated to 4.1.0 upd 6 RC2 yesterday, and this is still the case.
I am now using D0 without an issue, and have confirmed all digital pins D0 thru D10 except D4 are working.

Aidan

#25 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 27 February 2011 - 01:19 AM

I updated to 4.1.0 upd 6 RC2 yesterday, and this is still the case.


Thanks for verifying that. I have put in a bug report in our internal system, and we will dig into this for the upcoming v4.1.1 release. [As a workaround for now, can you use another pin for CS or jumper a wire between D4 and another pin--and then use that other pin for CS in your code?]

Chris

#26 ANW

ANW

    New Member

  • Members
  • Pip
  • 3 posts

Posted 27 February 2011 - 01:26 AM

Thansk for verifying that. I have put in a bug report in our internal system, and we will dig into this for the upcoming v4.1.1 release. [As a workaround for now, can you use another pin for CS or jumper a wire between D4 and another pin--and then use that other pin for CS in your code?]

Chris

Chris,
No problems there, was just causing consternation..
The culprit I beleive is in AT91_SPI.cpp, a couple of bit of code:
if((Configuration.DeviceCS != GPIO_PIN_NONE) && (Configuration.DeviceCS != AT91_SPI0_NSS))

Aidan




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.