<?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>HFCLK Useage</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49943/hfclk-useage</link><description>SDK 15.3 API S132 
 How can i implement the HFCLK using softdevice or how can i enabled it 
 I need to be able to run an SK6812 which has the following timing requirements 
 
 using the LFCLK and 32MHZ crystal does not do it fast enough. I tried to make</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Jul 2019 20:39:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49943/hfclk-useage" /><item><title>RE: HFCLK Useage</title><link>https://devzone.nordicsemi.com/thread/200161?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 20:39:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3a4c252-298c-4517-b1b1-75a70813760f</guid><dc:creator>dmleone</dc:creator><description>&lt;p&gt;This is exactly what i needed. That link is perfect and using the PWM is a brilliant method. I have 1 question regarding his implementation and I don&amp;#39;t see why it is not working for me. It should, after displaying the color in my test function, after completing the sequence of the pwm enter the interrupt handler and reset pwm_sequenced_finished to true so it can display the next color. However, it does not enter the interrupt after the execution of the display function, but rather it seems to enter the interrupt handler after it completes my test function. so rather than flashing through RED, BLUE, and GREEN, it just stays RED.&lt;/p&gt;
&lt;p&gt;As a side note and i just thought this could be the issue. I am calling ws2812_led_test() from within a timer interrupt. so every 5 seconds i want it to cycle these colors. Is the fact i am in an interrupt preventing me from entering another interrupt? --This was the issue. I ran the function outside an interrupt and it worked as intended.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void ws2812_led_test(void){
    int i;
    
    for(i = 0; i &amp;lt; LED_MATRIX_WIDTH; i++){
        drv_ws2812_pixel_draw(i, 0, 65280UL);       // RED
    }
    drv_ws2812_display();
    nrf_delay_ms(250);

    for(i = 0; i &amp;lt; LED_MATRIX_WIDTH; i++){
        drv_ws2812_pixel_draw(i, 0, 255UL);         // BLUE
    }
    drv_ws2812_display();
    nrf_delay_ms(250);
    
    for(i = 0; i &amp;lt; LED_MATRIX_WIDTH; i++){
        drv_ws2812_pixel_draw(i, 0, 6711680UL);     // GREEN
    }
    drv_ws2812_display();
    nrf_delay_ms(250);

    for(i = 0; i &amp;lt; LED_MATRIX_WIDTH; i++){
        drv_ws2812_pixel_draw(i, 0, 0UL);
    }
    drv_ws2812_display();

}

uint32_t drv_ws2812_display(void)
{
    if(!pwm_sequencue_finished) 
    {
        return NRF_ERROR_BUSY;
    }
    convert_rgb_to_pwm_sequence();
    pwm_sequencue_finished = false;
    uint32_t err_code = nrfx_pwm_simple_playback(&amp;amp;m_pwm0, &amp;amp;pwm_sequence, 1, NRFX_PWM_FLAG_STOP);
    return err_code;
}

