<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[forum.rcl-radio.ru &mdash; max7219 - 7 сегментный индикатор]]></title>
		<link>http://forum.rcl-radio.ru/viewtopic.php?id=295</link>
		<atom:link href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=295&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «max7219 - 7 сегментный индикатор».]]></description>
		<lastBuildDate>Thu, 08 Apr 2021 09:36:04 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: max7219 - 7 сегментный индикатор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=3399#p3399</link>
			<description><![CDATA[<p>тест</p><div class="codebox"><pre><code>#define DIN PD2
#define CS  PD3
#define CLK PD4

void setup() {
  DDRD |= (1 &lt;&lt; DIN) | (1 &lt;&lt; CS) | (1 &lt;&lt; CLK);
  PORTD |= (1 &lt;&lt; CS);
  PORTD &amp;= ~(1 &lt;&lt; CLK) | (1 &lt;&lt; DIN);

  WriteBit16(0x0F,0x00); // Тест выкл.
  WriteBit16(0x0C,0x01); // Вкл. индик.
  WriteBit16(0x0B,0x07); // кол-во разрядов
  WriteBit16(0x09,0xFF); // Дешифраторы вкл.
  WriteBit16(0x0A,0x04); // яркость
}

void loop() {
  dec(12345678);
  }

void dec(long decimal){
  WriteBit16(0x08,decimal/10000000);
  WriteBit16(0x07,decimal/1000000%10);
  WriteBit16(0x06,decimal/100000%10);
  WriteBit16(0x05,decimal/10000%10);
  WriteBit16(0x04,decimal/1000%10);
  WriteBit16(0x03,decimal/100%10);
  WriteBit16(0x02,decimal/10%10);
  WriteBit16(0x01,decimal%10);
  }

void WriteBit16(byte reg, byte data){  
     PORTD &amp;= ~(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; CS);
     for(int i = 7; i &gt;= 0; i--){
        if(((reg &gt;&gt; i) &amp; 1) == 1){PORTD |= (1 &lt;&lt; DIN);}else{PORTD &amp;= ~(1 &lt;&lt; DIN);}
        PORTD |=(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; CLK);
        }
     for(int i = 7; i &gt;= 0; i--){
        if(((data &gt;&gt; i) &amp; 1) == 1){PORTD |= (1 &lt;&lt; DIN);}else{PORTD &amp;= ~(1 &lt;&lt; DIN);}
        PORTD |=(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; CLK);
        }
     PORTD |=(1 &lt;&lt; CS);PORTD &amp;= ~(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; DIN);
  }  </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Thu, 08 Apr 2021 09:36:04 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=3399#p3399</guid>
		</item>
		<item>
			<title><![CDATA[Re: max7219 - 7 сегментный индикатор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=3398#p3398</link>
			<description><![CDATA[<p>Attiny 2313 частотомер 9МГц</p><div class="codebox"><pre><code>#define DIN PD2
#define CS  PD3
#define CLK PD4
#define T1  PD5

volatile int x;
unsigned int timer0;
float f;
float pop_k = 0.996237;

void setup() {
  DDRD |= (1 &lt;&lt; DIN) | (1 &lt;&lt; CS) | (1 &lt;&lt; CLK);
  PORTD |= (1 &lt;&lt; CS);
  PORTD &amp;= ~(1 &lt;&lt; CLK) | (1 &lt;&lt; DIN);
  PORTD |= (1 &lt;&lt; T1);

  WriteBit16(0x0F,0x00); // Тест выкл.
  WriteBit16(0x0C,0x01); // Вкл. индик.
  WriteBit16(0x0B,0x07); // кол-во разрядов
  WriteBit16(0x09,0xFF); // Дешифраторы вкл.
  WriteBit16(0x0A,0x04); // яркость
     cli(); 
// TIMER1    
  TCCR1A = 0;
  TCCR1B = 0;
  TCCR1B = (1 &lt;&lt; CS12)|(1 &lt;&lt; CS11)|(1 &lt;&lt; CS10); 
  TIMSK |= (1 &lt;&lt; TOIE1); 
// TIMER0
  TCCR0A = 0;   
  TCCR0B = 0;   
  OCR0A = 250;
  TCCR0A |= (1 &lt;&lt; WGM01); 
  TCCR0B |= (1 &lt;&lt; CS01);  
  TIMSK |= (1 &lt;&lt; OCIE0A);  
   sei(); 
}

void loop() {}

void dec(long decimal){
  WriteBit16(0x08,15);
  WriteBit16(0x07,decimal/1000000%10+0x80);
  WriteBit16(0x06,decimal/100000%10);
  WriteBit16(0x05,decimal/10000%10);
  WriteBit16(0x04,decimal/1000%10+0x80);
  WriteBit16(0x03,decimal/100%10);
  WriteBit16(0x02,decimal/10%10);
  WriteBit16(0x01,decimal%10);
  }

void WriteBit16(byte reg, byte data){  
     PORTD &amp;= ~(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; CS);
     for(int i = 7; i &gt;= 0; i--){
        if(((reg &gt;&gt; i) &amp; 1) == 1){PORTD |= (1 &lt;&lt; DIN);}else{PORTD &amp;= ~(1 &lt;&lt; DIN);}
        PORTD |=(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; CLK);
        }
     for(int i = 7; i &gt;= 0; i--){
        if(((data &gt;&gt; i) &amp; 1) == 1){PORTD |= (1 &lt;&lt; DIN);}else{PORTD &amp;= ~(1 &lt;&lt; DIN);}
        PORTD |=(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; CLK);
        }
     PORTD |=(1 &lt;&lt; CS);PORTD &amp;= ~(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; DIN);
  }  


ISR(TIMER0_COMPA_vect){
    timer0++;
  if(timer0 == 1){
    x = 0;TCNT1 = 0;
     TCCR1B = (1 &lt;&lt; CS12)|(1 &lt;&lt; CS11)|(1 &lt;&lt; CS10);}
  if(timer0 == 10001){
     TCCR1B &amp;= ~(1 &lt;&lt; CS12)|(1 &lt;&lt; CS11)|(1 &lt;&lt; CS10); 
     f = ((x * 65535) + TCNT1)*pop_k; dec(f); timer0 = 0; }
  }  

ISR (TIMER1_OVF_vect){x++;}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Thu, 08 Apr 2021 09:29:48 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=3398#p3398</guid>
		</item>
		<item>
			<title><![CDATA[max7219 - 7 сегментный индикатор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=3397#p3397</link>
			<description><![CDATA[<div class="codebox"><pre><code>#define DIN PD2
#define CS  PD3
#define CLK PD4

long x;

void setup() {
  DDRD |= (1 &lt;&lt; DIN) | (1 &lt;&lt; CS) | (1 &lt;&lt; CLK);
  PORTD |= (1 &lt;&lt; CS);
  PORTD &amp;= ~(1 &lt;&lt; CLK) | (1 &lt;&lt; DIN);
  delay(1);

  WriteBit16(0x0F,0x00); // Тест выкл.
  WriteBit16(0x0C,0x01); // Вкл. индик.
  WriteBit16(0x0B,0x07); // кол-во разрядов
  WriteBit16(0x09,0xFF); // Дешифраторы вкл.
  WriteBit16(0x0A,0x00); // яркость
}

void loop() {

  dec(x++); 
delay(100);
}

void dec(long decimal){
  WriteBit16(0x08,decimal/10000000);
  WriteBit16(0x07,decimal/1000000%10);
  WriteBit16(0x06,decimal/100000%10);
  WriteBit16(0x05,decimal/10000%10);
  WriteBit16(0x04,decimal/1000%10);
  WriteBit16(0x03,decimal/100%10);
  WriteBit16(0x02,decimal/10%10);
  WriteBit16(0x01,decimal%10);
  }

void WriteBit16(byte reg, byte data){  
     PORTD &amp;= ~(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; CS);
     for(int i = 7; i &gt;= 0; i--){
        if(((reg &gt;&gt; i) &amp; 1) == 1){PORTD |= (1 &lt;&lt; DIN);}else{PORTD &amp;= ~(1 &lt;&lt; DIN);}
        PORTD |=(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; CLK);
        }
     for(int i = 7; i &gt;= 0; i--){
        if(((data &gt;&gt; i) &amp; 1) == 1){PORTD |= (1 &lt;&lt; DIN);}else{PORTD &amp;= ~(1 &lt;&lt; DIN);}
        PORTD |=(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; CLK);
        }
     PORTD |=(1 &lt;&lt; CS);PORTD &amp;= ~(1 &lt;&lt; CLK);PORTD &amp;= ~(1 &lt;&lt; DIN);
  }  </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Thu, 08 Apr 2021 00:13:42 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=3397#p3397</guid>
		</item>
	</channel>
</rss>
