<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: vietdt89</title>
    <description>The latest articles on DEV Community by vietdt89 (@vietdt89).</description>
    <link>https://dev.to/vietdt89</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F304646%2Ffd9822f6-edb5-4e8c-82c7-6a5bb2034ced.jpeg</url>
      <title>DEV Community: vietdt89</title>
      <link>https://dev.to/vietdt89</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vietdt89"/>
    <language>en</language>
    <item>
      <title>Setup Uart with STM32F411RE</title>
      <dc:creator>vietdt89</dc:creator>
      <pubDate>Sat, 26 Oct 2024 06:18:49 +0000</pubDate>
      <link>https://dev.to/vietdt89/setup-uart-with-stm32f411re-l4</link>
      <guid>https://dev.to/vietdt89/setup-uart-with-stm32f411re-l4</guid>
      <description>&lt;h2&gt;
  
  
  1. Open block diagram in Datasheet
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fczouw247dq7dqyl3crec.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fczouw247dq7dqyl3crec.png" alt="Image description" width="478" height="577"&gt;&lt;/a&gt;&lt;br&gt;
We will use USART2 interface because it is connected to the same bus (APB1) with the power interface. That means we can communicate directly with the computer via USB without having a chip to convert from UART to USB. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi6q2fp5y96gc14ywi07k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi6q2fp5y96gc14ywi07k.png" alt="Image description" width="368" height="199"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Write UART send function to computer USB
&lt;/h2&gt;

&lt;p&gt;Open Alternate function mapping in datasheet. We can see that creating UART TX involving PA2 and AF07 (will mention later)&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3e8p0s0ch3fw1r5l7mtz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3e8p0s0ch3fw1r5l7mtz.png" alt="Image description" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First we need to setup PA2 port to alternate function type as table above&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Enable clock to GPIOA
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RCC-&amp;gt;AHB1ENR |= GPIOAEN;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Set PA2 to alternate mode
As the table, we need to set bit 5 and 4 of pin 2 to value 10
If we want to receive UART, as the alternate table, we need to set PA3 to alternate mode
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqjiisnt6tyk662babihf.png" alt="Image description" width="800" height="503"&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GPIOA-&amp;gt;MODER &amp;amp;=~(1U&amp;lt;&amp;lt;4);
GPIOA-&amp;gt;MODER |= (1U&amp;lt;&amp;lt;5);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GPIOA-&amp;gt;MODER &amp;amp;=~(1U&amp;lt;&amp;lt;6);
GPIOA-&amp;gt;MODER |= (1U&amp;lt;&amp;lt;7);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Set PA2 alternate type to UART_TX
As mentioned above, besides PA2, we need to modify AF07. AFRL is a low register for alternate function 
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhikemnd2cijdu0jbof8z.png" alt="Image description" width="800" height="523"&gt;
There are 2 alternate function registers, and we are dealing with PA2, so we use AFR[0] for low to locate to AFRL2, and we will modify bit 8, 9, 10, 11. To set to AF7, use value 0111
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GPIOA-&amp;gt;AFR[0] |= (1U&amp;lt;&amp;lt;8);
GPIOA-&amp;gt;AFR[0] |= (1U&amp;lt;&amp;lt;9);
GPIOA-&amp;gt;AFR[0] |= (1U&amp;lt;&amp;lt;10);
GPIOA-&amp;gt;AFR[0] &amp;amp;= ~(1U&amp;lt;&amp;lt;11);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Set PA3&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GPIOA-&amp;gt;AFR[0] |= (1U&amp;lt;&amp;lt;12);
GPIOA-&amp;gt;AFR[0] |= (1U&amp;lt;&amp;lt;13);
GPIOA-&amp;gt;AFR[0] |= (1U&amp;lt;&amp;lt;14);
GPIOA-&amp;gt;AFR[0] &amp;amp;= ~(1U&amp;lt;&amp;lt;15);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Set clock to USART2 port
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqnss7bv9g4xtkoczn389.png" alt="Image description" width="800" height="346"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#define UART2EN (1U&amp;lt;&amp;lt;17)
RCC-&amp;gt;APB1ENR |= UART2EN;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Set direction of UART to sending
We need to set TE mode
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi1ltlgrfzid8l4md7g02.png" alt="Image description" width="800" height="229"&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgs184pd81hwwhhkohjjb.png" alt="Image description" width="531" height="92"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#define CR1_TE (1U&amp;lt;&amp;lt;3)
USART2-&amp;gt;CR1 = CR1_TE;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to enable USART in bit 13&lt;br&gt;
Remember that we only enable after we set up all the configuration.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftxmt2lrxt5922hne76os.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftxmt2lrxt5922hne76os.png" alt="Image description" width="724" height="134"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#define CR1_UE (1U&amp;lt;&amp;lt;13)
USART2-&amp;gt;CR1 |= CR1_UE;
USART2-&amp;gt;CR1 = CR1_TE | CR1_RE; //if we want to receive UART
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Set baudrate&lt;br&gt;
We will set frequency as 16Mhz and baudrate as 115200. &lt;br&gt;
And calculate as formula below&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8yav0xlk3xwdpnfykahd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8yav0xlk3xwdpnfykahd.png" alt="Image description" width="340" height="66"&gt;&lt;/a&gt;&lt;br&gt;
Then we need to set value to BRR register&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvi3lfsrwooa4joa3vi0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvi3lfsrwooa4joa3vi0.png" alt="Image description" width="800" height="251"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Write data to pin&lt;br&gt;
Before sending, we need to check if send status is ok or not&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F56qit66ypzqy2vb8fit3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F56qit66ypzqy2vb8fit3.png" alt="Image description" width="800" height="214"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9wdyxha20jte1nmc6ssy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9wdyxha20jte1nmc6ssy.png" alt="Image description" width="723" height="140"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#define SR_TXE (1U&amp;lt;&amp;lt;7)
USART2-&amp;gt;SR &amp;amp; SR_TXE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we can only write one character per write&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1bqpkx64oewof9csnhc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1bqpkx64oewof9csnhc.png" alt="Image description" width="800" height="233"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;USART2-&amp;gt;DR = (character &amp;amp; 0xFF);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include "stm32f4xx.h"
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

