<?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>Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/43951/receiving-dmx512-data-stream</link><description>Parts of this discussion started on this thread: i-am-trying-to-do-dmx512-protocol 
 I am using SDK 15.2.0 on an nRF52810. My test board is based off of a Laird BL651 which contains a real (not simulated) nRF52810. I&amp;#39;m using the Segger IDE. My code is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Mar 2019 18:33:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/43951/receiving-dmx512-data-stream" /><item><title>RE: Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/thread/174086?ContentTypeID=1</link><pubDate>Mon, 04 Mar 2019 18:33:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c23f49c-83f2-4393-b2a7-5c35b25d917a</guid><dc:creator>Alan</dc:creator><description>&lt;p&gt;I tried a stoprx followed by a flushrx and I get the same result.&lt;/p&gt;
&lt;p&gt;I set up the PPI to find the break event, checked it with a scope and it looks like I want.&amp;nbsp; However, I&amp;#39;m still not seeing the expected rx count in the uarte handler.&amp;nbsp; Here is my PPI setup, maybe you can spot a problem or a better way?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    // Break begins on High to low transition, reset and start timer
    NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;EVENTS_IN[0];
    NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_TIMER1-&amp;gt;TASKS_START;
    NRF_PPI-&amp;gt;FORK[0].TEP = (uint32_t)&amp;amp;NRF_TIMER1-&amp;gt; TASKS_CLEAR;
    
    // Stop count on low to high transition, only count when line is low
    NRF_PPI-&amp;gt;CH[1].EEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;EVENTS_IN[1];
    NRF_PPI-&amp;gt;CH[1].TEP = (uint32_t)&amp;amp;NRF_TIMER1-&amp;gt;TASKS_CAPTURE[0];
    NRF_PPI-&amp;gt;FORK[1].TEP = (uint32_t)&amp;amp;NRF_TIMER1-&amp;gt;TASKS_STOP;
    
    // StopRX when count matches compare
    NRF_PPI-&amp;gt;CH[2].EEP = (uint32_t)&amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[1]; 
    NRF_PPI-&amp;gt;CH[2].TEP = (uint32_t)&amp;amp;NRF_UARTE0-&amp;gt;TASKS_STOPRX;
    NRF_PPI-&amp;gt;FORK[2].TEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;TASKS_OUT[2];  // for scope
//    NRF_PPI-&amp;gt;FORK[2].TEP = (uint32_t)&amp;amp;NRF_UARTE0-&amp;gt;TASKS_FLUSHRX;
    
    // Timer 1, sends event when count reaches 50us
    NRF_TIMER1-&amp;gt;MODE = (uint32_t)TIMER_MODE_MODE_Timer&amp;lt;&amp;lt;TIMER_MODE_MODE_Pos; // Timer mode
    NRF_TIMER1-&amp;gt;BITMODE = (uint32_t)TIMER_BITMODE_BITMODE_24Bit&amp;lt;&amp;lt;TIMER_BITMODE_BITMODE_Pos; // 32 bits resolution
    NRF_TIMER1-&amp;gt;PRESCALER = (uint32_t)0; // Prescaler = 0
    NRF_TIMER1-&amp;gt;CC[1] =  (uint32_t)800;

    // Event on GPIO high to low
    NRF_GPIOTE-&amp;gt;CONFIG[0] = GPIOTE_CONFIG_MODE_Event &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos | 
                                         GPIOTE_CONFIG_POLARITY_HiToLo &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos | 
                                         YELLOWWIRE &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos | 
                                         GPIOTE_CONFIG_OUTINIT_Low &amp;lt;&amp;lt; GPIOTE_CONFIG_OUTINIT_Pos;

    // Event on GPIO low to high
    NRF_GPIOTE-&amp;gt;CONFIG[1] = GPIOTE_CONFIG_MODE_Event &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos | 
                                         GPIOTE_CONFIG_POLARITY_LoToHi &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos | 
                                         YELLOWWIRE &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos | 
                                         GPIOTE_CONFIG_OUTINIT_Low &amp;lt;&amp;lt; GPIOTE_CONFIG_OUTINIT_Pos;

