<?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>How to implement bit banging in NCS via TIME+GPIOTE+PPI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113843/how-to-implement-bit-banging-in-ncs-via-time-gpiote-ppi</link><description>Hello everyone, 
 Currently we&amp;#39;re working on improving our DALI driver on the nRF52840 chip and NCS2.6.0, because we&amp;#39;ve experienced issues with transmitting DALI bits with the correct timing. The issues we experience are similar with a previous blog post</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 Aug 2024 07:17:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113843/how-to-implement-bit-banging-in-ncs-via-time-gpiote-ppi" /><item><title>RE: How to implement bit banging in NCS via TIME+GPIOTE+PPI</title><link>https://devzone.nordicsemi.com/thread/497936?ContentTypeID=1</link><pubDate>Tue, 13 Aug 2024 07:17:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de01c5bf-26b3-4219-8abf-1642cfffe58a</guid><dc:creator>Quay</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;Thank you for your support.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to implement bit banging in NCS via TIME+GPIOTE+PPI</title><link>https://devzone.nordicsemi.com/thread/497928?ContentTypeID=1</link><pubDate>Tue, 13 Aug 2024 06:54:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85141006-80c7-444d-81b3-12d001b88e52</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Quay,&lt;/p&gt;
&lt;p&gt;The managing of Dali tx and rx is an IP in itself which many Lighting companies do it themselves and the efficiency of the implementation is never shared. Unfortunately we do not have a template to show to you on how this can be done.&lt;/p&gt;
&lt;p&gt;The timer can be setup somthing like below to achieve 1200bps baud on the Dali transport layer&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static struct dali_timer_data dali_timer_data =
{
    .p_instance = NRFX_TIMER_INSTANCE(CONFIG_DALI_TIMER_INSTANCE),
    .cfg = 
    {
        .frequency = NRF_TIMER_FREQ_16MHz,
        .mode = NRF_TIMER_MODE_TIMER,
        .bit_width = NRF_TIMER_BIT_WIDTH_32,
        .interrupt_priority = 0
    }
};

static void timer_handler(nrf_timer_event_t event_type, void *p_context)
{
    struct dali_timer *timer = (struct dali_timer *)p_context;
    struct dali_timer_data * timer_data = (struct dali_timer_data *)timer-&amp;gt;timer_data;
    if(event_type == NRF_TIMER_EVENT_COMPARE0)
    {
        timer-&amp;gt;callback(timer, timer-&amp;gt;user_data);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;GPIOTE and PPI can be configured something like this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_GPIOTE-&amp;gt;CONFIG[GPIOTE_CH_OUT] = GPIOTE_CONFIG_MODE_Task &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos |
                                    GPIOTE_CONFIG_POLARITY_HiToLo &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos |
                                    PIN &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos |
                                    GPIOTE_CONFIG_OUTINIT_High &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos;

NRF_TIMER3-&amp;gt;BITMODE = TIMER_BITMODE_BITMODE_32Bit &amp;lt;&amp;lt; TIMER_BITMODE_BITMODE_Pos;
NRF_TIMER3-&amp;gt;PRESCALER = 0;
NRF_TIMER3-&amp;gt;SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled &amp;lt;&amp;lt; 0;
NRF_TIMER3-&amp;gt;MODE = TIMER_MODE_MODE_Counter &amp;lt;&amp;lt; TIMER_MODE_MODE_Pos;
NRF_TIMER3-&amp;gt;CC[0] = COUNT_LIMIT;
NRF_TIMER3-&amp;gt;TASKS_START = 1;

NRF_PPI-&amp;gt;CH[PPI_CH_0].EEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;EVENTS_IN[GPIOTE_CH_IN];
NRF_PPI-&amp;gt;CH[PPI_CH_0].TEP = (uint32_t)&amp;amp;NRF_TIMER3-&amp;gt;TASKS_COUNT;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>