void pwm_handler(nrfx_pwm_evt_type_t event_type)
{
    switch(event_type)
    {
	case NRFX_PWM_EVT_FINISHED:
	    pwm_sequencue_finished = true;
	    break;
	default:
	    break;
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HFCLK Useage</title><link>https://devzone.nordicsemi.com/thread/200089?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 13:27:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66ade09d-5463-4d8f-a8ad-59381a854d3d</guid><dc:creator>Marjeris Romero</dc:creator><description>[quote user="dmleone"]RTC and timer interrupts are too slow. Fastest times i can get are greater than 1us.[/quote]
&lt;p&gt;&amp;nbsp;&lt;br /&gt;RTC runs on LFCLK but TIMER runs on HFCLK. You should try using TIMER directly, then you will be able to go down to 62.5ns. &lt;br /&gt;&lt;br /&gt;But what exactly are you trying to implement? Is it something like the protocol described under &amp;#39;Protocol&amp;#39; in &lt;a href="https://www.pololu.com/product/2527"&gt;this link&lt;/a&gt;? If this is the case you can also consider using PWM. There is an example for a WS2812 driver using PWM you can take a look at &lt;a href="https://github.com/NordicPlayground/nrf52-ble-multi-link-multi-role/tree/master/common/drv_ws2812"&gt;here&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HFCLK Useage</title><link>https://devzone.nordicsemi.com/thread/199880?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2019 18:19:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3cc64165-3e7c-4a78-9b14-186fb2bd3a5c</guid><dc:creator>dmleone</dc:creator><description>&lt;p&gt;i tried using the PPI + GPIOTE but i could not change the cycle time fast enoughafter each cycle&lt;/p&gt;
&lt;p&gt;RTC and timer interrupts are too slow. Fastest times i can get are greater than 1us.&lt;/p&gt;
&lt;p&gt;I am trying to implement a WS2812 protocvol exactly. The SK6812 is the newer variant of WS2812 but operates same protocol.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HFCLK Useage</title><link>https://devzone.nordicsemi.com/thread/199873?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2019 16:46:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46e8a125-905c-414a-b250-df0dd82f7512</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry for the late answer. It&amp;#39;s summertime in Norway and half our staff on tech support is on vacation.&lt;/p&gt;
&lt;p&gt;So if I understood you problem correctly, yo want to generate 0.3 us, 0.6 us and 0.9 us pulses? &lt;/p&gt;
&lt;p&gt;You should RTC or TIMER instead of using CPU and nrf_delay_ms(). We have 6 compare registers in some of our timers. You can run a timer from 0, set first compare register to 0.3 us, next one to 0.3 + 0.6 us and etc., then use PPI + GPIOTE to set/clear GPIO on compare events.&lt;/p&gt;
&lt;p&gt;But I am still not sure what is it that you want to implement... Are you looking to implement something like the WS2812 protocol maybe?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HFCLK Useage</title><link>https://devzone.nordicsemi.com/thread/199575?ContentTypeID=1</link><pubDate>Fri, 19 Jul 2019 15:08:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aae5a2e9-6efe-4ee0-b684-e6068235eb13</guid><dc:creator>dmleone</dc:creator><description>&lt;p&gt;I feel like this is probably not the most elegant method by which to do this, but i could not figure out how to engage the HFCLK so i can use delay or something off a 62.5ns clock cycle&lt;/p&gt;
&lt;p&gt;Using the normal clock i just tried to take C assembler out of the picture&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void sk6812_show(void){
    uint32_t err_code;

    nrf_gpio_pin_write(led_pin, 0);
    nrf_delay_fast(1);

    for(int i = 0; i &amp;lt; NUM_OF_LEDS; i++){
        for(int j = 0; j &amp;lt; 24; j++){
            if(pixels[i] &amp;lt;&amp;lt; j &amp;amp; 0x800000){
                NRF_P0-&amp;gt;OUTSET = (1UL &amp;lt;&amp;lt; led_pin);
                __ASM(&amp;quot; MOV R0, #7\n\t&amp;quot;
                      &amp;quot; loop:\n\t&amp;quot;
                          &amp;quot; SUBS R0, R0, #1\n\t&amp;quot;
                          &amp;quot; NOP\n\t&amp;quot;
                          &amp;quot; NOP\n\t&amp;quot;
                          &amp;quot; BNE loop\n\t&amp;quot;);

                NRF_P0-&amp;gt;OUTCLR = (1UL &amp;lt;&amp;lt; led_pin);
                __ASM(&amp;quot; MOV R0, #2\n\t&amp;quot;
                      &amp;quot; loop2:\n\t&amp;quot;
                          &amp;quot; SUBS R0, R0, #1\n\t&amp;quot;
                          &amp;quot; NOP\n\t&amp;quot;
                          &amp;quot; NOP\n\t&amp;quot;
                          &amp;quot; BNE loop2\n\t&amp;quot;);
            }else{
                NRF_P0-&amp;gt;OUTSET = (1UL &amp;lt;&amp;lt; led_pin);
                __ASM(&amp;quot; MOV R0, #3\n\t&amp;quot;
                      &amp;quot; loop3:\n\t&amp;quot;
                          &amp;quot; SUBS R0, R0, #1\n\t&amp;quot;
                          &amp;quot; NOP\n\t&amp;quot;
                          &amp;quot; NOP\n\t&amp;quot;
                          &amp;quot; BNE loop3\n\t&amp;quot;);
                NRF_P0-&amp;gt;OUTCLR = (1UL &amp;lt;&amp;lt; led_pin);
                __ASM(&amp;quot; MOV R0, #7\n\t&amp;quot;
                      &amp;quot; loop4:\n\t&amp;quot;
                          &amp;quot; SUBS R0, R0, #1\n\t&amp;quot;
                          &amp;quot; NOP\n\t&amp;quot;
                          &amp;quot; NOP\n\t&amp;quot;
                          &amp;quot; BNE loop4\n\t&amp;quot;);
            }
        }
    }
    nrf_delay_ms(2);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>