<?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>Program to interface Grove Four Digit Display(TM1637) with nRF chips</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/88948/program-to-interface-grove-four-digit-display-tm1637-with-nrf-chips</link><description>I am trying to interface the Grove 4 Digit Display(TM1637) with the nRF52840 DK.I have successfully interfaced it with ESP32 and get clear output after researching for the CODE in the Internet.I have included that code , below: 
 main.c 
 
 tm1637.h </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Jun 2022 07:38:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/88948/program-to-interface-grove-four-digit-display-tm1637-with-nrf-chips" /><item><title>RE: Program to interface Grove Four Digit Display(TM1637) with nRF chips</title><link>https://devzone.nordicsemi.com/thread/373152?ContentTypeID=1</link><pubDate>Mon, 20 Jun 2022 07:38:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9393fda-a7e9-420e-b233-36c3b9c9c2b8</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Vicky,&lt;/p&gt;
&lt;p&gt;The nRF52840 DK will use a pin voltage of 1.7V by default, and this is controlled from the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/uicr.html?cp=4_0_0_3_4_0_7#register.REGOUT0"&gt;REGOUT0 register located in UICR&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I am not sure whether it just needs the 3V3 (3.3V) to power up the device, or if it requires 3V3 on the communication pins as well. To figure out you can try to power it up from the arduino, but keep the communication on the default 1V7. Are you able to control the display then?&lt;/p&gt;
&lt;p&gt;If not, try adding this snippet before you start up the I2C:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void set_gpio_voltage(void) // If your motor is struggling, try calling this function from motor_init().
{
    uint32_t regout = NRF_UICR-&amp;gt;REGOUT0;
    uint32_t target_voltage = UICR_REGOUT0_VOUT_3V3;

    LOG_INF(&amp;quot;Regout: 0x%08x&amp;quot;, regout);
    if ((regout &amp;amp; UICR_REGOUT0_VOUT_Msk) != target_voltage) {
        LOG_INF(&amp;quot;regout not set to 3V3. Configuring...&amp;quot;);
        

        NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen;
        while (NRF_NVMC-&amp;gt;CONFIG != NVMC_CONFIG_WEN_Wen){
            // Wait...
        }
        NRF_UICR-&amp;gt;REGOUT0 = (target_voltage | ~UICR_REGOUT0_VOUT_Msk);
        while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy) {
            // Wait...
        }
        while ((NRF_UICR-&amp;gt;REGOUT0 &amp;amp; UICR_REGOUT0_VOUT_Msk) != target_voltage) {
            // Wait...
        }
        NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Ren;
        while (NRF_NVMC-&amp;gt;CONFIG != NVMC_CONFIG_WEN_Ren){
            // Wait...
        }
        NVIC_SystemReset();
    } else {
        LOG_INF(&amp;quot;Regout0 is set to target voltage.&amp;quot;);
    }

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is very hard-coded, but it should do the job of setting the GPIO voltage to 3V3. This is a snippet that will only be run the first time you power it on after having programmed it, and then it will reboot. Since this is stored in UICR (in flash), it will keep that setting until the flash is erased. So please note that if you want to change it from 3V3 to e.g. 3V0, you need to change this snippet to have &amp;quot;uint32_t target_voltage = &lt;span&gt;UICR_REGOUT0_VOUT_3V0, then erase the flash (nrfjprog --eraseall), and then reprogram the chip with your application.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Program to interface Grove Four Digit Display(TM1637) with nRF chips</title><link>https://devzone.nordicsemi.com/thread/373023?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 12:29:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adef6040-3842-4b3c-8a55-ebd3736091f5</guid><dc:creator>Vicky7797</dc:creator><description>&lt;p&gt;I found the problem. The TM1637 Display works on 3.3V. When a voltage of 3.3V is given to that display from the Arduino Pin, It gets scanned in the nRF52840 DK. My questions is , How can I get a 3.3V output from the DK as there is no pin giving a Voltage og 3.3V ?&lt;/p&gt;
&lt;p&gt;My I have to use an external regulator to convert the 5V to 3.3V?Please give me an Idea.&lt;/p&gt;
&lt;p&gt;If you have any idea on preparing a program to drive TM1637 display, Please descrbe it to me.&lt;/p&gt;
&lt;p&gt;Thankyou.&lt;/p&gt;
&lt;p&gt;-Vicky&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Program to interface Grove Four Digit Display(TM1637) with nRF chips</title><link>https://devzone.nordicsemi.com/thread/373015?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 12:10:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40924fe7-32b8-4a0b-822a-62aa3dc973b1</guid><dc:creator>Vicky7797</dc:creator><description>&lt;p&gt;Really Sorry.I wronlgy connected the SCL, SDA pins of the nRF52840 DK to the other SCL, SDA pins. After correct connection, I get to found the adress of the live I2C &lt;br /&gt;commuication as 0x4. Then, I try to connect the TM1637 display to the ongoing live I2C Connection. After connecting that, I get to found more number of addresses(above 25) &lt;br /&gt;at the Output Terminal. But, when I try to connect that Display directly to the DK which was running I2C_Scanner program, it won&amp;#39;t detect that display.&lt;br /&gt;It gets detected when a live I2C connection flows along with it only.&lt;/p&gt;
&lt;p&gt;My Setup:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1655467573265v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Terminal Output:&lt;/p&gt;
&lt;p&gt;When Arduino live I2C connection is Ongoing:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1655467672801v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;When TM1637 connected to the live I2C Connection:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1655467735038v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;When TM1637 alone connected to DK:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1655467774761v4.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;What will be the problem ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Program to interface Grove Four Digit Display(TM1637) with nRF chips</title><link>https://devzone.nordicsemi.com/thread/373003?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 11:39:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddbd22d8-50d9-44b7-8513-379a0b9b154a</guid><dc:creator>Vicky7797</dc:creator><description>&lt;p&gt;Thankyou for you quick reply , Edvin. As your recommendation , I will use I2C Communication to control the TM1637 Display. Your way of explaining things is really great. I can easily understand the steps and procedure , which I have to follow to do my project working from your reply.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;As you said, I used the nRF52840 DK with the I2C_Scanner sample from the Github .I downloaded the file from the GitHub and changed the &lt;br /&gt;overlay file as follows:&lt;br /&gt;nrf52840dk_nrf52840.overlay&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
&amp;amp;i2c0 {
	status = &amp;quot;ok&amp;quot;;
	compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
	sda-pin = &amp;lt;27&amp;gt;;
	scl-pin = &amp;lt;26&amp;gt;;
	clock-frequency = &amp;lt;I2C_BITRATE_STANDARD&amp;gt;;
};
&lt;/pre&gt;&lt;br /&gt;I renamed the overlay file as nrf52840dk_nrf52840.overlay.&lt;/p&gt;
&lt;p&gt;I removed the CONFIG_I2C_3=y from the configuration file as well.Then I used the code given by you in the main.c file and compiled it.It build successfully.When I connected my display to the SCL, SDA pins it does&amp;#39;t give any address at the Output terminal.&lt;/p&gt;
&lt;p&gt;Output Terminal:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1655465520297v1.png" alt=" " /&gt;&lt;br /&gt;As for the extra checking, I use two Arduino boards which connect between them through I2C communication and send and receive data between them.&lt;br /&gt;Then, I used the live I2C communication to scan the address from the nRF52840 DK.&lt;/p&gt;
&lt;p&gt;My Test Setup:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1655465962108v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Even at this condition, it won&amp;#39;t give any address of the I2C modules(Arduino Uno &amp;amp; Arduino Pro Mini)&lt;br /&gt;I even the changed the Serial communication baud rate to 115200 on the two Arduino modules for detection of the addresses. But, I don&amp;#39;t get any address at this state also.&lt;br /&gt;I don&amp;#39;t know what will be the problem in this. Can you please tell me how to solve this problem?&lt;/p&gt;
&lt;p&gt;Software:&lt;br /&gt;I program the boards using VS Code, nRF connect Extension.&lt;br /&gt; &lt;br /&gt;Thankyou.&lt;br /&gt;-Vicky.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Program to interface Grove Four Digit Display(TM1637) with nRF chips</title><link>https://devzone.nordicsemi.com/thread/372962?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 08:59:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:465bbf25-e8ce-4eea-bb31-726216e560f3</guid><dc:creator>Edvin</dc:creator><description>[quote user="Vicky7797"]&lt;strong&gt;My final objective is to interface TM1637 Display to nRF52840 Dongle , which run the BLE Mesh model in them&lt;/strong&gt;.[/quote]
&lt;p&gt;In that case, since you need to use the softdevice (in the nRF5 SDK) or the softdevice controller (in NCS, which you are currently using), I suggest that you try to use the&amp;nbsp;I2C (sorry, I wrote SPI in the previous reply. I meant to say I2C). If you for some reason want to look up the I2C peripheral in our &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/twim.html?cp=4_0_0_5_30"&gt;documentation&lt;/a&gt;, be aware that TWI is the same as I2C. It is just a naming convension. Also, TWIM is just the master driver of the TWI.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I understand that you have spent quite a lot of time on your driver, but unfortunately, the k_sleep(K_MSEC(3)) will not let you sleep for 3 msec accurately and consistently because of the reasons I explained in the previous reply. Timings are not that accurate in an RTOS, such as Zephyr, which is used in the nRF Connect SDK (NCS)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;However, you are close, and you can use a lot of what you already have, so this time is not wasted.&lt;/p&gt;
&lt;p&gt;First, I suggest that you try to copy and run the sample i2c_scanner from &lt;a href="https://github.com/sigurdnev/ncs-playground/tree/master/samples"&gt;this github&lt;/a&gt;&amp;nbsp;(same as in previous reply). Just download the entire &lt;a href="https://github.com/sigurdnev/ncs-playground"&gt;repository&lt;/a&gt;&amp;nbsp;and copy out the samples/i2c_scanner folder next to your other application.&lt;/p&gt;
&lt;p&gt;You have a DK as well as a dongle (from your picture), so I suggest that you do everything on the DK, because it is easier to work with. When everything is working, you can move your application over to the dongle.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Before you compile and run the i2c_scanner sample, copy the nrf9160dk_nrf9160ns.overlay, and name it nrf52840dk_nrf52840.overlay, and change the sda-pin and scl-pin to the same as you have already have tested (P0.26 and P0.27). Also change the first line from&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;amp;i2c3 {&lt;/p&gt;
&lt;p&gt;to&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;amp;i2c0 {&lt;/p&gt;
&lt;p&gt;you can use i2c0, i2c1, since the nRF52840 has two TWIs/I2Cs. Therefore i2c3 doesn&amp;#39;t exist on the nRF52840.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Finally, you need to open prj.conf, and remove the line:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;CONFIG_I2C_3=y&lt;/p&gt;
&lt;p&gt;which is no longer needed in the later NCS versions.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Finally, we need to change a few things in main.c. I took the freedom to do so, and you can find the modified main.c file here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0755.main.c"&gt;devzone.nordicsemi.com/.../0755.main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Basically, I changed the #include that included the nrf9160 header file (line 1), Then I changed line 45 and 46, which were hardcoded for the I2C_3.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Now, if you run this sample on your DK, it should try to &amp;quot;ping&amp;quot; all I2C addresses on the I2C bus. I don&amp;#39;t know this device in particular, but I guess it will reply on 0x40 or 0x44 (or both). You should see which addresses are matched (if any) on the UART log (115200 baud rate).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you see it, then you can remove the pinging if you like to, and then start to use this I2C bus with your driver. You can use i2c_transfer(), i2c_read()&amp;nbsp;and i2c_write(), all described here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/i2c.html#c.i2c_transfer"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/i2c.html#c.i2c_transfer&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you want some more introduction on how to set up the I2C from scratch, you can check out the Nordic Developer Academy, which has a session on I2C:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://academy.nordicsemi.com/topic/i2c-protocol/"&gt;https://academy.nordicsemi.com/topic/i2c-protocol/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Program to interface Grove Four Digit Display(TM1637) with nRF chips</title><link>https://devzone.nordicsemi.com/thread/372905?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 05:41:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20471dbf-e409-4916-bce5-65955e280da3</guid><dc:creator>Vicky7797</dc:creator><description>&lt;p&gt;Hi Edwin,&lt;br /&gt;Thankyou for your suggestion. I used Pin 26 and 27 for my Push Button , LED project and it worked perfectly.&lt;/p&gt;
&lt;p&gt;I want to interface that TM1637 Display with the nRF52840 Dongle.So that, I used the normal bit banging method to control my display.&lt;br /&gt;I have modified the above code to work for the DK .It get build successfully without any errors.But it won&amp;#39;t produce any output for the&lt;br /&gt;Display.I will show the modified code below.Can you tell me , what am I missing in that?&lt;/p&gt;
&lt;p&gt;main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;quot;myfunction.h&amp;quot;

#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;math.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;devicetree.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;

#define CONFIG_TM1637_CLK_PIN 26
#define CONFIG_TM1637_DTA_PIN 27

const gpio_num_t CLK = CONFIG_TM1637_CLK_PIN;
const gpio_num_t DTA = CONFIG_TM1637_DTA_PIN;

const gpio_num_pin_t CLK_PIN = CONFIG_TM1637_CLK_PIN;
const gpio_num_pin_t DTA_PIN = CONFIG_TM1637_DTA_PIN;

void main(void)
{
	int a = 8, b = 92;
	printk(&amp;quot;The sum of %d and %d is %d\n\r&amp;quot;, a, b, sum(a,b));
	tm1637_led_t * lcd = tm1637_init(CLK, DTA, CLK_PIN, DTA_PIN);
	tm1637_set_number(lcd, 8008); //Displays Number 8008 on Four Digit Display
	tm1637_set_brightness(lcd, 7);
	
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;myfunction.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;myfunction.h&amp;quot;

int sum(int a, int b){
    return a+b;
}

/*#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;math.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;devicetree.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;*/

#define TM1637_ADDR_AUTO 0x40
#define TM1637_ADDR_FIXED 0x44

#define MINUS_SIGN_IDX 16

static const int8_t tm1637_symbols[] = {
    // XGFEDCBA
    0x3f, // 0b00111111,    // 0
    0x06, // 0b00000110,    // 1
    0x5b, // 0b01011011,    // 2
    0x4f, // 0b01001111,    // 3
    0x66, // 0b01100110,    // 4
    0x6d, // 0b01101101,    // 5
    0x7d, // 0b01111101,    // 6
    0x07, // 0b00000111,    // 7
    0x7f, // 0b01111111,    // 8
    0x6f, // 0b01101111,    // 9
    0x77, // 0b01110111,    // A
    0x7c, // 0b01111100,    // b
    0x39, // 0b00111001,    // C
    0x5e, // 0b01011110,    // d
    0x79, // 0b01111001,    // E
    0x71, // 0b01110001     // F
    0x40, // 0b01000000     // minus sign
};

void tm1637_start(tm1637_led_t *led);
void tm1637_stop(tm1637_led_t *led);
void tm1637_off(tm1637_led_t *led);
void tm1637_send_byte(tm1637_led_t *led, uint8_t byte);
void tm1637_delay();
// PUBLIC PART:
//Defining GPIO pins
#define CLK_NODE DT_ALIAS(gpiocus0)

#if DT_NODE_HAS_STATUS(CLK_NODE, okay)
#define CLOCK DT_GPIO_LABEL(CLK_NODE, gpios)
#define CLOCK_PIN DT_GPIO_PIN(CLK_NODE, gpios)
#define CLOCK_FLAGS DT_GPIO_FLAGS(CLK_NODE, gpios)
#else
#error &amp;quot;Unsupported board: gpio22 devicetree alias is not defined&amp;quot;
#endif

#define DTA_NODE DT_ALIAS(gpiocus1)

#if DT_NODE_HAS_STATUS(DTA_NODE, okay)
#define DATA DT_GPIO_LABEL(DTA_NODE, gpios)
#define DATA_PIN DT_GPIO_PIN(DTA_NODE, gpios)
#define DATA_FLAGS DT_GPIO_FLAGS(DTA_NODE, gpios)
#else
#error &amp;quot;Unsupported board: gpio24 devicetree alias is not defined&amp;quot;
#endif
const struct device *dev;

tm1637_led_t *tm1637_init(gpio_num_t clk, gpio_num_t data, gpio_num_pin_t pin_clk, gpio_num_pin_t pin_data)
{
    
    printk(&amp;quot;Struct Working One&amp;quot;);
    dev = device_get_binding(CLOCK);

    tm1637_led_t *led = (tm1637_led_t *)malloc(sizeof(tm1637_led_t));
    led-&amp;gt;m_clk = clk;
    led-&amp;gt;m_dta = data;
    led-&amp;gt;m_clk_pin = pin_clk;
    led-&amp;gt;m_dta_pin = pin_data;
    led-&amp;gt;m_brightness = 0x06;
    // Set CLK to low during DIO initialization to avoid sending a start signal by mistake
    gpio_pin_configure(dev, pin_clk, GPIO_OUTPUT_ACTIVE | CLOCK_FLAGS);
    gpio_pin_set(dev, clk, 0);
    tm1637_delay();
    gpio_pin_configure(dev, data, GPIO_OUTPUT_ACTIVE | CLOCK_FLAGS);
    gpio_pin_set(dev, pin_data, 1);
    tm1637_delay();
    gpio_pin_set(dev, pin_clk, 1);
    tm1637_delay();
    return led;
}


void tm1637_delay()
{
    k_sleep(K_MSEC(3));
    //hal_delay(3);
}

void tm1637_start(tm1637_led_t *led)
{
    // Send start signal
    // Both outputs are expected to be HIGH beforehand
    gpio_pin_set(dev, led-&amp;gt;m_dta_pin, 0);
    tm1637_delay();
}

void tm1637_stop(tm1637_led_t *led)
{
    // Send stop signal
    // CLK is expected to be LOW beforehand
    gpio_pin_set(dev, led-&amp;gt;m_dta_pin, 0);
    tm1637_delay();
    gpio_pin_set(dev, led-&amp;gt;m_clk_pin, 1);
    tm1637_delay();
    gpio_pin_set(dev, led-&amp;gt;m_dta_pin, 1);
    tm1637_delay();
}



void tm1637_send_byte(tm1637_led_t *led, uint8_t byte)
{
    for (uint8_t i = 0; i &amp;lt; 8; ++i)
    {
        gpio_pin_set(dev, led-&amp;gt;m_clk_pin, 0);
        tm1637_delay();
        gpio_pin_set(dev, led-&amp;gt;m_dta_pin, byte &amp;amp; 0x01); // Send current bit
        byte &amp;gt;&amp;gt;= 1;
        tm1637_delay();
        gpio_pin_set(dev, led-&amp;gt;m_clk_pin, 1);
        tm1637_delay();
    }

    // The TM1637 signals an ACK by pulling DIO low from the falling edge of
    // CLK after sending the 8th bit, to the next falling edge of CLK.
    // DIO needs to be set as input during this time to avoid having both
    // chips trying to drive DIO at the same time.
    gpio_pin_configure(dev, led-&amp;gt;m_dta, GPIO_INPUT);
    gpio_pin_set(dev, led-&amp;gt;m_clk_pin, 0); // TM1637 starts ACK (pulls DIO low)
    tm1637_delay();
    gpio_pin_set(dev, led-&amp;gt;m_clk_pin, 1);
    tm1637_delay();
    gpio_pin_set(dev, led-&amp;gt;m_clk_pin, 0); // TM1637 ends ACK (releasing DIO)
    tm1637_delay();
    gpio_pin_configure(dev, led-&amp;gt;m_dta, GPIO_OUTPUT_ACTIVE);
}



void tm1637_set_brightness(tm1637_led_t *led, uint8_t level)
{
    if (level &amp;gt; 0x07)
    {
        level = 0x07;
    } // Check max level
    led-&amp;gt;m_brightness = level;
}

void tm1637_set_segment_number(tm1637_led_t *led, const uint8_t segment_idx, const uint8_t num, const bool dot)
{
    uint8_t seg_data = 0x00;

    if (num &amp;lt; (sizeof(tm1637_symbols) / sizeof(tm1637_symbols[0])))
    {
        seg_data = tm1637_symbols[num]; // Select proper segment image
    }

    if (dot)
    {
        seg_data |= 0x80; // Set DOT segment flag
    }

    tm1637_set_segment_raw(led, segment_idx, seg_data);
}

void tm1637_set_segment_raw(tm1637_led_t *led, const uint8_t segment_idx, const uint8_t data)
{
    tm1637_start(led);
    tm1637_send_byte(led, TM1637_ADDR_FIXED);
    tm1637_stop(led);
    tm1637_start(led);
    tm1637_send_byte(led, segment_idx | 0xc0);
    tm1637_send_byte(led, data);
    tm1637_stop(led);
    tm1637_start(led);
    tm1637_send_byte(led, led-&amp;gt;m_brightness | 0x88);
    tm1637_stop(led);
}

void tm1637_set_number(tm1637_led_t *led, uint16_t number)
{
    tm1637_set_number_lead_dot(led, number, false, 0x00);
}

void tm1637_set_number_lead(tm1637_led_t *led, uint16_t number, const bool lead_zero)
{
    tm1637_set_number_lead_dot(led, number, lead_zero, 0x00);
}

void tm1637_set_number_lead_dot(tm1637_led_t *led, uint16_t number, bool lead_zero, const uint8_t dot_mask)
{
    uint8_t lead_number = lead_zero ? 0xFF : tm1637_symbols[0];

    if (number &amp;lt; 10)
    {
        tm1637_set_segment_number(led, 3, number, dot_mask &amp;amp; 0x01);
        tm1637_set_segment_number(led, 2, lead_number, dot_mask &amp;amp; 0x02);
        tm1637_set_segment_number(led, 1, lead_number, dot_mask &amp;amp; 0x04);
        tm1637_set_segment_number(led, 0, lead_number, dot_mask &amp;amp; 0x08);
    }
    else if (number &amp;lt; 100)
    {
        tm1637_set_segment_number(led, 3, number % 10, dot_mask &amp;amp; 0x01);
        tm1637_set_segment_number(led, 2, (number / 10) % 10, dot_mask &amp;amp; 0x02);
        tm1637_set_segment_number(led, 1, lead_number, dot_mask &amp;amp; 0x04);
        tm1637_set_segment_number(led, 0, lead_number, dot_mask &amp;amp; 0x08);
    }
    else if (number &amp;lt; 1000)
    {
        tm1637_set_segment_number(led, 3, number % 10, dot_mask &amp;amp; 0x01);
        tm1637_set_segment_number(led, 2, (number / 10) % 10, dot_mask &amp;amp; 0x02);
        tm1637_set_segment_number(led, 1, (number / 100) % 10, dot_mask &amp;amp; 0x04);
        tm1637_set_segment_number(led, 0, lead_number, dot_mask &amp;amp; 0x08);
    }
    else
    {
        tm1637_set_segment_number(led, 3, number % 10, dot_mask &amp;amp; 0x01);
        tm1637_set_segment_number(led, 2, (number / 10) % 10, dot_mask &amp;amp; 0x02);
        tm1637_set_segment_number(led, 1, (number / 100) % 10, dot_mask &amp;amp; 0x04);
        tm1637_set_segment_number(led, 0, (number / 1000) % 10, dot_mask &amp;amp; 0x08);
    }
}


void tm1637_display_off(tm1637_led_t *led, uint16_t number, bool lead_zero, const uint8_t dot_mask)
{
    uint8_t lead_number = lead_zero ? 0xFF : tm1637_symbols[0];

    
        tm1637_set_segment_number(led, 3, lead_number, dot_mask &amp;amp; 0x01);
        tm1637_set_segment_number(led, 2, lead_number, dot_mask &amp;amp; 0x02);
        tm1637_set_segment_number(led, 1, lead_number, dot_mask &amp;amp; 0x04);
        tm1637_set_segment_number(led, 0, lead_number, dot_mask &amp;amp; 0x08);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;myfunction.h&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifndef MY_FUNCTION_H
#define MY_FUNCTION_H

int sum(int a, int b);

#include &amp;lt;inttypes.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;devicetree.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#ifdef __cplusplus
extern &amp;quot;C&amp;quot;
{
#endif

    struct tm;

    typedef enum
    {
        CLOCK = 26, /*!&amp;lt; GPIO0, input and output ,Can take any of these two pins as CLK and DIO*/
        DATA = 27
    } gpio_num_t;

    typedef enum
    {
        CLOCK_PIN = 26,
        DATA_PIN = 27
    } gpio_num_pin_t;

    typedef struct
    {
        gpio_num_t m_clk;
        gpio_num_t m_dta;
        gpio_num_pin_t m_clk_pin;
        gpio_num_pin_t m_dta_pin;
        uint8_t m_brightness;
    } tm1637_led_t;

    tm1637_led_t *tm1637_init(gpio_num_t clk, gpio_num_t data, gpio_num_pin_t pin_clk, gpio_num_pin_t pin_data);

    void tm1637_set_brightness(tm1637_led_t *led, uint8_t level);

    void tm1637_set_segment_number(tm1637_led_t *led, const uint8_t segment_idx, const uint8_t num, const bool dot);

    void tm1637_set_segment_raw(tm1637_led_t *led, const uint8_t segment_idx, const uint8_t data);

    void tm1637_set_number(tm1637_led_t *led, uint16_t number);

    void tm1637_set_number_lead(tm1637_led_t *led, uint16_t number, const bool lead_zero);

    void tm1637_set_number_lead_dot(tm1637_led_t *led, uint16_t number, const bool lead_zero, const uint8_t dot_mask);

    void tm1637_display_off(tm1637_led_t *led, uint16_t number, bool lead_zero, const uint8_t dot_mask);

#ifdef __cplusplus
}
#endif 

#endif
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;If you have any idea on connecting that display to Dongle through I2C connection, Please notify that and guide me to achive that Edvin.It will be&lt;br /&gt;really helpful for me.&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/88948/program-to-interface-grove-four-digit-display-tm1637-with-nrf-chips/372887#372887"]But only as long as you are not using the Bluetooth Low Energy stack, because then it will have the highest priority, and you are pretty much in the same situation.[/quote]
&lt;p&gt;I have to use Bluetooth Mesh Stack for the Dongles along with this Display interface.Then, How can I overcome this problem in Dongle?&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/88948/program-to-interface-grove-four-digit-display-tm1637-with-nrf-chips/372887#372887"]&lt;p&gt;If you want to check out an example using SPI, I can recommend that you check out this github&amp;#39;s SPI sample:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/sigurdnev/ncs-playground/tree/master/samples"&gt;https://github.com/sigurdnev/ncs-playground/tree/master/samples&lt;/a&gt;&lt;/p&gt;[/quote]
&lt;p&gt;I try to build and flash some of the samples in the above mentioned link.But it gives me so many errors and I don&amp;#39;t know how to use them as there is no explanation or read me files.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;My final objective is to interface TM1637 Display to nRF52840 Dongle , which run the BLE Mesh model in them&lt;/strong&gt;.Kinldy guide me to achieve that.And also have a look at the code , I gave above . I spent almot one day to modify that. If it gives clear output to Display numbers , I feel really happy. Or if I have to follow the I2C techniques to interface that Display , Please give some ideas to do that . Ultimately I have to achive my final objective.&lt;/p&gt;
&lt;p&gt;Thankyou .&lt;/p&gt;
&lt;p&gt;-Vicky.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Program to interface Grove Four Digit Display(TM1637) with nRF chips</title><link>https://devzone.nordicsemi.com/thread/372887?ContentTypeID=1</link><pubDate>Thu, 16 Jun 2022 21:13:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02c3e8d5-b3aa-4680-b187-9d23fd137b5f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Vicky,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply. I&amp;#39;ve had a couple of non-planned days out of office since I was assigned your case.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So you are not seeing any changes in the GPIO at all?&lt;/p&gt;
&lt;p&gt;I see that you are using the pins 20 and 21. I assume you didn&amp;#39;t do any changes/modifications to the DK? If so, then the pins P0.17 -&amp;gt; P0.23 are not connected to the GPIO headers that you are trying to use. If you look at the back of your DK, you can see that these are connected to a QSPI bus attached to an external flash chip on the DK. So the easiest workaround for this is to use some other pins. Try e.g. P0.26 and P0.27.&lt;/p&gt;
&lt;p&gt;It is correct that you need to set up an overlay file like you did, so try changing the pins to see if they will light up the LED.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Even if they do light it up, though, bitbanging (emulating SPI) is not straight forward when you are using NCS, which is a real time operating system (RTOS). Is there a reason why you need to bitbang it like this, and not use SPI? Actually using the SPI peripheral will give you much better timing control. Assuming the driver that you have found is working, you should be able to just send the bytes that you are bitbanging here over SPI instead of stepping through bit by bit.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Since you are so close, though, try replacing the pins. What does your&amp;nbsp;tm1637_delay() look like? Tru using &amp;quot;&lt;span&gt;k_sleep&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;K_MSEC&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;100&lt;/span&gt;&lt;span&gt;));&amp;quot; . That is 100ms, so you may want to turn it down. But unfortunately, the k_sleep works less good with shorter delays, because it hands the control over to other part of the RTOS, and it will get it back when it is done with it&amp;#39;s other work.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If you want to check out an example using SPI, I can recommend that you check out this github&amp;#39;s SPI sample:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/sigurdnev/ncs-playground/tree/master/samples"&gt;https://github.com/sigurdnev/ncs-playground/tree/master/samples&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you for some reason &lt;strong&gt;need&lt;/strong&gt;&amp;nbsp;to bitbang this, I suggest you check out the nRF5 SDK, which is a more bare metal SDK, without the RTOS. There you will have more control of the timing in the application. But only as long as you are not using the Bluetooth Low Energy stack, because then it will have the highest priority, and you are pretty much in the same situation.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Program to interface Grove Four Digit Display(TM1637) with nRF chips</title><link>https://devzone.nordicsemi.com/thread/372466?ContentTypeID=1</link><pubDate>Wed, 15 Jun 2022 05:06:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a195bcb4-e36e-4d90-8ea3-aa022a893752</guid><dc:creator>Vicky7797</dc:creator><description>&lt;p&gt;After searching different Questions and Answers in Devzone, I came to the point , that I have to change the Device Tree by including Overlay file in the root folder of the main function. I have made a simple program to blink an LED connected to the GPIO pin 22 which is declared as CLK.&lt;/p&gt;
&lt;p&gt;Refernce&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/72618/extra-gpios-in-board-overlay-for-nrf9160dk"&gt;Device Tree Overlay Program Reference&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I have included the main.c function and the overlay file below:&lt;/p&gt;
&lt;p&gt;main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;devicetree.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;

/* Increase the main thread sleep time from 100ms to 1 second  */
#define SLEEP_TIME_MS 1000


//Defining GPIO pins
#define CLK_NODE DT_ALIAS(gpiocus0)
#if DT_NODE_HAS_STATUS(CLK_NODE, okay)
#define CLK DT_GPIO_LABEL(CLK_NODE, gpios)
#define CLK_PIN DT_GPIO_PIN(CLK_NODE, gpios)
#define CLK_FLAGS DT_GPIO_FLAGS(CLK_NODE, gpios)
#else
#error &amp;quot;Unsupported board: gpio22 devicetree alias is not defined&amp;quot;
#endif

#define DIO_NODE DT_ALIAS(gpiocus1)
#if DT_NODE_HAS_STATUS(DIO_NODE, okay)
#define DIO DT_GPIO_LABEL(DIO_NODE, gpios)
#define DIO_PIN DT_GPIO_PIN(DIO_NODE, gpios)
#define DIO_FLAGS DT_GPIO_FLAGS(DIO_NODE, gpios)
#else
#error &amp;quot;Unsupported board: gpio24 devicetree alias is not defined&amp;quot;
#endif


void main(void)
{
    const struct device *dev;
    bool led_is_on = true;
    int ret;
    
    dev = device_get_binding(CLK);
    if (dev == NULL) 
    {
        return;
    }
    
    ret = gpio_pin_configure(dev, CLK_PIN, GPIO_OUTPUT_ACTIVE | CLK_FLAGS);
    if (ret &amp;lt; 0) 
    {
        return;
    }

    while (1) 
    {
        gpio_pin_set(dev, CLK_PIN, (int)led_is_on);
        led_is_on = !led_is_on;
        k_msleep(SLEEP_TIME_MS);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Device tree overlay file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
    gpiocustom {
        compatible = &amp;quot;gpio-keys&amp;quot;;
        gpiocus0: gpiocus_0 {
            gpios = &amp;lt;&amp;amp;gpio0 22 GPIO_ACTIVE_LOW&amp;gt;;
            label = &amp;quot;Custom gpio 22&amp;quot;;
        };
        gpiocus1: gpiocus_1 {
            gpios = &amp;lt;&amp;amp;gpio0 23 GPIO_ACTIVE_LOW&amp;gt;;
            label = &amp;quot;Custom gpio 24&amp;quot;;
        };
    };
    aliases {
        gpiocus0 = &amp;amp;gpiocus0;
        gpiocus1 = &amp;amp;gpiocus1;
    };
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The screenshot of my VS Code workspace:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1655273748322v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Hardware setup and wiring diagram :&lt;/p&gt;
&lt;p&gt;This is my hardware setup to blink an LED connected to GPIO pin no : 22.&lt;/p&gt;
&lt;p&gt;If you notice any error in my wiring circuit , Please notify that.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1655273725619v2.jpeg" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I have Pristine build the above code without any errors.But , when I flash it in thw nRF52840 DK board, I won&amp;#39;t get any output. I connected an LED at GPIO pin 22 with required resistor. I don&amp;#39;t know what am I missing?Can you tell me how can I solve this problem?&lt;/p&gt;
&lt;p&gt;Ultimately I have to control the 4 Digit Display using these two GPIO pins. If you have idea to do that, Please tell me how can I achieve that.&lt;/p&gt;
&lt;p&gt;Thankyou.&lt;/p&gt;
&lt;p&gt;-Vicky&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>