{"id":1817,"date":"2025-10-13T00:00:00","date_gmt":"2025-10-12T15:00:00","guid":{"rendered":"https:\/\/twarelab.com\/?p=1817"},"modified":"2025-10-02T15:08:38","modified_gmt":"2025-10-02T06:08:38","slug":"stm32f4-c-project-tutorial-step-5-1","status":"publish","type":"post","link":"https:\/\/twarelab.com\/en\/blog\/stm32f4-c-project-tutorial-step-5-1\/","title":{"rendered":"[STM32F4] C++ \ud504\ub85c\uc81d\ud2b8 \ud29c\ud1a0\ub9ac\uc5bc &#8211; Step 5-1"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">SPI \uae30\ubc18 M95M04 Serial Flash \uc77d\uae30\/\uc4f0\uae30<\/h2>\n\n\n\n<p>\uc55e\uc120 \uae00\uc5d0\uc11c\ub294 SPI \uc778\ud130\ud398\uc774\uc2a4\uc758 \uae30\ubcf8 \uad6c\uc870\uc640 \uc7a5\uce58\ubcc4 \ud655\uc7a5 \ud074\ub798\uc2a4 \uc124\uacc4 \ubc29\uc2dd\uc744 \ub2e4\ub8e8\uc5c8\uc2b5\ub2c8\ub2e4.<br>\uc774\ubc88 \uae00\uc5d0\uc11c\ub294 \uc774\ub97c \uc2e4\uc81c \uc608\uc81c\ub85c \ud655\uc7a5\ud558\uc5ec, <strong>M95M04 Serial Flash<\/strong> \uc7a5\uce58\ub97c C++ \ud074\ub798\uc2a4\ub85c \uad6c\ud604\ud558\uace0, SPI\ub97c \ud1b5\ud574 \ub370\uc774\ud130\ub97c \uc77d\uace0 \uc4f0\ub294 \uacfc\uc815\uc744 \uc124\uba85\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">M95M04 Serial Flash\uc758 \ud2b9\uc9d5<\/h2>\n\n\n\n<p><strong>M95M04<\/strong>\ub294 STMicroelectronics\uc5d0\uc11c \uc81c\uacf5\ud558\ub294 <strong>4Mbit(512KB)<\/strong> \uc6a9\ub7c9\uc758 <strong>SPI \uae30\ubc18 \uc2dc\ub9ac\uc5bc \ud50c\ub798\uc2dc \uba54\ubaa8\ub9ac<\/strong>\uc785\ub2c8\ub2e4.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\uc6a9\ub7c9<\/strong>: 4Mbit (512KB)<\/li>\n\n\n\n<li><strong>SPI \uc778\ud130\ud398\uc774\uc2a4<\/strong>: \ucd5c\ub300 20MHz \ub3d9\uc791<\/li>\n\n\n\n<li><strong>\ud398\uc774\uc9c0 \ud06c\uae30<\/strong>: 256\ubc14\uc774\ud2b8 \ub2e8\uc704 \uc4f0\uae30<\/li>\n\n\n\n<li><strong>\uba85\ub839\uc5b4 \uc138\ud2b8<\/strong>: Read(0x03), Write(0x02), Write Enable(0x06), Read Status Register(0x05) \ub4f1<\/li>\n\n\n\n<li><strong>\ubcf4\uc874 \ud2b9\uc131<\/strong>: 20\ub144 \uc774\uc0c1 \ub370\uc774\ud130 \uc720\uc9c0, 1,000,000\ud68c \uc774\uc0c1 \uc4f0\uae30\/\uc9c0\uc6b0\uae30 \ubcf4\uc7a5<\/li>\n\n\n\n<li><strong>\ubcf4\ud638 \uae30\ub2a5<\/strong>: WP(Write Protect), HOLD \ud540 \uc81c\uacf5<\/li>\n<\/ul>\n\n\n\n<p>\uc774\ub7ec\ud55c \ud2b9\uc9d5 \ub355\ubd84\uc5d0 \ud38c\uc6e8\uc5b4 \uc800\uc7a5, \ub85c\uadf8 \uae30\ub85d, \ud658\uacbd \uc124\uc815 \ubcf4\uc874 \ub4f1\uc5d0 \uc801\ud569\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud074\ub798\uc2a4 \uc124\uacc4<\/h2>\n\n\n\n<p><code>M95M04SPI<\/code> \ud074\ub798\uc2a4\ub294 <code>BaseSPI<\/code>\ub97c \uc0c1\uc18d\ubc1b\uc544 \uc791\uc131\ub418\uc5c8\uc73c\uba70, M95M04 \uc804\uc6a9 \ud504\ub85c\ud1a0\ucf5c\uc744 \uad6c\ud604\ud569\ub2c8\ub2e4<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\uc8fc\uc694 \uba64\ubc84 \ubcc0\uc218<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>pSPI<\/code> : \uc0ac\uc6a9\ud560 SPI \uc778\ud130\ud398\uc774\uc2a4 \ud3ec\uc778\ud130<\/li>\n\n\n\n<li><code>nCS<\/code> : Chip Select \ud540<\/li>\n\n\n\n<li><code>nWP<\/code> : Write Protect \ud540<\/li>\n\n\n\n<li><code>nHOLD<\/code> : Hold \ud540<\/li>\n\n\n\n<li><code>CTask<\/code> : \ub514\ubc84\uae45 \ub85c\uadf8 \ucd9c\ub825\uc744 \uc704\ud55c \ucf58\uc194 \ud0dc\uc2a4\ud06c<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\uc8fc\uc694 \uba64\ubc84 \ud568\uc218<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>WriteEnable() \/ WriteDisable()<\/code> : \uc4f0\uae30 \uac00\ub2a5 \uc0c1\ud0dc \uc804\ud658<\/li>\n\n\n\n<li><code>WriteByte(), ReadByte()<\/code> : \ub2e8\uc77c \ubc14\uc774\ud2b8 \uc1a1\uc218\uc2e0<\/li>\n\n\n\n<li><code>sendCommand(), sendAddress()<\/code> : \uba85\ub839\uc5b4 \ubc0f \uc8fc\uc18c \uc804\uc1a1<\/li>\n\n\n\n<li><code>WriteData(addr, buf, len)<\/code> : \ud2b9\uc815 \uc8fc\uc18c\uc5d0 \ub370\uc774\ud130 \uc4f0\uae30<\/li>\n\n\n\n<li><code>ReadData(addr, buf, len)<\/code> : \ud2b9\uc815 \uc8fc\uc18c\uc5d0\uc11c \ub370\uc774\ud130 \uc77d\uae30<\/li>\n\n\n\n<li><code>EEPROM_Test(addr, size)<\/code> : \uc77d\uae30\/\uc4f0\uae30\/\uac80\uc99d\uc744 \ud3ec\ud568\ud55c \ud14c\uc2a4\ud2b8 \ub8e8\ud2f4<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ucf54\ub4dc \uc608\uc81c<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \uac1d\uccb4 \uc120\uc5b8 \ubc0f \ucd08\uae30\ud654<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include \"M95M04SPI.h\"\n\nM95M04SPI eepSpi;\n\n...\nvoid InitSerialFlash(void);\n...\n\/*\n *\n *\/\nvoid InitSerialFlash(void)\n{\n#if defined(_SPI_EEP_)\n\t  eepSpi = M95M04SPI(SPI6, EEP_nCS_1, &amp;CTask);\n\t  eepSpi.setWPPin(EEP_nWP_1);\n\t  eepSpi.setHOLDPin(EEP_nHOLD_1);\n#endif\n}<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2. \ub370\uc774\ud130 \uc4f0\uae30<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\nthis->pEEPSPI->WriteData(this->pEEPos->FlashingSize.getPosition(), tmpBuf, this->pEEPos->FlashingSize.getLength());<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">3. \ub370\uc774\ud130 \uc77d\uae30<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">this->pEEPSPI->ReadData(this->pEEPos->bDebug.getPosition(), (uint8_t *)&amp;(this->pSysinfo->General.bDebug), this->pEEPos->bDebug.getLength());<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">4. \ud14c\uc2a4\ud2b8 \ud568\uc218 \ud65c\uc6a9<\/h3>\n\n\n\n<p><code>EEPROM_Test()<\/code>\ub294 \uc9c0\uc815\ud55c \uc8fc\uc18c\uc5d0 \ub370\uc774\ud130\ub97c \uc4f0\uace0, \ub2e4\uc2dc \uc77d\uc5b4\uc624\ub294 \uacfc\uc815\uc744 \uc790\ub3d9\uc73c\ub85c \uc218\ud589\ud558\uba70 \ub85c\uadf8\ub97c \ucd9c\ub825\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">void AT24CTask::EEPROMEraseAll(void)\n{\n\tint i, j;\n\n\tuint8_t data[32];\n\tfor(i=0; i&lt;32; i++)\n\t\tdata[i] = 0xFF;\n\n\tfor(i=0; i&lt;16*1024; i++)\n\t{\n\t      this->pEEPSPI->WriteData(32*i, (uint8_t *)&amp;i, 1);\n\t}\n\n\tfor(i=0; i&lt;16*1024; i++)\n\t{\n\t\tthis->pEEPSPI->ReadData(32*i, data, 32);\n\t\tfor(j=0; j&lt;32; j++)\n\t\t\tthis->CTask->PRINTF((char *)\"%02X \", data[j]);\n\t\tthis->CTask->PRINTF((char *)\"\\r\\n\");\n\t\tthis->CTask->flushTxBuf();\n\t}\n\n}<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud2b8\ub7ec\ube14\uc288\ud305<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\uc4f0\uae30 \ubd88\uac00<\/strong>\n<ul class=\"wp-block-list\">\n<li>\uc6d0\uc778: Write Enable(WREN) \uba85\ub839\uc5b4 \ub204\ub77d<\/li>\n\n\n\n<li>\ud574\uacb0: <code>WriteData()<\/code> \ub0b4\ubd80\uc5d0\uc11c WREN \ucc98\ub9ac \ud655\uc778<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\ub370\uc774\ud130 \uc77d\uae30 \ubd88\uc77c\uce58<\/strong>\n<ul class=\"wp-block-list\">\n<li>\uc6d0\uc778: \uc8fc\uc18c \uc804\uc1a1 \uc5d0\ub7ec(3\ubc14\uc774\ud2b8 \uc8fc\uc18c \ucc98\ub9ac \ubb38\uc81c)<\/li>\n\n\n\n<li>\ud574\uacb0: <code>sendAddress()<\/code> \ud568\uc218 \uad6c\ud604 \ud655\uc778 (24\ube44\ud2b8 \uc8fc\uc18c \uc804\uc1a1)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>SPI \uc751\ub2f5 \uc5c6\uc74c<\/strong>\n<ul class=\"wp-block-list\">\n<li>\uc6d0\uc778: CS \ud540 \uc81c\uc5b4 \uc624\ub958<\/li>\n\n\n\n<li>\ud574\uacb0: <code>csEnable()\/csDisable()<\/code> \ud568\uc218 \ud655\uc778<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ub9c8\uce58\uba70<\/h2>\n\n\n\n<p>\uc774\ubc88 \uae00\uc5d0\uc11c\ub294 <code>BaseSPI<\/code>\ub97c \uc0c1\uc18d\ubc1b\uc544 \uad6c\ud604\ud55c <strong>M95M04SPI \ud074\ub798\uc2a4<\/strong>\ub97c \ud1b5\ud574 \uc2e4\uc81c SPI Serial Flash \uc7a5\uce58\ub97c \ub2e4\ub918\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n<p>\ud575\uc2ec \ud3ec\uc778\ud2b8:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>M95M04\ub294 512KB \uc6a9\ub7c9\uc758 SPI \ud50c\ub798\uc2dc\ub85c, \uba85\ub839\uc5b4 \uae30\ubc18 \uc811\uadfc \ud544\uc694<\/li>\n\n\n\n<li><code>M95M04SPI<\/code> \ud074\ub798\uc2a4\uc5d0\uc11c \uc77d\uae30\/\uc4f0\uae30\/\ud14c\uc2a4\ud2b8 \ub8e8\ud2f4\uae4c\uc9c0 \uad6c\ud604<\/li>\n\n\n\n<li>\uc2e4\uc81c \ud504\ub85c\uc81d\ud2b8\uc5d0\uc11c\ub294 <code>EEPROM_Test()<\/code> \uac19\uc740 \ub8e8\ud2f4\uc744 \ud65c\uc6a9\ud558\uc5ec \ub370\uc774\ud130 \ubb34\uacb0\uc131\uc744 \uc27d\uac8c \uac80\uc99d \uac00\ub2a5<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>SPI \uae30\ubc18 M95M04 Serial Flash \uc77d\uae30\/\uc4f0\uae30 \uc55e\uc120 \uae00\uc5d0\uc11c\ub294 SPI \uc778\ud130\ud398\uc774\uc2a4\uc758 \uae30\ubcf8 \uad6c\uc870\uc640 \uc7a5\uce58\ubcc4 \ud655\uc7a5 \ud074\ub798\uc2a4 \uc124\uacc4 \ubc29\uc2dd\uc744 \ub2e4\ub8e8\uc5c8\uc2b5\ub2c8\ub2e4.\uc774\ubc88 \uae00\uc5d0\uc11c\ub294 \uc774\ub97c \uc2e4\uc81c \uc608\uc81c\ub85c \ud655\uc7a5\ud558\uc5ec, M95M04 Serial Flash \uc7a5\uce58\ub97c C++ \ud074\ub798\uc2a4\ub85c \uad6c\ud604\ud558\uace0, SPI\ub97c \ud1b5\ud574 \ub370\uc774\ud130\ub97c \uc77d\uace0 \uc4f0\ub294 \uacfc\uc815\uc744 \uc124\uba85\ud569\ub2c8\ub2e4. M95M04 Serial Flash\uc758 \ud2b9\uc9d5 M95M04\ub294 STMicroelectronics\uc5d0\uc11c \uc81c\uacf5\ud558\ub294 4Mbit(512KB) \uc6a9\ub7c9\uc758 SPI \uae30\ubc18 \uc2dc\ub9ac\uc5bc \ud50c\ub798\uc2dc [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1,13,12],"tags":[87,91,92,51,42,30],"class_list":["post-1817","post","type-post","status-publish","format-standard","hentry","category-blog","category-en","category-ko","tag-c","tag-m95m04","tag-serial-flash","tag-spi","tag-stm32f4","tag-tw100mj"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/twarelab.com\/en\/wp-json\/wp\/v2\/posts\/1817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/twarelab.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/twarelab.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/twarelab.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/twarelab.com\/en\/wp-json\/wp\/v2\/comments?post=1817"}],"version-history":[{"count":4,"href":"https:\/\/twarelab.com\/en\/wp-json\/wp\/v2\/posts\/1817\/revisions"}],"predecessor-version":[{"id":1822,"href":"https:\/\/twarelab.com\/en\/wp-json\/wp\/v2\/posts\/1817\/revisions\/1822"}],"wp:attachment":[{"href":"https:\/\/twarelab.com\/en\/wp-json\/wp\/v2\/media?parent=1817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/twarelab.com\/en\/wp-json\/wp\/v2\/categories?post=1817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/twarelab.com\/en\/wp-json\/wp\/v2\/tags?post=1817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}