#if 1 // For scoping, toggle gpio on break detected
    NRF_GPIOTE-&amp;gt;CONFIG[2] = GPIOTE_CONFIG_MODE_Task &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos | 
                                         GPIOTE_CONFIG_POLARITY_Toggle &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos | 
                                         ORANGEWIRE &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos | 
                                         GPIOTE_CONFIG_OUTINIT_Low &amp;lt;&amp;lt; GPIOTE_CONFIG_OUTINIT_Pos;
#endif

                                             

    NRF_TIMER1-&amp;gt;TASKS_START = (uint32_t)1; // start the timer

    NRF_PPI-&amp;gt;CHENSET = (uint32_t)(1&amp;lt;&amp;lt;0); //Enable PPI channel0
    NRF_PPI-&amp;gt;CHENSET = (uint32_t)(1&amp;lt;&amp;lt;1); //Enable PPI channel1
    NRF_PPI-&amp;gt;CHENSET = (uint32_t)(1&amp;lt;&amp;lt;2); //Enable PPI channel2
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I tied the uart rx line to a gpio to use with the PPI.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m expecting when I tell the uart to receive 513 bytes and then send it 65 bytes followed by a break that the uart handler will get called with an&amp;nbsp;NRFX_UARTE_EVT_RX_DONE event and have a count of 65.&amp;nbsp; But that isn&amp;#39;t happening.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/thread/172665?ContentTypeID=1</link><pubDate>Mon, 25 Feb 2019 01:23:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5628fdd2-ee86-47a2-b42c-c1bc1a075d6e</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;I take it you separately triggered first the STOPRX and then the FLUSHRX? Both would be required .. there were some posts regarding PPI, such as&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/38819/frequency-measurement-accuracy"&gt;this&lt;/a&gt;&amp;nbsp;question. I won&amp;#39;t have time to look at testing this for a while, but&amp;nbsp;could try later in the week if needed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/thread/172637?ContentTypeID=1</link><pubDate>Sun, 24 Feb 2019 03:03:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f79e4d9-9e36-429c-a00b-e6884eab4113</guid><dc:creator>Alan</dc:creator><description>&lt;p&gt;I tried&amp;nbsp;FLUSHRX in the error handler, but got the same results.&lt;/p&gt;
&lt;p&gt;It will probably take me a while to figure out how to&amp;nbsp;setup PPI to trigger on&amp;nbsp;a 60us low signal. Any hints would be appreciated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/thread/172628?ContentTypeID=1</link><pubDate>Sat, 23 Feb 2019 22:40:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e85802d8-e590-407b-b739-aed3d3872151</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;The goal is to actually not use the Uart to detect the break, since the message frequency is so slow. Instead turn off the Uart:&amp;nbsp;&lt;em&gt;The UARTE receiver will be in its lowest activity level, and consume the least amount of energy, when it is stopped, i.e. before it is started via STARTRX or after it has been stopped via STOPRX and the RXTO event has been generated&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Instead monitor the Rx line with a timer or simple port event edge detection to locate the end-of-break, as with most RS485 systems, and link that to the STARTRX of the Uart using PPI. That way the break is detected and a hardware-triggered STARTRX command is sent to the Uart. The PPI sampling is at 16MHz, so 10uSecs is plenty of time for timer or port to tell the Uart to start without using interrupts or waking the cpu. The end-of-packet is then detected by the same timer which is now running in time-since-last-char mode, which generates an interrupt on timeout - or PPI-triggered event - and thence issues the STOPRX as we know the FIFO buffer is empty. I haven&amp;#39;t tried this on this specific device, but it works well on other systems.&lt;/p&gt;
&lt;p&gt;If you do want use the Uart to detect the break, I think you have to do a FLUSHRX after the STOPRX generated by &lt;span&gt;&lt;em&gt;nrfx_uarte_rx_abort()&lt;/em&gt;&lt;/span&gt;, otherwise the DMA doesn&amp;#39;t finish transferring pending data from the RX FIFO and thence generate the RX_DONE you are hoping for. Adding the flush might fix the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/thread/172602?ContentTypeID=1</link><pubDate>Sat, 23 Feb 2019 06:55:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bb191d3-f956-48d6-aefd-c95c3d25f46a</guid><dc:creator>Alan</dc:creator><description>&lt;p&gt;The DMX controller sends a Break because that is how DMX is defined.&amp;nbsp; It is a pretty old standard. Here is a link if you are interested: &lt;a href="https://www.freestylersupport.com/wiki/dmx_basics:dmx_timing"&gt;DMX&lt;/a&gt;.&amp;nbsp; Basicly the signal goes low for 88us-1sec, then high for about 10us, then you get up to 513 bytes of data at 250Kbaud with two stop bits, but delays can occur between bytes as long as the whole packet takes less than 1 second, but then next packet can start right away if it wants to.&amp;nbsp; Typically a packet take about 22ms, but it can be much quicker if not much data is sent. Most UARTs detect the initial low as a Framing error or as a Break, and handle the remaining incoming data just fine. The&amp;nbsp;&lt;span&gt;nRF52810 seems to be handling the data just fine too, except I haven&amp;#39;t found a way to determine how many bytes just got sent.&amp;nbsp; If I had a dedicated micro, I could just put it in a tight loop and count the characters as they come in, but the&amp;nbsp;nRF52810 has other things to do, so that is not an option.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Wouldn&amp;#39;t a timer input that detects&amp;nbsp;a low signal for say 60us, have the same issue I&amp;#39;m currently having?&amp;nbsp; The UART would still cause a framing or break error.&amp;nbsp; Also the re-priming you mentioned could be a big issue too since there might only be 40us before the data gets sent.&amp;nbsp; I can loose an occasional packet, but loosing too many would affect the performance too much.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Questions for you:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;You said something about re-priming the uart.&amp;nbsp; Do you have any information on how much time is required after an abort before data can be received again?&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Regarding the missing RX_DONE event,&amp;nbsp;in the code from my first post, I replaced the call to&amp;nbsp;nrfx_uarte_rx() with a call to&amp;nbsp;nrfx_uarte_rx_abort so that when the BREAK is handled the RX stops.&amp;nbsp; Should that cause an NRFX_UARTE_EVT_RX_DONE event that gets seen by the handler?&amp;nbsp; (It doesn&amp;#39;t currently)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Is there any other way to find the number of bytes received?&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;My backup plan it to fill the buffer with known data and scan it after the data has been received to see what has changed, but that&amp;#39;s a terribly brute force approach and may not work.&amp;nbsp; Plus I have to deal with issues like what if the data sent matches my preset values.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/thread/172598?ContentTypeID=1</link><pubDate>Sat, 23 Feb 2019 04:44:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b563bf0-2274-4003-864e-94e1ae01f91a</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Maybe the error is real, and the uart needs to be stopped after the abort before re-priming for the next message packet.&lt;/p&gt;
&lt;p&gt;Why does the DMX controller need to send a Break anyway? When the receiver needs to stop and process an incoming packet, usually it works better to attach the Rx input to a timer input in addition to the Uart, such that when no transition occurs within some specified interval an end Rx condition can be triggered. That timer monitoring can be initiated on the first Rx edge transition.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/thread/172586?ContentTypeID=1</link><pubDate>Sat, 23 Feb 2019 02:37:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c662783-a3ab-43f2-90fe-d0ffe7cf5df7</guid><dc:creator>Alan</dc:creator><description>&lt;p&gt;Here is an update.&amp;nbsp; The data in the buffer looks like I expect it to which is good,&amp;nbsp; but I still can&amp;#39;t tell how many bytes were written.&lt;/p&gt;
&lt;p&gt;I tried adding a call to&amp;nbsp;nrfx_uarte_rx_abort in the error handler, but didn&amp;#39;t get the results I was hoping for.&amp;nbsp; The documentation says an RX_DONE event will be generated, but the event handler sees the event.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Calling&amp;nbsp;&lt;span&gt;nrfx_uarte_rx_abort&amp;nbsp;has some undesired side effects too.&amp;nbsp; I sometimes get an extra ERROR event on the first character when I call&amp;nbsp;nrfx_uarte_rx to do the next read.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Except for the not knowing how many bytes were sent, the code I added in the first post seems to be working fine.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/thread/172407?ContentTypeID=1</link><pubDate>Fri, 22 Feb 2019 03:43:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3968e3a9-47f7-4eea-aebc-b284e19fee0d</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Yes, the problem is an &lt;em&gt;Error&lt;/em&gt; does not generate an &lt;em&gt;END&lt;/em&gt; event, so the break does not stop reception and populate the count register. You can manually generate a &lt;em&gt;Stop&lt;/em&gt; within the Break &lt;em&gt;Error&lt;/em&gt; interrupt handler which would work. Also&amp;nbsp;&lt;span&gt;&lt;em&gt;nrf_uarte_rx_amount_get()&lt;/em&gt; doesn&amp;#39;t return 32-bits, only 10-bits in a 32-bit field. Not sure why Nordic limited it to 10-bits ..&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regrettably there is no &lt;em&gt;SHORT&lt;/em&gt; between &lt;em&gt;Error&lt;/em&gt; and &lt;em&gt;End&lt;/em&gt; or &lt;em&gt;Stop&lt;/em&gt;; if there were you could just use that instead of manually doing it in the error event .. let&amp;#39;s ask Nordic to add it to the next die revision :-)&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/thread/172405?ContentTypeID=1</link><pubDate>Fri, 22 Feb 2019 03:26:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4921d8a-2c7e-4e04-abae-94c1742c1508</guid><dc:creator>Alan</dc:creator><description>&lt;p&gt;That does look like a problem (bug?).&amp;nbsp; But I also tried calling&amp;nbsp;nrf_uarte_rx_amount_get() which returns a uint32_t&amp;nbsp;and I&amp;#39;m still seeing 0 bytes transfered.&amp;nbsp; &amp;nbsp;The UARTE documentation makes it sound like the&amp;nbsp;RXD.AMOUNT register isn&amp;#39;t updated until the receive operation is complete and it sounds like an ERROR is not considered complete.&amp;nbsp; I even tried reading the&amp;nbsp;RXD.PTR and subtracting my buffer address and it still gives me 0.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/thread/172403?ContentTypeID=1</link><pubDate>Fri, 22 Feb 2019 03:02:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8b6c60c-1ff0-4d3f-875a-06cbebe02713</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Not sure if it&amp;#39;s an issue or not but the max Rx count on the nRF52810 is 1024 bytes, comfortably above the 513 you need, but note the receive structure appears to be only 8-bit and it looks like the code above is trying to use this (256-byte limit):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * @brief Structure for UARTE transfer completion event.
 */