#define GPIOAEN (1U&amp;lt;&amp;lt;0)
#define UART2EN (1U&amp;lt;&amp;lt;17)

#define CR1_TE (1U&amp;lt;&amp;lt;3)
#define CR1_UE (1U&amp;lt;&amp;lt;13)
#define SR_TXE (1U&amp;lt;&amp;lt;7)

#define SYS_FREQ 16000000
#define APB1_CLK SYS_FREQ
#define UART_BAUDRATE 115200

static void uart_set_baudrate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t BaudRate);
static uint16_t compute_uart_bd(uint32_t PeriphClk,uint32_t BaudRate);
void uart2_tx_init(void);
void uart2_write(int ch);

int __io_putchar(int ch){
    uart2_write(ch);
    return ch;
}
int main(void){
    uart2_tx_init();
    while(1){
        uart2_write('O');
        //printf("hello\n\r");
    }
    return 0;
}

void uart2_tx_init(void){
    //Enable GPIOA
    RCC-&amp;gt;AHB1ENR |= GPIOAEN;

    //Set PA2 to alternate function mode
    GPIOA-&amp;gt;MODER &amp;amp;=~(1U&amp;lt;&amp;lt;4);
    GPIOA-&amp;gt;MODER |= (1U&amp;lt;&amp;lt;5);

    //Set PA2 alternate function type to UART_TX (AF07)
    GPIOA-&amp;gt;AFR[0] |= (1U&amp;lt;&amp;lt;8);
    GPIOA-&amp;gt;AFR[0] |= (1U&amp;lt;&amp;lt;9);
    GPIOA-&amp;gt;AFR[0] |= (1U&amp;lt;&amp;lt;10);
    GPIOA-&amp;gt;AFR[0] &amp;amp;= ~(1U&amp;lt;&amp;lt;11);
    //Enable clock access to uart2
    RCC-&amp;gt;APB1ENR |= UART2EN;

    //Configure baudrate
    uart_set_baudrate(USART2, APB1_CLK, UART_BAUDRATE);
    //Configure transfer direct
    USART2-&amp;gt;CR1 = CR1_TE;

    //Enable uart module
    USART2-&amp;gt;CR1 |= CR1_UE;

}

