{"id":5310,"date":"2012-06-26T22:17:47","date_gmt":"2012-06-27T02:17:47","guid":{"rendered":"http:\/\/embedded-lab.com\/blog\/?p=5310"},"modified":"2012-12-17T22:54:16","modified_gmt":"2012-12-18T03:54:16","slug":"dual-4-digit-seven-segment-led-display-with-spi-interface","status":"publish","type":"post","link":"https:\/\/embedded-lab.com\/blog\/dual-4-digit-seven-segment-led-display-with-spi-interface\/","title":{"rendered":"Dual 4-digit seven segment LED display with SPI interface"},"content":{"rendered":"<p>This project is an extension of my previous <a href=\"http:\/\/embedded-lab.com\/blog\/?p=4935\">MAX7219 based SPI seven segment LED display<\/a> module. The new display features eight 7-segment displays arranged in two rows of four digits. The on-board MAX7219 driver enables you to easily add eight 7-segment LED displays to your project using only 3 I\/O pins of microcontroller. The major advantage of using this board is the time-division multiplexing operations required for continuous refreshing of the display digits are performed by the MAX7219 chip, thereby keeping the microcontroller free for doing other pressing tasks. It is suitable for displaying two variable values simultaneously in a project, such as displaying temperature and humidity, or current and voltage, etc.<\/p>\n<div id=\"attachment_5311\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/8DigitSPIDisplayTitle.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5311\" class=\"size-full wp-image-5311\" title=\"8DigitSPIDisplayTitle\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/8DigitSPIDisplayTitle.jpg\" alt=\"\" width=\"565\" height=\"387\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/8DigitSPIDisplayTitle.jpg 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/8DigitSPIDisplayTitle-550x376.jpg 550w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><p id=\"caption-attachment-5311\" class=\"wp-caption-text\">8-digit seven segment LED display with serial interface<\/p><\/div>\n<p><!--more--><\/p>\n<p><strong>Key Features:<\/strong><\/p>\n<ul>\n<li>based on MAX7219 display driver<\/li>\n<li>SPI interface (3 pins)<\/li>\n<li>operates at +5V supply<\/li>\n<li>individual control of all digits and decimal points<\/li>\n<li>display brightness control through software<\/li>\n<li>dimensions 1.95? x 1.95? (50mm x 50mm)<\/li>\n<li>two 0.36? 4-digit seven segment LED display<\/li>\n<\/ul>\n<p>The circuit diagram of this project is very simple (shown below) and derived from the datasheet of the MAX7219.<\/p>\n<div id=\"attachment_5319\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/Circuit.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5319\" class=\"size-full wp-image-5319\" title=\"Circuit\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/Circuit.jpg\" alt=\"\" width=\"565\" height=\"521\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/Circuit.jpg 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/Circuit-550x507.jpg 550w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><p id=\"caption-attachment-5319\" class=\"wp-caption-text\">Circuit diagram as described in the datasheet of MAX7219<\/p><\/div>\n<div id=\"attachment_5313\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/AssembledBoard.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5313\" class=\"size-full wp-image-5313\" title=\"AssembledBoard\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/AssembledBoard.jpg\" alt=\"\" width=\"565\" height=\"451\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/AssembledBoard.jpg 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/AssembledBoard-550x439.jpg 550w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><p id=\"caption-attachment-5313\" class=\"wp-caption-text\">Assembled display board<\/p><\/div>\n<p>In the above board, digits from right to left in the first row are DIG0 through DIG3, whereas in the second row, the digits from right to left are DIG4-DIG7. The following example code is written in C and compiled with mikroC Pro for PIC compiler to illustrate how to interface this display module with the <a href=\"http:\/\/embedded-lab.com\/blog\/?p=5469\" target=\"_blank\">PIC12F project board<\/a>. The program is for\u00a0a dual 4-digit decimal counter. The first row of the display will be an up counter counting from 0000 to 9999 with one second duration. Meanwhile, the second row will count in reverse order from 9999 to 0000. The microcontroller used in the PIC12F board is PIC12F683. The details of MAX7219 registers and their initialization is described in my previous article <a href=\"http:\/\/embedded-lab.com\/blog\/?p=4935\">Serial 4-digit seven segment display module<\/a>.<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"c\" style=\"font-family:monospace;\"><span style=\"color: #808080; font-style: italic;\">\/*\n  Project: 4-digit Up\/Down counter using SPI 7-segment LED display\n  MCU: PIC12F683 running at 4.0MHz internal clock, MCLR disabled\n  Date: June 26, 2012\n*\/<\/span>\n&nbsp;\n<span style=\"color: #666666; font-style: italic;\">\/\/ Define Soft-SPI connections<\/span>\n<span style=\"color: #339933;\">#define CS_Pin       GP0_bit<\/span>\n<span style=\"color: #339933;\">#define MOSI_Pin     GP1_bit<\/span>\n<span style=\"color: #339933;\">#define CLK_Pin      GP2_bit<\/span>\n&nbsp;\n<span style=\"color: #993333;\">void<\/span> SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #993333;\">unsigned<\/span> <span style=\"color: #993333;\">short<\/span> num<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#123;<\/span>\n <span style=\"color: #993333;\">unsigned<\/span> <span style=\"color: #993333;\">short<\/span> t<span style=\"color: #339933;\">,<\/span> Mask<span style=\"color: #339933;\">,<\/span> Flag<span style=\"color: #339933;\">;<\/span>\n CLK_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>\n Mask <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">128<\/span><span style=\"color: #339933;\">;<\/span>\n <span style=\"color: #b1b100;\">for<\/span> <span style=\"color: #009900;\">&#40;<\/span>t<span style=\"color: #339933;\">=<\/span><span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span> t<span style=\"color: #339933;\">&amp;<\/span>lt<span style=\"color: #339933;\">;<\/span><span style=\"color: #0000dd;\">8<\/span><span style=\"color: #339933;\">;<\/span> t<span style=\"color: #339933;\">++<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#123;<\/span>\n  Flag <span style=\"color: #339933;\">=<\/span> num <span style=\"color: #339933;\">&amp;<\/span>amp<span style=\"color: #339933;\">;<\/span> Mask<span style=\"color: #339933;\">;<\/span>\n  <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #009900;\">&#40;<\/span>Flag <span style=\"color: #339933;\">==<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #009900;\">&#41;<\/span> MOSI_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>\n  <span style=\"color: #b1b100;\">else<\/span> MOSI_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>\n  CLK_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>\n  CLK_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>\n  Mask <span style=\"color: #339933;\">=<\/span> Mask <span style=\"color: #339933;\">&amp;<\/span>gt<span style=\"color: #339933;\">;&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>\n <span style=\"color: #009900;\">&#125;<\/span>\n<span style=\"color: #009900;\">&#125;<\/span>\n&nbsp;\n<span style=\"color: #993333;\">void<\/span> MAX7219_INIT<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span>\n  <span style=\"color: #666666; font-style: italic;\">\/\/ Disable Shutdown mode<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled LOW<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0x0C<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Select Shutdown register<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0x01<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Set D0 bit to return to normal operation<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled HIGH<\/span>\n&nbsp;\n  <span style=\"color: #666666; font-style: italic;\">\/\/ Set BCD decode mode for digits DIG0-DIG3<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled LOW<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0x09<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Select Decode Mode register<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0xFF<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Select BCD mode for digits DIG0-DIG7<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled HIGH<\/span>\n&nbsp;\n  <span style=\"color: #666666; font-style: italic;\">\/\/ Set display brighness<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled LOW<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0x0A<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Select Intensity register<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0x0C<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Set brightness<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled HIGH<\/span>\n&nbsp;\n   <span style=\"color: #666666; font-style: italic;\">\/\/ Set display refresh<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled LOW<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0x0B<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Select Scan-Limit register<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0x07<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Select digits DIG0-DIG3<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled HIGH<\/span>\n&nbsp;\n <span style=\"color: #666666; font-style: italic;\">\/\/ Enable Display-Test<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled LOW<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0x0F<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Select Display-Test register<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0x01<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Enable Display-Test<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled HIGH<\/span>\n&nbsp;\n  Delay_ms<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000dd;\">1000<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n <span style=\"color: #666666; font-style: italic;\">\/\/ Disable Display-Test<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled LOW<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0x0F<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Select Display-Test register<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #208080;\">0x00<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>    <span style=\"color: #666666; font-style: italic;\">\/\/ Disable Display-Test<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled HIGH<\/span>\n&nbsp;\n<span style=\"color: #009900;\">&#125;<\/span>\n&nbsp;\n <span style=\"color: #993333;\">void<\/span> Display_Counter<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #993333;\">unsigned<\/span> <span style=\"color: #993333;\">int<\/span> j<span style=\"color: #339933;\">,<\/span> <span style=\"color: #993333;\">unsigned<\/span> <span style=\"color: #993333;\">short<\/span> k<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#123;<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>                    <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled LOW<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span>k<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>             <span style=\"color: #666666; font-style: italic;\">\/\/ Send thousands digit<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#40;<\/span>j<span style=\"color: #339933;\">\/<\/span><span style=\"color: #0000dd;\">1000<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">%<\/span><span style=\"color:#800080;\">10<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>                    <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled HIGH<\/span>\n&nbsp;\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>                    <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled LOW<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span>k<span style=\"color: #339933;\">-<\/span><span style=\"color: #0000dd;\">1<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>             <span style=\"color: #666666; font-style: italic;\">\/\/ Send hundreds digit<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#40;<\/span>j<span style=\"color: #339933;\">\/<\/span><span style=\"color: #0000dd;\">100<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">%<\/span><span style=\"color:#800080;\">10<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>                    <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled HIGH<\/span>\n&nbsp;\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>                    <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled LOW<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span>k<span style=\"color: #339933;\">-<\/span><span style=\"color: #0000dd;\">2<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>             <span style=\"color: #666666; font-style: italic;\">\/\/ Send tens digit<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#40;<\/span>j<span style=\"color: #339933;\">\/<\/span><span style=\"color: #0000dd;\">10<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">%<\/span><span style=\"color:#800080;\">10<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>                    <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled HIGH<\/span>\n&nbsp;\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>                    <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled LOW<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span>k<span style=\"color: #339933;\">-<\/span><span style=\"color: #0000dd;\">3<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>             <span style=\"color: #666666; font-style: italic;\">\/\/ Send ones digit<\/span>\n  SPI_Write_Byte<span style=\"color: #009900;\">&#40;<\/span>j<span style=\"color: #339933;\">%<\/span><span style=\"color:#800080;\">10<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n  CS_Pin <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">1<\/span><span style=\"color: #339933;\">;<\/span>                    <span style=\"color: #666666; font-style: italic;\">\/\/ CS pin is pulled HIGH<\/span>\n <span style=\"color: #009900;\">&#125;<\/span>\n&nbsp;\n<span style=\"color: #993333;\">unsigned<\/span> <span style=\"color: #993333;\">short<\/span> i<span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #993333;\">unsigned<\/span> <span style=\"color: #993333;\">int<\/span> counter <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span>\n&nbsp;\n<span style=\"color: #993333;\">void<\/span> main<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span>\n  TRISIO<span style=\"color: #339933;\">=<\/span><span style=\"color: #208080;\">0b00001000<\/span><span style=\"color: #339933;\">;<\/span>        <span style=\"color: #666666; font-style: italic;\">\/\/ GP3 is input only<\/span>\n  CMCON0 <span style=\"color: #339933;\">=<\/span> <span style=\"color: #208080;\">0x07<\/span><span style=\"color: #339933;\">;<\/span>\n  ANSEL <span style=\"color: #339933;\">=<\/span> <span style=\"color: #208080;\">0x00<\/span><span style=\"color: #339933;\">;<\/span>\n  MAX7219_INIT<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>              <span style=\"color: #666666; font-style: italic;\">\/\/ initialize  max7219<\/span>\n  <span style=\"color: #b1b100;\">do<\/span><span style=\"color: #009900;\">&#123;<\/span>\n   <span style=\"color: #b1b100;\">for<\/span> <span style=\"color: #009900;\">&#40;<\/span>counter<span style=\"color: #339933;\">=<\/span><span style=\"color: #0000dd;\">0<\/span><span style=\"color: #339933;\">;<\/span> counter<span style=\"color: #339933;\">&amp;<\/span>lt<span style=\"color: #339933;\">;<\/span><span style=\"color: #0000dd;\">10000<\/span><span style=\"color: #339933;\">;<\/span> counter<span style=\"color: #339933;\">++<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span>\n    Display_Counter<span style=\"color: #009900;\">&#40;<\/span>counter<span style=\"color: #339933;\">,<\/span> <span style=\"color: #0000dd;\">4<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n    Display_Counter<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000dd;\">9999<\/span><span style=\"color: #339933;\">-<\/span>counter<span style=\"color: #339933;\">,<\/span> <span style=\"color: #0000dd;\">8<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n    Delay_ms<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000dd;\">1000<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n   <span style=\"color: #009900;\">&#125;<\/span>\n  <span style=\"color: #009900;\">&#125;<\/span><span style=\"color: #b1b100;\">while<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000dd;\">1<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span>\n<span style=\"color: #009900;\">&#125;<\/span><\/pre><\/td><\/tr><\/table><\/div>\n\n<p><a href=\"http:\/\/embedded-lab.com\/uploads\/HexFiles\/PIC12F\/8Digit_SPI_LEd_Display.zip\">Download mikroC source and HEX files<\/a><\/p>\n<div id=\"attachment_5312\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/CounterOP2.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5312\" class=\"size-full wp-image-5312\" title=\"CounterOP2\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/CounterOP2.jpg\" alt=\"\" width=\"565\" height=\"432\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/CounterOP2.jpg 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/CounterOP2-550x420.jpg 550w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><p id=\"caption-attachment-5312\" class=\"wp-caption-text\">Interfacing with the PIC12F683 microcontroller to make a dual counter<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>The kit consists of:<\/p>\n<div>\n<ul>\n<li>printed circuit board (1)<\/li>\n<li>MAX7219 (1)<\/li>\n<li>0.36? four-digit seven segment LED display (2)<\/li>\n<li>1N4148 diode (1)<\/li>\n<li>18K resistor (1)<\/li>\n<li>100nF capacitor (1)<\/li>\n<li>5-pin male header<\/li>\n<\/ul>\n<\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_5314\" style=\"width: 570px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/CompleteKit.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5314\" class=\"size-full wp-image-5314\" title=\"CompleteKit\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/CompleteKit.jpg\" alt=\"\" width=\"560\" height=\"440\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/CompleteKit.jpg 560w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/05\/CompleteKit-550x432.jpg 550w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/a><p id=\"caption-attachment-5314\" class=\"wp-caption-text\">Complete kit of 8-digit SPI seven segment LED display<\/p><\/div>\n<p>While mounting the parts on PCB, solder low profile components (resistor, capacitor, and diode) first.<\/p>\n<div id=\"attachment_5495\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/SolderComponents.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5495\" class=\"size-full wp-image-5495\" title=\"SolderComponents\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/SolderComponents.jpg\" alt=\"\" width=\"565\" height=\"470\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/SolderComponents.jpg 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/SolderComponents-550x457.jpg 550w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><p id=\"caption-attachment-5495\" class=\"wp-caption-text\">Placement of resistor, capacitor, diode and MAX7219 on board<\/p><\/div>\n<p>The actual circuit of the display is shown below.<\/p>\n<div id=\"attachment_5582\" style=\"width: 544px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/SPIDISP8digit.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5582\" class=\"size-full wp-image-5582\" title=\"SPIDISP8digit\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/SPIDISP8digit.png\" alt=\"\" width=\"534\" height=\"480\" \/><\/a><p id=\"caption-attachment-5582\" class=\"wp-caption-text\">8-digit SPI display circuit<\/p><\/div>\n<p>You can purchase this display module as kit for $<strong>12.00<\/strong>\u00a0on Tindie. Here&#8217;s the buying link: <strong><a href=\"https:\/\/tindie.com\/shops\/rajbex\/spi-8-digit-seven-segment-led-display-kit\/\" target=\"_blank\">SPI7SEGDISP8 on Tindie<\/a>.<\/strong><\/p>\n<p><span style=\"color: #800000;\"><strong>Update (12\/17\/2012):<\/strong><\/span><\/p>\n<p>The new PCBs for this display board has an additional 10uF electrolytic capacitor between VCC and Ground, as shown below. You will receive the new version if you order it now.<\/p>\n<div id=\"attachment_6747\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/SPI7SEGDISP8_Board.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6747\" class=\"size-full wp-image-6747\" title=\"SPI7SEGDISP8_Board\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/SPI7SEGDISP8_Board.jpg\" alt=\"\" width=\"565\" height=\"452\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/SPI7SEGDISP8_Board.jpg 565w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/SPI7SEGDISP8_Board-550x440.jpg 550w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/a><p id=\"caption-attachment-6747\" class=\"wp-caption-text\">Revised version of the 8-digit SPI seven segment display board<\/p><\/div>\n<p>And here&#8217;s the list of items you will receive in a kit.<\/p>\n<div id=\"attachment_6749\" style=\"width: 439px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/LOM_SPIDISP8.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6749\" class=\"size-full wp-image-6749\" title=\"LOM_SPIDISP8\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2012\/06\/LOM_SPIDISP8.png\" alt=\"\" width=\"429\" height=\"201\" \/><\/a><p id=\"caption-attachment-6749\" class=\"wp-caption-text\">List of items in a SPI7SEGDISP8 kit<\/p><\/div>\n<p>But it here:\u00a0\u00a0<strong><a href=\"https:\/\/tindie.com\/shops\/rajbex\/spi-8-digit-seven-segment-led-display-kit\/\" target=\"_blank\">SPI7SEGDISP8 on Tindie<\/a>.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This project is an extension of my previous MAX7219 based SPI seven segment LED display module. The new display features eight 7-segment displays arranged in two rows of four digits. The on-board MAX7219 driver enables you to easily add eight 7-segment LED displays to your project using only 3 I\/O pins of microcontroller. The major advantage of using this board is the time-division multiplexing operations required for continuous refreshing of the display digits are performed by the MAX7219 chip, thereby keeping the microcontroller free for doing other pressing tasks. It is suitable for displaying two variable values simultaneously in a<\/p>\n","protected":false},"author":1,"featured_media":5311,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,437],"tags":[462,461,438],"class_list":["post-5310","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pic-projects","category-products","tag-pic12f-updown-counter","tag-serial-8-digit-led-display","tag-spi-led-display"],"_links":{"self":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/5310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/comments?post=5310"}],"version-history":[{"count":19,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/5310\/revisions"}],"predecessor-version":[{"id":5501,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/5310\/revisions\/5501"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media\/5311"}],"wp:attachment":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media?parent=5310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/categories?post=5310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/tags?post=5310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}