{"id":2670,"date":"2024-08-15T12:35:39","date_gmt":"2024-08-15T12:35:39","guid":{"rendered":"https:\/\/iotthinghub.com\/?p=2670"},"modified":"2024-08-15T13:04:19","modified_gmt":"2024-08-15T13:04:19","slug":"display-control-ssd-led","status":"publish","type":"post","link":"https:\/\/iotthinghub.com\/?p=2670","title":{"rendered":"Display Control SSD &amp; LED"},"content":{"rendered":"\n<p class=\"has-text-color has-link-color wp-elements-7f562ea37c3cee1b14b35fb307ce5ef8 wp-block-paragraph\" style=\"color:#5c5c5c\">In this example we introduce a display contain custom digits and LED indicator. Since STM32 has may GPIO pin we can easily interface LEDs and Seven Segment Display. But in this section we will develop a custom display using Latch Register 74HC595. For the basic of Seven Segment Display &amp; SPI interface with 74HC595 please go through the section we discuss earlier. We will develop part by part. Let\u2019s start with 4 digits Seven Segment Display.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"304\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/4-Digit-CA-SSD-1024x304.jpg\" alt=\"\" class=\"wp-image-2672\" style=\"width:755px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/4-Digit-CA-SSD-1024x304.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/4-Digit-CA-SSD-300x89.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/4-Digit-CA-SSD-768x228.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/4-Digit-CA-SSD.jpg 1410w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-6894d3ebc5e473571aaf708eb88c9d23 wp-block-paragraph\" style=\"color:#5c5c5c\">Here we use Common Anode 4 digit Seven Segment Display. If we connect the 74HC595 with the following configuration then-<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" width=\"1024\" height=\"75\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-1-1-1024x75.jpg\" alt=\"\" class=\"wp-image-2676\" style=\"width:737px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-1-1-1024x75.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-1-1-300x22.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-1-1-768x56.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-1-1.jpg 1373w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-7c576e7416ca9c895351d528e0391ea4 wp-block-paragraph\" style=\"color:#5c5c5c\">So that to display 0, bit sends will be 0b11000000. Similarly other digit will be created. After connect V<sub>cc <\/sub>to Pin6 then we see a 0 value shows in digit4 or V<sub>cc <\/sub>to Pin12 digit1 will show 0 value. We have to control the digit with either using GPIO pin or using another 74HC595 latch. We will use another 74HC595 latch register and control the digit[1:4] using persistence of vision. To know more about persistence of vision &amp; how it works just see my illusion article. We use remaining 4 pin to control LEDs to indicate different indicators. Let\u2019s look at the full connection diagram \u2013<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" width=\"1024\" height=\"541\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/Latch-Connection-1024x541.jpg\" alt=\"\" class=\"wp-image-2679\" style=\"width:791px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/Latch-Connection-1024x541.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/Latch-Connection-300x158.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/Latch-Connection-768x406.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/Latch-Connection.jpg 1301w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-adc289bff84141386e30bef91dee04c0 wp-block-paragraph\" style=\"color:#5c5c5c\">Only 4 pin will use to control the whole display. Make the MR=High and OE= GND. From the shifting logic of 74HC595 we have to do the following function step by step-<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"166\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-2-1024x166.jpg\" alt=\"\" class=\"wp-image-2681\" style=\"width:746px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-2-1024x166.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-2-300x49.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-2-768x125.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-2.jpg 1298w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-6526a69a1e25790d937c6e99ad4f3417 wp-block-paragraph\" style=\"color:#5c5c5c\">Set SPI1 with parameters that need to be changed in STM32 as follow-<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"101\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-3-1024x101.jpg\" alt=\"\" class=\"wp-image-2682\" style=\"width:781px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-3-1024x101.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-3-300x30.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-3-768x76.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/function-3.jpg 1293w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-63dc6b596b872f0c9295f8336b493c4d wp-block-paragraph\" style=\"color:#5c5c5c\">Other parameters remain the same. Here we introduce only one function of SPI HAL Library.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-56792f24ac29be7074cdb73f8645c95b wp-block-paragraph\" style=\"color:#5c5c5c\">HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout)<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-d381ba2652ae824ec2018c766d046e54 wp-block-paragraph\" style=\"color:#5c5c5c\">Here, hspi is hspi1, since we initialize SPI1<\/p>\n\n\n\n<ul style=\"color:#5c5c5c\" class=\"wp-block-list has-text-color has-link-color wp-elements-341822bb687fd6a41983c82e4471e0a3\">\n<li>pData pointer to data buffer<\/li>\n\n\n\n<li>Size amount of data to be sent<\/li>\n\n\n\n<li>Timeout Timeout duration<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-0ddba05eb0ec9f30ffab0c6436910bdd wp-block-paragraph\" style=\"color:#5c5c5c\">We use STM320308-DISCO board with GPIO pin PC4 for Seven Segment Display part &amp; pin PC5 for Controlling Part. Suppose we only want to set Q7 pin of CONTROL latch 74HC595, simple code is-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\n    uint8_t Led&#x5B;0]= 0b10000000;\n    HAL_SPI_Transmit(&amp;hspi1, Led,1,100);\n\tHAL_GPIO_WritePin(GPIOC,GPIO_PIN_5,GPIO_PIN_SET);\n\tHAL_Delay(1);\n\tHAL_GPIO_WritePin(GPIOC,GPIO_PIN_5,GPIO_PIN_RESET);\n\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-60ea61a6acfb6ed1f0b2f0e6b81db9e2 wp-block-paragraph\" style=\"color:#5c5c5c\">If we use this function in main.c file then there will be no error, but if we want to make our own segment.c &amp; segment.h file and use the SPI HAL Library, there will be an error of undefined &amp;hspi1. We use global type variable declaration to overcome that error that-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\nextern SPI_HandleTypeDef hspi1;\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-8d1605b16cd68a16c3aaabea1277e789 wp-block-paragraph\" style=\"color:#5c5c5c\">We use same void print(unsigned long int num) -&gt; function that we developed in ATmel section with couple of changes. We introduce a new function of \u2013<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-04c2be3bfe56a9050cd88bdfd0dc40fb wp-block-paragraph\" style=\"color:#5c5c5c\">void LED_ON(uint8_t value)->\u00a0 to display indicators Please <a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/SSD-Driver.rar\">download<\/a> the <a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/SSD-Driver.rar\">driver<\/a> which contain the segment.c &amp; segment.h file and follow the procedure as shown in the video.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"STM32 Display with SSD\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/LZbcSqmWBl4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-220f28596d098ef2cb521f5f4b479d4e wp-block-paragraph\" style=\"color:#5c5c5c\">The connection diagram has a simplified model as follow-<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"284\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/SSD-Connection-1024x284.jpg\" alt=\"\" class=\"wp-image-2688\" style=\"width:772px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/SSD-Connection-1024x284.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/SSD-Connection-300x83.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/SSD-Connection-768x213.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/SSD-Connection.jpg 1325w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-7387b849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\">\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-3e41869c wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/DISPLAY-SSD-STM32F0308.rar\" style=\"padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--50);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--50)\">download<\/a><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-7f09757dbf54351ed479f31c11ef59da wp-block-paragraph\" style=\"color:#252525\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/DISPLAY-SSD-STM32F0308.rar\">DISPLAY SSD STM32F0308.rar<\/a><\/p>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this example we introduce a display contain custom digits and LED indicator. Since STM32 has may GPIO pin we can easily interface LEDs and Seven Segment Display. But in this section we will develop a custom display using Latch Register 74HC595. For the basic of Seven Segment Display &amp; SPI interface with 74HC595 please [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-2670","post","type-post","status-publish","format-standard","hentry","category-arm-standards-peripherals"],"_links":{"self":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/2670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2670"}],"version-history":[{"count":11,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/2670\/revisions"}],"predecessor-version":[{"id":2695,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/2670\/revisions\/2695"}],"wp:attachment":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}