void uart2_write(int ch){
    while( !(USART2-&amp;gt;SR &amp;amp; SR_TXE)){}
    USART2-&amp;gt;DR = (ch &amp;amp; 0xFF);
}

static void uart_set_baudrate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t BaudRate){
    USARTx-&amp;gt;BRR |= compute_uart_bd(PeriphClk, BaudRate);
}

static uint16_t compute_uart_bd(uint32_t PeriphClk,uint32_t BaudRate){
    return ((PeriphClk + (BaudRate/2U))/BaudRate);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>stm32</category>
    </item>
    <item>
      <title>Push button and led blink with STM32F411RE</title>
      <dc:creator>vietdt89</dc:creator>
      <pubDate>Fri, 25 Oct 2024 08:43:08 +0000</pubDate>
      <link>https://dev.to/vietdt89/push-button-and-led-blink-with-stm32f411re-4nce</link>
      <guid>https://dev.to/vietdt89/push-button-and-led-blink-with-stm32f411re-4nce</guid>
      <description>&lt;h3&gt;
  
  
  Write a driver to listen to button push event then blink led
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Tool&lt;br&gt;
Board STm32F411RE&lt;br&gt;
Cube IDE&lt;br&gt;
Datasheet&lt;br&gt;
Reference manual&lt;br&gt;
User manual&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi01qtz3rimh2g74ffngu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi01qtz3rimh2g74ffngu.png" alt="Image description" width="406" height="471"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  1. Open User manual to locate led and button pin
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjgq60hydh2uvxhl5smzi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjgq60hydh2uvxhl5smzi.png" alt="Image description" width="800" height="130"&gt;&lt;/a&gt;&lt;br&gt;
To confirm the port and pin, we check the board selector in CubeIDE&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5cd68fch7q7qqq0fft32.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5cd68fch7q7qqq0fft32.png" alt="Image description" width="647" height="617"&gt;&lt;/a&gt;&lt;br&gt;
Now we know that LED is on PA15 (port A pin 5), button is on PC 13 (Port C pin 13). We go to block diagram to check the bus that connect to that port. We need to enable clock to the bus before communicating with the ports&lt;br&gt;
To check the bus, go to Datasheet-&amp;gt; block diagram&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo6vfcf5x3it00iohu8si.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo6vfcf5x3it00iohu8si.png" alt="Image description" width="537" height="541"&gt;&lt;/a&gt;&lt;br&gt;
Both ports are on bus AHB1&lt;/p&gt;
&lt;h4&gt;
  
  
  2. Download header file
&lt;/h4&gt;

&lt;p&gt;Now go to ST website and download the &lt;a href="https://www.st.com/en/embedded-software/stm32cubef4.html" rel="noopener noreferrer"&gt;STM32CubeF4&lt;/a&gt;. This contains the header for controlling the register so that we don't need to calculate the bit location manually. &lt;br&gt;
Get the latest here&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4nnncznt7ds04a00rm4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4nnncznt7ds04a00rm4.png" alt="Image description" width="800" height="95"&gt;&lt;/a&gt;&lt;br&gt;
We will keep these folders and delete all the remaining&lt;br&gt;
&lt;code&gt;\STM32Cube_FW_F4_V1.28.0\Drivers\CMSIS\Include&lt;br&gt;
\STM32Cube_FW_F4_V1.28.0\Drivers\CMSIS\Device\ST\STM32F4xx&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  3. Create new project
&lt;/h4&gt;

&lt;p&gt;Create new project with STM32F411 component&lt;br&gt;
Then import the header folder to Cube project&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjay6az33rzg17m953lxu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjay6az33rzg17m953lxu.png" alt="Image description" width="800" height="284"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  4. Source code
&lt;/h4&gt;

&lt;p&gt;If we do not have stm32f4xx header, we will have to define the register location manually&lt;br&gt;
In the code, we wil use structs provided by the header.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*
#define PERIPH_BASE             (0x40000000UL)
#define AHB1PERIPH_OFFSET               (0x00020000UL)
#define AHB1PERIPH_BASE                 (PERIPH_BASE + AHB1PERIPH_OFFSET)

#define GPIOA_OFFSET                    (0x0000UL)
#define GPIOA_BASE              (AHB1PERIPH_BASE + GPIOA_OFFSET)

#define RCC_OFFSET              (0x3800UL)
#define RCC_BASE                (AHB1PERIPH_BASE + RCC_OFFSET)

#define AHB1EN_R_OFFSET                 (0x30UL)
#define RCC_AHB1EN_R                    (*(volatile unsigned int*)(RCC_BASE + AHB1EN_R_OFFSET))

#define MODE_R_OFFSET                    (0x00UL)
#define GPIOA_MODE_R                     (*(volatile unsigned int*)(GPIOA_BASE + MODE_R_OFFSET))

#define OD_R_OFFSET              (0x14UL)
#define GPIOA_OD_R               (*(volatile unsigned int*)(GPIOA_BASE + OD_R_OFFSET))
*/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using header&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include "stm32f4xx.h"
#define GPIOAEN                  (1U&amp;lt;&amp;lt;0)
#define GPIOCEN                  (1U&amp;lt;&amp;lt;2)

#define PIN5                     (1U&amp;lt;&amp;lt;5)
#define PIN13                    (1U&amp;lt;&amp;lt;13)

#define LED_PIN                  PIN5
#define BTN_PIN                  PIN13

int main(void){
        // set clock for bus
    RCC-&amp;gt;AHB1ENR |= GPIOAEN;
    RCC-&amp;gt;AHB1ENR |= GPIOCEN;
        //set mode register for port A and port C
    GPIOA-&amp;gt;MODER |= (1U&amp;lt;&amp;lt;10);
    GPIOA-&amp;gt;MODER&amp;amp;=~(1U&amp;lt;&amp;lt;11);

    GPIOC-&amp;gt;MODER &amp;amp;=~(1U&amp;lt;&amp;lt;26);
    GPIOC-&amp;gt;MODER &amp;amp;=~(1U&amp;lt;&amp;lt;27);
        // reset led into off state
    //GPIOA-&amp;gt;ODR &amp;amp;= ~LED_PIN;
    GPIOA-&amp;gt;BSRR = (1U&amp;lt;&amp;lt;21);
        // blink loop
    while(1){
        if(GPIOC-&amp;gt;IDR &amp;amp; BTN_PIN){//if 
            GPIOA-&amp;gt;BSRR |= (1U&amp;lt;&amp;lt;21);
        }
        else{
            while (1){
                                //GPIOA-&amp;gt;ODR|= LED_PIN;
                GPIOA-&amp;gt;BSRR |= LED_PIN;
                for(int i = 0; i &amp;lt; 100000; i++){}//delay
                                //GPIOA-&amp;gt;ODR &amp;amp;= ~LED_PIN;
                GPIOA-&amp;gt;BSRR |= (1U&amp;lt;&amp;lt;21);
                for(int i = 0; i &amp;lt; 100000; i++){}//delay
                if(GPIOC-&amp;gt;IDR &amp;amp; BTN_PIN){
                    break;
                }
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explain&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. Go to memory mapping in datasheet&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftu6krywjuqy717dphg61.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftu6krywjuqy717dphg61.png" alt="Image description" width="798" height="735"&gt;&lt;/a&gt;&lt;br&gt;
We can see that AHB1 bus register starts at 0x4002 0000 and the root address of all registers starts at 0x4000 0000. From this, we will define all register that we need to control the ports. &lt;br&gt;
&lt;strong&gt;2. Register needed&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All information is in Reference manual document&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RCC AHB1: provide clock to AHB1 bus&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fieiwimex7eyydiftwcnl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fieiwimex7eyydiftwcnl.png" alt="Image description" width="800" height="335"&gt;&lt;/a&gt;&lt;br&gt;
Port A is at pin 0, port C is at pin 2. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mode register: to set operation mode for each port. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frpxfpqevke9cd3qukdxy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frpxfpqevke9cd3qukdxy.png" alt="Image description" width="800" height="309"&gt;&lt;/a&gt;&lt;br&gt;
We use port A to set led, port C to receive button event so port A will be output mode, port C will be input mode&lt;br&gt;
Set led at Port A pin 5, so bit 11 and 10 of mode register should be 01. &lt;br&gt;
Receive button event at Port C pin 13 so bit 27 26 of mode register should be 00. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Set led&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have 2 ways to set led. One is to set data pin, the other is to set reset pin. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set data pin
Find data register&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3qotrppbcrf7n6lj23ra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3qotrppbcrf7n6lj23ra.png" alt="Image description" width="800" height="240"&gt;&lt;/a&gt;&lt;br&gt;
Since led pin is in pin 5. We set led on off by setting bit 5 with 1 or 0&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GPIOA-&amp;gt;ODR|= LED_PIN;
GPIOA-&amp;gt;ODR &amp;amp;= ~LED_PIN;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Set/reset bit reset register&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwjgt9dnz094fvjh7nhs2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwjgt9dnz094fvjh7nhs2.png" alt="Image description" width="800" height="261"&gt;&lt;/a&gt;&lt;br&gt;
Set pin 5 bit 5 in reset in bit 21. So the code is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GPIOA-&amp;gt;BSRR |= LED_PIN;
GPIOA-&amp;gt;BSRR |= (1U&amp;lt;&amp;lt;21);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To listen to button event, we will listen to pin 13 of input data register&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhadq3q5wl0rguvquqjpu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhadq3q5wl0rguvquqjpu.png" alt="Image description" width="800" height="237"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GPIOC-&amp;gt;IDR &amp;amp; BTN_PIN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if bit is 1, button is released, 0 button is pressed&lt;br&gt;
Here we have pullup, pulldown transistor for button&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We need pullup transistor so that when button is not pressed, the state will be pulled up to HIGH&lt;/li&gt;
&lt;li&gt;We need pulldown transistor so that when button is pressed, the state will be pulled down to LOW&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>stm32f4</category>
    </item>
    <item>
      <title>Delegation is the last thing managers should do</title>
      <dc:creator>vietdt89</dc:creator>
      <pubDate>Tue, 23 Apr 2024 00:55:48 +0000</pubDate>
      <link>https://dev.to/vietdt89/delegation-is-the-last-thing-managers-should-do-3af0</link>
      <guid>https://dev.to/vietdt89/delegation-is-the-last-thing-managers-should-do-3af0</guid>
      <description>&lt;h2&gt;
  
  
  Delegation is a vital skill of effective leadership. It involves entrusting tasks and responsibilities to team members based on their skills, capabilities, and expertise, thereby fostering a culture of empowerment and accountability.
&lt;/h2&gt;

&lt;p&gt;Effective delegation not only enhances productivity and efficiency but also promotes professional growth and development within the team. Mastering the art of delegation enables managers to focus on strategic initiatives and decision-making while empowering their team to take ownership and contribute to the overall goals of the organization.&lt;/p&gt;

&lt;p&gt;There are lots of things you can do. Here are the ones I believe have the most impact:.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before delegation&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Raise team's capabilities
According to Blanchard, different people in different situations need different styles of leadership. High competence and a good attitude are the first criteria to consider. Every member needs continuous improvement. Even the ones with high expertise who recently joined your team or the members who formed the team in the first place.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Giving your members training is an effective way to build trust and the foundation so that they can do the work with the least of our direction.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Communicate clearly
There are important things that we need to clearly communicate to your directs&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A SMART goal is a way for us to know when the work is done and how we can measure the progress. This is a critical tool so that they can manage themselves.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Capability dictionary: a list of what we have to obtain to do the work with best quality. Members who are eager to learn can refer to it to improve their competency.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;After delegation&lt;/strong&gt;&lt;br&gt;
It is very difficult for everything to go the correct way from beginning. Now monitoring comes in handy&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Provide feedback&lt;br&gt;
woman in white long sleeve shirt sitting on red couch&lt;br&gt;
For managers, 1:1 meetings are a familiar tool. We should use it to give instant feedback from various points of view so that members can correctly “turn the steering wheel.”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reflect on process&lt;br&gt;
We can learn a lot from observing others working. Write it down and update the processes for future preparation of the next delegation as well as our own way of working.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Last words&lt;/strong&gt;&lt;br&gt;
Mastering the art of delegation is not just about distributing tasks; it's about empowering your team, fostering growth, and achieving collective success. By delegating effectively, managers can unlock the full potential of their team members, creating a dynamic and productive work environment where everyone thrives. So, embrace delegation as a strategic tool in your people management arsenal, and watch as your team flourishes and accomplishes more than you ever thought possible.&lt;/p&gt;

&lt;p&gt;If you like my post, hit like button or comment if you want to add more ideas&lt;br&gt;
Visit my &lt;a href="https://viettuandao.substack.com/p/delegation-is-the-last-thing-managers" rel="noopener noreferrer"&gt;site &lt;/a&gt; for more articles&lt;/p&gt;

</description>
      <category>management</category>
      <category>delegation</category>
      <category>process</category>
      <category>people</category>
    </item>
    <item>
      <title>Easy way to setup VSCode to learn Linux programming</title>
      <dc:creator>vietdt89</dc:creator>
      <pubDate>Sat, 13 Apr 2024 02:37:09 +0000</pubDate>
      <link>https://dev.to/vietdt89/easy-way-to-setup-vscode-to-learn-linux-programming-2a9c</link>
      <guid>https://dev.to/vietdt89/easy-way-to-setup-vscode-to-learn-linux-programming-2a9c</guid>
      <description>&lt;h2&gt;
  
  
  As an embedded engineer, I often need to practice Linux programming on my Windows laptop. I believe that installing a distro directly into the system is superfluous and somewhat complex.
&lt;/h2&gt;

&lt;p&gt;I have since discovered WSL, which is more practical. Thus, I make a few notes about how to configure the system to run and build code. &lt;br&gt;
This is for some one who knows how to do it but struggles to make it work&lt;br&gt;
&lt;strong&gt;1. Use virtual machine&lt;/strong&gt;&lt;br&gt;
Firstly, I remind everyone about the old-school method with VM&lt;br&gt;
You need Virtual machine with an Ubuntu distro. I choose Kubuntu because I think it is less prone to error than Ubuntu ( just my personal experience). &lt;/p&gt;

&lt;p&gt;Install ssh to Ubuntu then enable it&lt;br&gt;
The most important part is setting up Network in VM&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7htscxfwkj33p2euhpol.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7htscxfwkj33p2euhpol.png" alt="Image description" width="800" height="392"&gt;&lt;/a&gt;&lt;br&gt;
The guess IP is the IP in Ubuntu you get from the ifconfig command. &lt;br&gt;
You can test the connection in command window&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Filr3hlj9zmi5apudlzbp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Filr3hlj9zmi5apudlzbp.png" alt="Image description" width="800" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now open VSCode or Visual studio, install SSH extension and create new one, use the same command above and you are good to write code. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Use WSL&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;WSL stands for Windows Subsystem for Linux. In short, it works like below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidid4c6ydt5anq5juv36.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidid4c6ydt5anq5juv36.png" alt="Image description" width="738" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/windows/wsl/setup/environment" rel="noopener noreferrer"&gt;This&lt;/a&gt; is the best tutorial on how to install WSL and connect it with VSCode. Just follow it. &lt;br&gt;
Now you can access a Linux system like using VM, we come to the most important part, compile and run/debug source code. &lt;br&gt;
You need to create a Hello world cpp file to test. &lt;br&gt;
We need tasks.json file to compile the code in Linux and a launch.json file to debug. &lt;br&gt;
tasks.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "compiler: /usr/bin/g++"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install gdb to Linux using command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install gdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now check where gdb is&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fatxkfohlvk9v7f9x492w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fatxkfohlvk9v7f9x492w.png" alt="Image description" width="629" height="40"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Config launch.json file and update miDebuggerPath with the path you get&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "debug",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "MIMode": "gdb",
            "cwd": "${fileDirname}",
            "miDebuggerPath": "/usr/bin/gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++ build active file"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To compile code, use Ctrl Shift B&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjme57r7vdroofkax1mx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjme57r7vdroofkax1mx.png" alt="Image description" width="739" height="138"&gt;&lt;/a&gt;&lt;br&gt;
To debug, use Run -&amp;gt; Start Debugging&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fco0hvws6x7ldsjd39y5i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fco0hvws6x7ldsjd39y5i.png" alt="Image description" width="800" height="536"&gt;&lt;/a&gt;&lt;br&gt;
Everything should be ok now. Enjoy!&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>linux</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
