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
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog Raspberry Pico: talk to ICs with active high Chip Select (CS)
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 25 Apr 2025 10:10 AM Date Created
  • Views 512 views
  • Likes 10 likes
  • Comments 2 comments
Related
Recommended
  • raspberry
  • pico
  • spi

Raspberry Pico: talk to ICs with active high Chip Select (CS)

Jan Cumps
Jan Cumps
25 Apr 2025

SPI ICs usually have an active low chip select pin (~CS, nCS, ...).
I have a Texas Instruments IC (stepper motor driver DRV8711) that has an active high CS.

Initially, I bit-banged the CS pin: set it high with the GPIO API before communication, and low when finished. 
This is also what the Raspberry Pico SPI examples do.

    gpio_init(PICO_DEFAULT_SPI_CSN_PIN);
    gpio_put(PICO_DEFAULT_SPI_CSN_PIN, 0);
    gpio_set_dir(PICO_DEFAULT_SPI_CSN_PIN, GPIO_OUT);

void write(uint16_t reg){

    gpio_put(PICO_DEFAULT_SPI_CSN_PIN, 1); // add a few NOPs to stretch the time
    spi_write16_blocking(spi_default, &reg, 1);
    gpio_put(PICO_DEFAULT_SPI_CSN_PIN, 0); // add a few NOPss to stretch the time
}

This works, but I'd prefer to use the full SPI native driver functionality, if possible.

Invert CS behaviour of native Pico SPI driver

I found that you can inverse behaviour of GPIO pins. As it turns out, this also works for pins that are set to a SPI function:

    // CS is active-high, invert pin action
    gpio_set_function(PICO_DEFAULT_SPI_CSN_PIN, GPIO_FUNC_SPI);
    gpio_set_outover(PICO_DEFAULT_SPI_CSN_PIN, GPIO_OVERRIDE_INVERT );

void write(uint16_t reg){
    spi_write16_blocking(spi_default, &reg, 1);
}

Here is a capture of a conversation, fully managed by the SPI API command spi_write16_blocking().
The CS is active high, as needed by the DRV8711 pin.

image

  • Sign in to reply
  • Jan Cumps
    Jan Cumps 4 months ago in reply to shabaz

    There are a number of great ICs at that price range. The cost may come later, because they may require a microcontroller with a lot of free IOs. 8 pins (10 including step and dir)  per motor if you aren't sure of the final design.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz 4 months ago

    Interesting that it's active high.. I think I now know why though:

    I added a resistor R30 to my motor PCB last night; in my case the Toshiba chip has an enable pin (ENA_X) which is active low (I should have named it better; I took the naming from the datasheet, bit weird how they are using _X to perhaps indicate negation), and there's a chance the chip will be enabled if the power is applied before the Pi Pico is powered up. 

    The Toshiba chip (TB67S581FNG) is not bad, for the very low price, it has some power capability (50V 2.5A capable), although I wish it went a bit higher (say 60-80V) to power larger stepper motors.

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • 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