typedef struct
{
    uint8_t * p_data; ///&amp;lt; Pointer to memory used for transfer.
    uint8_t   bytes;  ///&amp;lt; Number of bytes transfered.
} nrfx_uarte_xfer_evt_t;

#define UARTE0_EASYDMA_MAXCNT_SIZE 10
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Just checked and the nRF52832 has an 8-bit register, but the nRF52810 has a 10-bit register.. This is a software bug, methinks, since the 10-bit size is checked against an 8-bit register if the &lt;em&gt;nrfx_uarte_xfer_evt_t()&lt;/em&gt; code above is the correct version (15.2.0).&lt;/p&gt;
&lt;p&gt;65? Don&amp;#39;t know how that ties up ..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving DMX512 data stream</title><link>https://devzone.nordicsemi.com/thread/172402?ContentTypeID=1</link><pubDate>Fri, 22 Feb 2019 02:31:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:448a179c-2720-461d-8d12-831665903a87</guid><dc:creator>Alan</dc:creator><description>&lt;p&gt;I was wrong about the data replicating throughout the buffer.&amp;nbsp; I was checking this by pausing the code and examining the memory with the debugger.&amp;nbsp; I&amp;#39;m guessing that stopping the code doesn&amp;#39;t stop ongoing UART-DMA operations so the buffer continues to fill after the break, which is good for me.&lt;/p&gt;
&lt;p&gt;I still need a way to find the number of bytes received before the BREAK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>