<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Zephyr SPI works in timer handler but not main function</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/112271/zephyr-spi-works-in-timer-handler-but-not-main-function</link><description>I&amp;#39;m having a problem using SPI within Zephyr. My custom nRF52840 board has 74HC959 shift registers to drive LEDs. I&amp;#39;m using the SPI bus to transfer LED on/off states and can successfully do so when spi_write_dt is only called from a kernel timer handler</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 20 Jun 2024 19:55:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/112271/zephyr-spi-works-in-timer-handler-but-not-main-function" /><item><title>RE: Zephyr SPI works in timer handler but not main function</title><link>https://devzone.nordicsemi.com/thread/489820?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2024 19:55:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:056b4c04-76da-4b99-89c7-d0b6c2f9d4dd</guid><dc:creator>abhav</dc:creator><description>&lt;p&gt;Turns out I overlooked the &lt;code&gt;count&lt;/code&gt; field of &lt;code&gt;tx_spi_buf_set&lt;/code&gt;. Even though the data to be written was len=2, the number of SPI buffer sets is only 1. Changing &lt;code&gt;count&lt;/code&gt; to 1 fixed my issue. Really not sure why this even worked in the first place within the timer context, though it explains the error code I was getting.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>