element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
STM32F4DISCOVERY Expansion Boards
  • Products
  • Dev Tools
  • STM32F4DISCOVERY Expansion Boards
  • More
  • Cancel
STM32F4DISCOVERY Expansion Boards
Forum Discover Wi-Fi Module SPI Communication
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join STM32F4DISCOVERY Expansion Boards to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 58 replies
  • Subscribers 7 subscribers
  • Views 7032 views
  • Users 0 members are here
  • wifi
  • stm32f4
  • discovery
  • spi
  • discover
Related

Discover Wi-Fi Module SPI Communication

Former Member
Former Member over 10 years ago

I've been messing around for days and have been unable to get the SPI communication with the Wi-Fi module to work, it would never respond at all. I couldn't get the demo UART code to respond either, but I need SPI for the increased bandwidth anyways. Am I doing something wrong, like missing a setup step or something? I'm not even sure if I connected the correct pins on the board, as there are 2 sets of SPI pins (SPI and SPI3), and I'm not 100% sure of which pin is the "ALRT" pin. I couldn't even get that interrupt to fire, despite numerous attempts to send data to the module. Does anyone have some working SPI code and wiring? I'm kind of at a loss here. I've put the code is this gist and this gist (too many lines to paste here), it looks rather shoddy as I was trying various things to get the module to do anything at all. I tried both DMAs and straight up interrupts, though I'd prefer to use DMAs to save CPU cycles.

  • Sign in to reply
  • Cancel

Top Replies

  • michaelkellett
    michaelkellett over 10 years ago in reply to Former Member +1
    Before you spend your money why not at least try to code it so that your waveforms look exactly like those on the data sheet ? And try clocking data out only when it's ready. These things might not make…
  • Former Member
    Former Member over 10 years ago in reply to michaelkellett +1
    Hi Michael, Thank you for your insight into SPI communication. I implemented that, driving a GPIO but with S/W and asserting prior to read/write and de-asserting when complete and it has improved communication…
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    Hi Jordan,

    My recollection is that the SN8200 would not reply to subsequent messages with the same sequence number, perhaps programmed to ignore those as the reply had already been sent.

     

    As far as the checksum, the spec says:

    Checksum: sum of L0, A | L1 and command ID. Note that this is different from the UART frame where the checksum calculation includes the payload field.

    It seems like bit 7 is not included. OTOH their example just below that states:

    After SPI serial protocol frame encapsulation, the payload becomes the following SPI frame:

    02 83 80 D0 04 33 00 D3 04

    02 -- SOM

    83 80 -- Payload length (3 octets, excluding CMD_ID)

    D0 -- 0x80 | CMD_ID_WIFI

    04 -- WIFI_GET_STATUS_REQ

    33 -- Sequence number

    00 -- STA interface

    D3 -- Checksum for “83 80 D0”

    04 -- EOM

     

    My calculator says that 83 80 D0 sums to 0x1D3. Lop off the high order bits and that becomes 0x53. So I guess they do include those.

     

    Thanks for the info on the /ALRT pin.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    No matter what I try I can't seem to receive anything, unless I set the SPI speed fast enough, then it starts receiving garbage. I've uploaded the correct firmware to the SN8200. Pins 20, 18, 16 and 14 on J6 are the SPI pins, right? I tried 2, 4, 6 and 8 originally but that did nothing at all.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    I'm using J6 12, 14, 16, 18 and 20 too. I thought I was having difficulty with NSS (20) so I just tied it to ground. On SPI4 (STM32F429I-Discovery) any baud rate prescaler from 4 through 128 works (don't recall if I tried 256.)

     

    At times the Murata stops sending replies. Some times that is resolved using the reset pin/button and at other times it may require a power cycle. It also doesn't like to be hammered by requests. I had to add a 50ms interval between exchanges.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    Well I think I'm getting actual responses now, but I can't verify the data, nor can I seem to clock the response out of the SPI. I have a circular DMA running with an empty buffer to keep the master clock going, but it doesn't seem to be doing anything. Can you check the code? I honestly don't think I know what I'm doing, pretty new to this thing...

     

    C file: https://gist.github.com/b987bbc998b0d27292af

    Header file: https://gist.github.com/579f9b3b8b42fb5adc7d

     

    There's a lot of commented out stuff, from various attempts to get the thing to work.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    I'll try to take a look at it tonight. It is unlikely I'll see anything as I started working with example code which I modified to suit my needs. ASll of the SPI and other setup was already in place. (In other words, probably know less about it than you.)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    Can I see your current code? I could probably figure out what I'm doing wrong by looking at it myself. I can't find the example code you're speaking of.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    Sorry - no can do.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    Why not exactly? And can you point me to where you got the example code you used?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    I started with C:\STM32Cube_FW_F4_V1.4.0\Projects\STM32F429I-Discovery\Examples\SPI\SPI_FullDuplex_ComDMA, part of the package downloaded from STM32CubeF4 Embedded software for STM32 F4 series (HAL low level drivers, USB, TCP/IP, File system, RTOS, Graphic - comi….

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    So it seems that by completing disabling the NSS pin on the STM32F4, it is actually working now. Next step is to ensure the data is correct. I'm also wondering if your "stops sending replies at times" has something to do with an oversight in sequence number. You said it won't reply to a previously used sequence number right? Maybe it overflows back to 0 and no longer works, effectively limiting you to 256 messages to the module before needing a reset. Only a theory though, haven't tested it yet.

     

    EDIT: Just tested it, it continues to reply even after the sequence number wraps around. Strange why it sometimes stops replying for no reason.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube