Форум программистов, компьютерный форум, киберфорум
Измерительная техника
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
 
Рейтинг 4.56/117: Рейтинг темы: голосов - 117, средняя оценка - 4.56
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536

Замена микросхемы 1827ВЕ1-0000000 в Г4-164 на AVR -МК

31.08.2019, 07:43. Показов 29981. Ответов 229
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Как заменить 1827ВЕ1-0000000 (аналог 586ВЕ1, система команд в книжке Гамкрелидзе, кажется, отрицательная логика на мультиплексированной шине адреса-данных , нестандартный UART ) в Г4-164 на AVR -МК ATMEGA8A, ATMEGA48, ATMEGA8535, используя , например, маскированные прерывания от одного из портов, битвайсовую эмуляцию пинов (шину ПЗУ можно не использовать ), подпрограммы задержки , используя С++, ассемблерные вставки ? Предусмотреть частоты , а которых переключаются фильтры, увеличение девиации в n раз в коэффициентах АЦП при включении делителей на n, таблицу коэффициентов в ЦАП в децибелах (с учетом , например, того , что 31,7-100 мВ , на 31,6 переключается аттенюатор и включается верх напряжения ЦАП ОН ), обработку прерывания от КОП и другие функции , как по инструкции (https://www.astena.ru/teh_3.html ) ?
Миниатюры
Замена  микросхемы 1827ВЕ1-0000000 в Г4-164 на AVR -МК  
Вложения
Тип файла: zip img012.zip (1.35 Мб, 38 просмотров)
Тип файла: zip g4-164_shems.zip (5.48 Мб, 35 просмотров)
Тип файла: zip g4-164_teh.zip (5.28 Мб, 35 просмотров)
0
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
31.08.2019, 07:43
Ответы с готовыми решениями:

Замена микросборок 2.030.036 ,2.030.034 в Г4-164, Г4-176
Замена микросборок 2.030.036 в Г4-164, 2.030.034 в Г4-176 : на какие транзисторы в современных условиях лучше заменить...

замена микросхемы
Нужно заменить микросхему драйвер двигателя на HDD Smooth 100369972 . На али есть такие схемки но смущает то что цифробуквы на моей схемке...

Замена микросхемы AT49F002NT
Господа! Если кто знает ,какая микросхема может заменить AT49F002NT?

229
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
28.03.2020, 15:15  [ТС]
Студворк — интернет-сервис помощи студентам
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 #include <stdio.h>
#include <stdint.h>
 
/*
int main() {
    uint16_t in = 0x4321;
 
    int t =
            (1000 * ((in & 0xf000) / (16*16*16))) + 
             (100 * ((in & 0xf00) / (16*16))) + 
              (10 * ((in & 0xf0) / 16)) + 
               (1 * ((in & 0xf) / 1));
    std::cout << t << std::endl;
    return 0;
}*/
 
 
uint8_t divmod10( uint32_t inp, uint32_t  div,  uint32_t *reminder )
{
    
*reminder=(uint32_t)  (inp % div) ;
 
return (uint8_t)  (inp/div);    
}
 
 
uint8_t *GetDigitsFromUint32_t( uint32_t in)  //"uint24_t" 
{
 uint8_t digits[5];
    /*
    digits[0]=(uint8_t)(in/100000) ;  in=in%100000;     
    digits[1]=(uint8_t)(in/10000) ;  in=in%10000;  
    digits[2]=(uint8_t)(in/1000) ;  in=in%1000;
    digits[3]=(uint8_t)(in/100) ;  in=in%100;
    digits[4]=(uint8_t)(in/10) ;  in=in%10;
    digits[5]=(uint8_t) (in);
        */    
   digits[0]=(uint8_t) divmod10(  in , 0x000186A0 /*100000*/ ,  &in );
   digits[1]=(uint8_t) divmod10(  in , 0x00002710 /*10000*/,  &in );
   digits[2]=(uint8_t) divmod10(  in , 0x000003e8 /*1000*/,  &in );
   digits[3]=(uint8_t) divmod10(  in , 0x00000064 /*100*/,  &in );
   digits[4]=(uint8_t) divmod10(  in , 0x0000000A /*10*/,  &in ); 
   digits[5]=(uint8_t) divmod10(  in , 0x00000001 /* 1*/ ,  &in );   
     
     
return (uint8_t *) digits;  
}
 
#include <iostream>
 
int main() {
    uint32_t in =  1599999;  // -> 15 9 9 9 9 9
     uint8_t *digits ; 
     digits = GetDigitsFromUint32_t(  in);
   printf("%d%d%d%d%d%d ",(int)digits[0],(int)digits[1], (int) digits[2], (int)digits[3],(int)digits[4],(int)digits[5] );   
    return 0;
}
Добавлено через 1 час 29 минут
Нужно на самом деле использовать деление 32-битных чисел на 32-битную (24- битную) константу (степень 10 , из-за этого медленно , если на зацикливании ), меняемую по программе, с 32- битным остатком (не более) , из которого использовать младший байт и все число для следующего действия , а также перекодирование цифр в число uint32_t :

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 #include <stdio.h>
#include <stdint.h>
uint8_t  div32bit_mod (uint32_t  in, uint32_t  div,    uint32_t *mod    )
{
*mod=(uint32_t)  (in % div) ;
return (uint8_t)  (in /div);
}
 
uint8_t divmod( uint32_t inp, uint32_t  div,  uint32_t *reminder )
{
 return (uint8_t) div32bit_mod( inp,  div, reminder  );
    
}
 
 
uint8_t *GetDigitsFromUint32_t( uint32_t in)  //"uint24_t" 
{
 uint8_t digits[5];
    /*
    digits[0]=(uint8_t)(in/100000) ;  in=in%100000;     
    digits[1]=(uint8_t)(in/10000) ;  in=in%10000;  
    digits[2]=(uint8_t)(in/1000) ;  in=in%1000;
    digits[3]=(uint8_t)(in/100) ;  in=in%100;
    digits[4]=(uint8_t)(in/10) ;  in=in%10;
    digits[5]=(uint8_t) (in);
        */    
   digits[0]=(uint8_t) divmod(  in , 0x000186A0 /*100000*/ ,  &in );
   digits[1]=(uint8_t) divmod(  in , 0x00002710 /*10000*/,  &in );
   digits[2]=(uint8_t) divmod(  in , 0x000003e8 /*1000*/,  &in );
   digits[3]=(uint8_t) divmod(  in , 0x00000064 /*100*/,  &in );
   digits[4]=(uint8_t) divmod(  in , 0x0000000A /*10*/,  &in ); 
   digits[5]=(uint8_t) divmod(  in , 0x00000001 /* 1*/ ,  &in );   
     
     
return (uint8_t *) digits;  
}
 
#include <iostream>
 
int main() {
    uint32_t in =  1599999;  // -> (15) (9) (9) (9) (9) (9)
     uint8_t *digits ; 
     digits = GetDigitsFromUint32_t(  in);
   printf("%d%d%d%d%d%d ",(int)digits[0],(int)digits[1], (int) digits[2], (int)digits[3],(int)digits[4],(int)digits[5] );   
    return 0;
}
Есть ли боле эффективные алгоритмы ?

Добавлено через 24 секунды
Судя по интернету это возможно .
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
28.03.2020, 16:00  [ТС]
Некоторые примеры из интернета ( http://blog.malcom.pl/2017/kon... d-avr.html ) на тему альтернативных алгоритмов преобразований и работы с BCD в аттаче .
Вложения
Тип файла: zip e425312ead749853819fe5ddfe74bad4-b044c27bd011ec70f49265e5efde57221346080d.zip (5.3 Кб, 8 просмотров)
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
29.03.2020, 11:25  [ТС]
Проверка подпрограммы (без акселерации , но на ГНУ-компиляторе )
C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <avr/io.h>
#include <math.h>
 
uint8_t  div32bit_mod (uint32_t  in, uint32_t  div,    uint32_t *mod    )
{
*mod=(uint32_t)  (in % div) ;
return (uint8_t)  (in /div);
}
 
uint8_t divmod( uint32_t inp, uint32_t  div,  uint32_t *reminder )
{
 return (uint8_t) div32bit_mod( inp,  div, reminder  );
    
}
 
 
void  GetDigitsFromUint32_t( uint32_t in )  //"uint24_t" 
{
 uint8_t digits[5];
    /*
    digits[0]=(uint8_t)(in/100000) ;  in=in%100000;     
    digits[1]=(uint8_t)(in/10000) ;  in=in%10000;  
    digits[2]=(uint8_t)(in/1000) ;  in=in%1000;
    digits[3]=(uint8_t)(in/100) ;  in=in%100;
    digits[4]=(uint8_t)(in/10) ;  in=in%10;
    digits[5]=(uint8_t) (in);
        */    
   digits[0]=(uint8_t) divmod(  in , 0x000186A0 /*100000*/ ,  &in );
   digits[1]=(uint8_t) divmod(  in , 0x00002710 /*10000*/,  &in );
   digits[2]=(uint8_t) divmod(  in , 0x000003e8 /*1000*/,  &in );
   digits[3]=(uint8_t) divmod(  in , 0x00000064 /*100*/,  &in );
   digits[4]=(uint8_t) divmod(  in , 0x0000000A /*10*/,  &in ); 
   digits[5]=(uint8_t) divmod(  in , 0x00000001 /* 1*/ ,  &in );   
     
     
     //for example, for output to PORTD 
         PORTD=digits[0];
         PORTD=digits[1];
         PORTD=digits[2];
         PORTD=digits[3];
         PORTD=digits[4];
         PORTD=digits[5];
     
return    ; 
}
int main(void)
{
    /* Replace with your application code */
    while (1) 
    {
     uint32_t in =0; //=  1599999;  // -> 15 9 9 9 9 9  
     //for example, input from port B
     in|=(uint32_t)((uint32_t)PINB<<0);
     in|=(uint32_t)((uint32_t)PINB<<8);
     in|=(uint32_t)((uint32_t)PINB<<16);
     in|=(uint32_t)((uint32_t)PINB<<24);
     
     GetDigitsFromUint32_t(  in);   
 
 
    }
}
Добавлено через 1 минуту
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
GccApplication2.elf:     file format elf32-avr
 
Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         0000013c  00000000  00000000  00000054  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         00000000  00800060  00800060  00000190  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  2 .comment      00000030  00000000  00000000  00000190  2**0
                  CONTENTS, READONLY
  3 .note.gnu.avr.deviceinfo 0000003c  00000000  00000000  000001c0  2**2
                  CONTENTS, READONLY
  4 .debug_aranges 00000038  00000000  00000000  000001fc  2**0
                  CONTENTS, READONLY, DEBUGGING
  5 .debug_info   000008e8  00000000  00000000  00000234  2**0
                  CONTENTS, READONLY, DEBUGGING
  6 .debug_abbrev 0000061b  00000000  00000000  00000b1c  2**0
                  CONTENTS, READONLY, DEBUGGING
  7 .debug_line   00000260  00000000  00000000  00001137  2**0
                  CONTENTS, READONLY, DEBUGGING
  8 .debug_frame  00000080  00000000  00000000  00001398  2**2
                  CONTENTS, READONLY, DEBUGGING
  9 .debug_str    00000342  00000000  00000000  00001418  2**0
                  CONTENTS, READONLY, DEBUGGING
 10 .debug_loc    000005ee  00000000  00000000  0000175a  2**0
                  CONTENTS, READONLY, DEBUGGING
 11 .debug_ranges 00000028  00000000  00000000  00001d48  2**0
                  CONTENTS, READONLY, DEBUGGING
 
Disassembly of section .text:
 
00000000 <__vectors>:
   0:   0c 94 2a 00     jmp 0x54    ; 0x54 <__ctors_end>
   4:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
   8:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
   c:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  10:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  14:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  18:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  1c:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  20:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  24:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  28:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  2c:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  30:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  34:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  38:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  3c:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  40:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  44:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  48:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  4c:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  50:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
 
00000054 <__ctors_end>:
  54:   11 24           eor r1, r1
  56:   1f be           out 0x3f, r1    ; 63
  58:   cf e5           ldi r28, 0x5F   ; 95
  5a:   d4 e0           ldi r29, 0x04   ; 4
  5c:   de bf           out 0x3e, r29   ; 62
  5e:   cd bf           out 0x3d, r28   ; 61
  60:   0e 94 67 00     call    0xce    ; 0xce <main>
  64:   0c 94 9c 00     jmp 0x138   ; 0x138 <_exit>
 
00000068 <__bad_interrupt>:
  68:   0c 94 00 00     jmp 0   ; 0x0 <__vectors>
 
0000006c <GetDigitsFromUint32_t>:
    
}
 
 
void  GetDigitsFromUint32_t( uint32_t in )  //"uint24_t" 
{
  6c:   0f 93           push    r16
  6e:   1f 93           push    r17
  70:   cf 93           push    r28
  72:   df 93           push    r29
#include <avr/io.h>
#include <math.h>
 
uint8_t  div32bit_mod (uint32_t  in, uint32_t  div,    uint32_t *mod    )
{
*mod=(uint32_t)  (in % div) ;
  74:   20 ea           ldi r18, 0xA0   ; 160
  76:   36 e8           ldi r19, 0x86   ; 134
  78:   41 e0           ldi r20, 0x01   ; 1
  7a:   50 e0           ldi r21, 0x00   ; 0
  7c:   0e 94 7a 00     call    0xf4    ; 0xf4 <__udivmodsi4>
  80:   02 2f           mov r16, r18
  82:   20 e1           ldi r18, 0x10   ; 16
  84:   37 e2           ldi r19, 0x27   ; 39
  86:   40 e0           ldi r20, 0x00   ; 0
  88:   50 e0           ldi r21, 0x00   ; 0
  8a:   0e 94 7a 00     call    0xf4    ; 0xf4 <__udivmodsi4>
  8e:   12 2f           mov r17, r18
  90:   28 ee           ldi r18, 0xE8   ; 232
  92:   33 e0           ldi r19, 0x03   ; 3
  94:   40 e0           ldi r20, 0x00   ; 0
  96:   50 e0           ldi r21, 0x00   ; 0
  98:   0e 94 7a 00     call    0xf4    ; 0xf4 <__udivmodsi4>
  9c:   d2 2f           mov r29, r18
  9e:   24 e6           ldi r18, 0x64   ; 100
  a0:   30 e0           ldi r19, 0x00   ; 0
  a2:   40 e0           ldi r20, 0x00   ; 0
  a4:   50 e0           ldi r21, 0x00   ; 0
  a6:   0e 94 7a 00     call    0xf4    ; 0xf4 <__udivmodsi4>
  aa:   c2 2f           mov r28, r18
return (uint8_t)  (in /div);
  ac:   2a e0           ldi r18, 0x0A   ; 10
  ae:   30 e0           ldi r19, 0x00   ; 0
  b0:   40 e0           ldi r20, 0x00   ; 0
  b2:   50 e0           ldi r21, 0x00   ; 0
  b4:   0e 94 7a 00     call    0xf4    ; 0xf4 <__udivmodsi4>
   digits[4]=(uint8_t) divmod(  in , 0x0000000A /*10*/,  &in ); 
   digits[5]=(uint8_t) divmod(  in , 0x00000001 /* 1*/ ,  &in );   
     
     
     //for example, for output to PORTD 
         PORTD=digits[0];
  b8:   02 bb           out 0x12, r16   ; 18
         PORTD=digits[1];
  ba:   12 bb           out 0x12, r17   ; 18
         PORTD=digits[2];
  bc:   d2 bb           out 0x12, r29   ; 18
         PORTD=digits[3];
  be:   c2 bb           out 0x12, r28   ; 18
         PORTD=digits[4];
  c0:   22 bb           out 0x12, r18   ; 18
         PORTD=digits[5];
  c2:   62 bb           out 0x12, r22   ; 18
     
return    ; 
}
  c4:   df 91           pop r29
  c6:   cf 91           pop r28
  c8:   1f 91           pop r17
  ca:   0f 91           pop r16
  cc:   08 95           ret
 
000000ce <main>:
    /* Replace with your application code */
    while (1) 
    {
     uint32_t in =0; //=  1599999;  // -> 15 9 9 9 9 9  
     //for example, input from port B
     in|=(uint32_t)((uint32_t)PINB<<0);
  ce:   26 b3           in  r18, 0x16   ; 22
     in|=(uint32_t)((uint32_t)PINB<<8);
  d0:   36 b3           in  r19, 0x16   ; 22
     in|=(uint32_t)((uint32_t)PINB<<16);
  d2:   66 b3           in  r22, 0x16   ; 22
  d4:   86 2f           mov r24, r22
  d6:   90 e0           ldi r25, 0x00   ; 0
  d8:   a0 e0           ldi r26, 0x00   ; 0
  da:   b0 e0           ldi r27, 0x00   ; 0
  dc:   dc 01           movw    r26, r24
  de:   99 27           eor r25, r25
  e0:   88 27           eor r24, r24
  e2:   93 2b           or  r25, r19
  e4:   82 2b           or  r24, r18
     in|=(uint32_t)((uint32_t)PINB<<24);
  e6:   26 b3           in  r18, 0x16   ; 22
     
     GetDigitsFromUint32_t(  in);   
  e8:   bc 01           movw    r22, r24
  ea:   cd 01           movw    r24, r26
  ec:   92 2b           or  r25, r18
  ee:   0e 94 36 00     call    0x6c    ; 0x6c <GetDigitsFromUint32_t>
  f2:   ed cf           rjmp    .-38        ; 0xce <main>
 
000000f4 <__udivmodsi4>:
  f4:   a1 e2           ldi r26, 0x21   ; 33
  f6:   1a 2e           mov r1, r26
  f8:   aa 1b           sub r26, r26
  fa:   bb 1b           sub r27, r27
  fc:   fd 01           movw    r30, r26
  fe:   0d c0           rjmp    .+26        ; 0x11a <__udivmodsi4_ep>
 
00000100 <__udivmodsi4_loop>:
 100:   aa 1f           adc r26, r26
 102:   bb 1f           adc r27, r27
 104:   ee 1f           adc r30, r30
 106:   ff 1f           adc r31, r31
 108:   a2 17           cp  r26, r18
 10a:   b3 07           cpc r27, r19
 10c:   e4 07           cpc r30, r20
 10e:   f5 07           cpc r31, r21
 110:   20 f0           brcs    .+8         ; 0x11a <__udivmodsi4_ep>
 112:   a2 1b           sub r26, r18
 114:   b3 0b           sbc r27, r19
 116:   e4 0b           sbc r30, r20
 118:   f5 0b           sbc r31, r21
 
0000011a <__udivmodsi4_ep>:
 11a:   66 1f           adc r22, r22
 11c:   77 1f           adc r23, r23
 11e:   88 1f           adc r24, r24
 120:   99 1f           adc r25, r25
 122:   1a 94           dec r1
 124:   69 f7           brne    .-38        ; 0x100 <__udivmodsi4_loop>
 126:   60 95           com r22
 128:   70 95           com r23
 12a:   80 95           com r24
 12c:   90 95           com r25
 12e:   9b 01           movw    r18, r22
 130:   ac 01           movw    r20, r24
 132:   bd 01           movw    r22, r26
 134:   cf 01           movw    r24, r30
 136:   08 95           ret
 
00000138 <_exit>:
 138:   f8 94           cli
 
0000013a <__stop_program>:
 13a:   ff cf           rjmp    .-2         ; 0x13a <__stop_program>
Добавлено через 13 минут
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * GccApplication2.c
 *
 * Created: 29.03.2020 10:38:02
 * Author : USERPC01
 */ 
 
#include <avr/io.h>
#include <math.h>
 
uint8_t  div32bit_mod (uint32_t  in, uint32_t  div,    uint32_t *mod    )
{
uint32_t res;
    res=(uint32_t)in /div;
    
*mod=(uint32_t)  (in - (res*div)) ;
 
return (uint8_t)  res;
}
 
uint8_t divmod( uint32_t inp, uint32_t  div,  uint32_t *reminder )
{
 return (uint8_t) div32bit_mod( inp,  div, reminder  );
    
}
 
 
void  GetDigitsFromUint32_t( uint32_t in )  //"uint24_t" 
{
 uint8_t digits[5];
    /*
    digits[0]=(uint8_t)(in/100000) ;  in=in%100000;     
    digits[1]=(uint8_t)(in/10000) ;  in=in%10000;  
    digits[2]=(uint8_t)(in/1000) ;  in=in%1000;
    digits[3]=(uint8_t)(in/100) ;  in=in%100;
    digits[4]=(uint8_t)(in/10) ;  in=in%10;
    digits[5]=(uint8_t) (in);
        */    
   digits[0]=(uint8_t) divmod(  in , 0x000186A0 /*100000*/ ,  &in );
   digits[1]=(uint8_t) divmod(  in , 0x00002710 /*10000*/,  &in );
   digits[2]=(uint8_t) divmod(  in , 0x000003e8 /*1000*/,  &in );
   digits[3]=(uint8_t) divmod(  in , 0x00000064 /*100*/,  &in );
   digits[4]=(uint8_t) divmod(  in , 0x0000000A /*10*/,  &in ); 
   digits[5]=(uint8_t) divmod(  in , 0x00000001 /* 1*/ ,  &in );   
     
     
     //for example, for output to PORTD 
         PORTD=digits[0];
         PORTD=digits[1];
         PORTD=digits[2];
         PORTD=digits[3];
         PORTD=digits[4];
         PORTD=digits[5];
     
return    ; 
}
int main(void)
{
    /* Replace with your application code */
    while (1) 
    {
     uint32_t in =0; //=  1599999;  // -> 15 9 9 9 9 9  
     //for example, input from port B
     in|=(uint32_t)((uint32_t)PINB<<0);
     in|=(uint32_t)((uint32_t)PINB<<8);
     in|=(uint32_t)((uint32_t)PINB<<16);
     in|=(uint32_t)((uint32_t)PINB<<24);
     
     GetDigitsFromUint32_t(  in);   
 
 
    }
}

Code
1
2
3
4
5
6
d=10;
data=102
res= data div d =10
rem=data mod d =2
res *d=100
rem=data-res*d


Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
GccApplication2.elf:     file format elf32-avr
 
Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         0000022c  00000000  00000000  00000054  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         00000000  00800060  00800060  00000280  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  2 .comment      00000030  00000000  00000000  00000280  2**0
                  CONTENTS, READONLY
  3 .note.gnu.avr.deviceinfo 0000003c  00000000  00000000  000002b0  2**2
                  CONTENTS, READONLY
  4 .debug_aranges 00000038  00000000  00000000  000002ec  2**0
                  CONTENTS, READONLY, DEBUGGING
  5 .debug_info   000009cb  00000000  00000000  00000324  2**0
                  CONTENTS, READONLY, DEBUGGING
  6 .debug_abbrev 0000063f  00000000  00000000  00000cef  2**0
                  CONTENTS, READONLY, DEBUGGING
  7 .debug_line   0000029c  00000000  00000000  0000132e  2**0
                  CONTENTS, READONLY, DEBUGGING
  8 .debug_frame  000000e4  00000000  00000000  000015cc  2**2
                  CONTENTS, READONLY, DEBUGGING
  9 .debug_str    00000342  00000000  00000000  000016b0  2**0
                  CONTENTS, READONLY, DEBUGGING
 10 .debug_loc    000006e5  00000000  00000000  000019f2  2**0
                  CONTENTS, READONLY, DEBUGGING
 11 .debug_ranges 00000028  00000000  00000000  000020d7  2**0
                  CONTENTS, READONLY, DEBUGGING
 
Disassembly of section .text:
 
00000000 <__vectors>:
   0:   0c 94 2a 00     jmp 0x54    ; 0x54 <__ctors_end>
   4:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
   8:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
   c:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  10:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  14:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  18:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  1c:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  20:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  24:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  28:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  2c:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  30:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  34:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  38:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  3c:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  40:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  44:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  48:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  4c:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
  50:   0c 94 34 00     jmp 0x68    ; 0x68 <__bad_interrupt>
 
00000054 <__ctors_end>:
  54:   11 24           eor r1, r1
  56:   1f be           out 0x3f, r1    ; 63
  58:   cf e5           ldi r28, 0x5F   ; 95
  5a:   d4 e0           ldi r29, 0x04   ; 4
  5c:   de bf           out 0x3e, r29   ; 62
  5e:   cd bf           out 0x3d, r28   ; 61
  60:   0e 94 b5 00     call    0x16a   ; 0x16a <main>
  64:   0c 94 14 01     jmp 0x228   ; 0x228 <_exit>
 
00000068 <__bad_interrupt>:
  68:   0c 94 00 00     jmp 0   ; 0x0 <__vectors>
 
0000006c <GetDigitsFromUint32_t>:
    
}
 
 
void  GetDigitsFromUint32_t( uint32_t in )  //"uint24_t" 
{
  6c:   cf 92           push    r12
  6e:   df 92           push    r13
  70:   ef 92           push    r14
  72:   ff 92           push    r15
  74:   0f 93           push    r16
  76:   1f 93           push    r17
  78:   cf 93           push    r28
  7a:   df 93           push    r29
  7c:   6b 01           movw    r12, r22
  7e:   7c 01           movw    r14, r24
#include <math.h>
 
uint8_t  div32bit_mod (uint32_t  in, uint32_t  div,    uint32_t *mod    )
{
uint32_t res;
    res=(uint32_t)in /div;
  80:   20 ea           ldi r18, 0xA0   ; 160
  82:   36 e8           ldi r19, 0x86   ; 134
  84:   41 e0           ldi r20, 0x01   ; 1
  86:   50 e0           ldi r21, 0x00   ; 0
  88:   0e 94 d8 00     call    0x1b0   ; 0x1b0 <__udivmodsi4>
  8c:   d2 2f           mov r29, r18
    
*mod=(uint32_t)  (in - (res*div)) ;
  8e:   60 ea           ldi r22, 0xA0   ; 160
  90:   76 e8           ldi r23, 0x86   ; 134
  92:   81 e0           ldi r24, 0x01   ; 1
  94:   90 e0           ldi r25, 0x00   ; 0
  96:   0e 94 c8 00     call    0x190   ; 0x190 <__mulsi3>
  9a:   c6 1a           sub r12, r22
  9c:   d7 0a           sbc r13, r23
  9e:   e8 0a           sbc r14, r24
  a0:   f9 0a           sbc r15, r25
#include <math.h>
 
uint8_t  div32bit_mod (uint32_t  in, uint32_t  div,    uint32_t *mod    )
{
uint32_t res;
    res=(uint32_t)in /div;
  a2:   c7 01           movw    r24, r14
  a4:   b6 01           movw    r22, r12
  a6:   20 e1           ldi r18, 0x10   ; 16
  a8:   37 e2           ldi r19, 0x27   ; 39
  aa:   40 e0           ldi r20, 0x00   ; 0
  ac:   50 e0           ldi r21, 0x00   ; 0
  ae:   0e 94 d8 00     call    0x1b0   ; 0x1b0 <__udivmodsi4>
  b2:   c2 2f           mov r28, r18
    
*mod=(uint32_t)  (in - (res*div)) ;
  b4:   a0 e1           ldi r26, 0x10   ; 16
  b6:   b7 e2           ldi r27, 0x27   ; 39
  b8:   0e 94 fa 00     call    0x1f4   ; 0x1f4 <__muluhisi3>
  bc:   c6 1a           sub r12, r22
  be:   d7 0a           sbc r13, r23
  c0:   e8 0a           sbc r14, r24
  c2:   f9 0a           sbc r15, r25
#include <math.h>
 
uint8_t  div32bit_mod (uint32_t  in, uint32_t  div,    uint32_t *mod    )
{
uint32_t res;
    res=(uint32_t)in /div;
  c4:   c7 01           movw    r24, r14
  c6:   b6 01           movw    r22, r12
  c8:   28 ee           ldi r18, 0xE8   ; 232
  ca:   33 e0           ldi r19, 0x03   ; 3
  cc:   40 e0           ldi r20, 0x00   ; 0
  ce:   50 e0           ldi r21, 0x00   ; 0
  d0:   0e 94 d8 00     call    0x1b0   ; 0x1b0 <__udivmodsi4>
  d4:   12 2f           mov r17, r18
    
*mod=(uint32_t)  (in - (res*div)) ;
  d6:   a8 ee           ldi r26, 0xE8   ; 232
  d8:   b3 e0           ldi r27, 0x03   ; 3
  da:   0e 94 fa 00     call    0x1f4   ; 0x1f4 <__muluhisi3>
  de:   c6 1a           sub r12, r22
  e0:   d7 0a           sbc r13, r23
  e2:   e8 0a           sbc r14, r24
  e4:   f9 0a           sbc r15, r25
#include <math.h>
 
uint8_t  div32bit_mod (uint32_t  in, uint32_t  div,    uint32_t *mod    )
{
uint32_t res;
    res=(uint32_t)in /div;
  e6:   c7 01           movw    r24, r14
  e8:   b6 01           movw    r22, r12
  ea:   24 e6           ldi r18, 0x64   ; 100
  ec:   30 e0           ldi r19, 0x00   ; 0
  ee:   40 e0           ldi r20, 0x00   ; 0
  f0:   50 e0           ldi r21, 0x00   ; 0
  f2:   0e 94 d8 00     call    0x1b0   ; 0x1b0 <__udivmodsi4>
  f6:   02 2f           mov r16, r18
    
*mod=(uint32_t)  (in - (res*div)) ;
  f8:   a4 e6           ldi r26, 0x64   ; 100
  fa:   b0 e0           ldi r27, 0x00   ; 0
  fc:   0e 94 fa 00     call    0x1f4   ; 0x1f4 <__muluhisi3>
 100:   c6 1a           sub r12, r22
 102:   d7 0a           sbc r13, r23
 104:   e8 0a           sbc r14, r24
 106:   f9 0a           sbc r15, r25
#include <math.h>
 
uint8_t  div32bit_mod (uint32_t  in, uint32_t  div,    uint32_t *mod    )
{
uint32_t res;
    res=(uint32_t)in /div;
 108:   c7 01           movw    r24, r14
 10a:   b6 01           movw    r22, r12
 10c:   2a e0           ldi r18, 0x0A   ; 10
 10e:   30 e0           ldi r19, 0x00   ; 0
 110:   40 e0           ldi r20, 0x00   ; 0
 112:   50 e0           ldi r21, 0x00   ; 0
 114:   0e 94 d8 00     call    0x1b0   ; 0x1b0 <__udivmodsi4>
    
*mod=(uint32_t)  (in - (res*div)) ;
 
return (uint8_t)  res;
 118:   82 2f           mov r24, r18
 11a:   93 2f           mov r25, r19
 11c:   a4 2f           mov r26, r20
 11e:   b5 2f           mov r27, r21
 120:   88 0f           add r24, r24
 122:   99 1f           adc r25, r25
 124:   aa 1f           adc r26, r26
 126:   bb 1f           adc r27, r27
 128:   ac 01           movw    r20, r24
 12a:   bd 01           movw    r22, r26
 12c:   44 0f           add r20, r20
 12e:   55 1f           adc r21, r21
 130:   66 1f           adc r22, r22
 132:   77 1f           adc r23, r23
 134:   44 0f           add r20, r20
 136:   55 1f           adc r21, r21
 138:   66 1f           adc r22, r22
 13a:   77 1f           adc r23, r23
 13c:   84 0f           add r24, r20
 13e:   95 1f           adc r25, r21
 140:   a6 1f           adc r26, r22
 142:   b7 1f           adc r27, r23
 144:   c8 1a           sub r12, r24
 146:   d9 0a           sbc r13, r25
 148:   ea 0a           sbc r14, r26
 14a:   fb 0a           sbc r15, r27
   digits[4]=(uint8_t) divmod(  in , 0x0000000A /*10*/,  &in ); 
   digits[5]=(uint8_t) divmod(  in , 0x00000001 /* 1*/ ,  &in );   
     
     
     //for example, for output to PORTD 
         PORTD=digits[0];
 14c:   d2 bb           out 0x12, r29   ; 18
         PORTD=digits[1];
 14e:   c2 bb           out 0x12, r28   ; 18
         PORTD=digits[2];
 150:   12 bb           out 0x12, r17   ; 18
         PORTD=digits[3];
 152:   02 bb           out 0x12, r16   ; 18
         PORTD=digits[4];
 154:   22 bb           out 0x12, r18   ; 18
         PORTD=digits[5];
 156:   c2 ba           out 0x12, r12   ; 18
     
return    ; 
}
 158:   df 91           pop r29
 15a:   cf 91           pop r28
 15c:   1f 91           pop r17
 15e:   0f 91           pop r16
 160:   ff 90           pop r15
 162:   ef 90           pop r14
 164:   df 90           pop r13
 166:   cf 90           pop r12
 168:   08 95           ret
 
0000016a <main>:
    /* Replace with your application code */
    while (1) 
    {
     uint32_t in =0; //=  1599999;  // -> 15 9 9 9 9 9  
     //for example, input from port B
     in|=(uint32_t)((uint32_t)PINB<<0);
 16a:   26 b3           in  r18, 0x16   ; 22
     in|=(uint32_t)((uint32_t)PINB<<8);
 16c:   36 b3           in  r19, 0x16   ; 22
     in|=(uint32_t)((uint32_t)PINB<<16);
 16e:   66 b3           in  r22, 0x16   ; 22
 170:   86 2f           mov r24, r22
 172:   90 e0           ldi r25, 0x00   ; 0
 174:   a0 e0           ldi r26, 0x00   ; 0
 176:   b0 e0           ldi r27, 0x00   ; 0
 178:   dc 01           movw    r26, r24
 17a:   99 27           eor r25, r25
 17c:   88 27           eor r24, r24
 17e:   93 2b           or  r25, r19
 180:   82 2b           or  r24, r18
     in|=(uint32_t)((uint32_t)PINB<<24);
 182:   26 b3           in  r18, 0x16   ; 22
     
     GetDigitsFromUint32_t(  in);   
 184:   bc 01           movw    r22, r24
 186:   cd 01           movw    r24, r26
 188:   92 2b           or  r25, r18
 18a:   0e 94 36 00     call    0x6c    ; 0x6c <GetDigitsFromUint32_t>
 18e:   ed cf           rjmp    .-38        ; 0x16a <main>
 
00000190 <__mulsi3>:
 190:   db 01           movw    r26, r22
 192:   8f 93           push    r24
 194:   9f 93           push    r25
 196:   0e 94 fa 00     call    0x1f4   ; 0x1f4 <__muluhisi3>
 19a:   bf 91           pop r27
 19c:   af 91           pop r26
 19e:   a2 9f           mul r26, r18
 1a0:   80 0d           add r24, r0
 1a2:   91 1d           adc r25, r1
 1a4:   a3 9f           mul r26, r19
 1a6:   90 0d           add r25, r0
 1a8:   b2 9f           mul r27, r18
 1aa:   90 0d           add r25, r0
 1ac:   11 24           eor r1, r1
 1ae:   08 95           ret
 
000001b0 <__udivmodsi4>:
 1b0:   a1 e2           ldi r26, 0x21   ; 33
 1b2:   1a 2e           mov r1, r26
 1b4:   aa 1b           sub r26, r26
 1b6:   bb 1b           sub r27, r27
 1b8:   fd 01           movw    r30, r26
 1ba:   0d c0           rjmp    .+26        ; 0x1d6 <__udivmodsi4_ep>
 
000001bc <__udivmodsi4_loop>:
 1bc:   aa 1f           adc r26, r26
 1be:   bb 1f           adc r27, r27
 1c0:   ee 1f           adc r30, r30
 1c2:   ff 1f           adc r31, r31
 1c4:   a2 17           cp  r26, r18
 1c6:   b3 07           cpc r27, r19
 1c8:   e4 07           cpc r30, r20
 1ca:   f5 07           cpc r31, r21
 1cc:   20 f0           brcs    .+8         ; 0x1d6 <__udivmodsi4_ep>
 1ce:   a2 1b           sub r26, r18
 1d0:   b3 0b           sbc r27, r19
 1d2:   e4 0b           sbc r30, r20
 1d4:   f5 0b           sbc r31, r21
 
000001d6 <__udivmodsi4_ep>:
 1d6:   66 1f           adc r22, r22
 1d8:   77 1f           adc r23, r23
 1da:   88 1f           adc r24, r24
 1dc:   99 1f           adc r25, r25
 1de:   1a 94           dec r1
 1e0:   69 f7           brne    .-38        ; 0x1bc <__udivmodsi4_loop>
 1e2:   60 95           com r22
 1e4:   70 95           com r23
 1e6:   80 95           com r24
 1e8:   90 95           com r25
 1ea:   9b 01           movw    r18, r22
 1ec:   ac 01           movw    r20, r24
 1ee:   bd 01           movw    r22, r26
 1f0:   cf 01           movw    r24, r30
 1f2:   08 95           ret
 
000001f4 <__muluhisi3>:
 1f4:   0e 94 05 01     call    0x20a   ; 0x20a <__umulhisi3>
 1f8:   a5 9f           mul r26, r21
 1fa:   90 0d           add r25, r0
 1fc:   b4 9f           mul r27, r20
 1fe:   90 0d           add r25, r0
 200:   a4 9f           mul r26, r20
 202:   80 0d           add r24, r0
 204:   91 1d           adc r25, r1
 206:   11 24           eor r1, r1
 208:   08 95           ret
 
0000020a <__umulhisi3>:
 20a:   a2 9f           mul r26, r18
 20c:   b0 01           movw    r22, r0
 20e:   b3 9f           mul r27, r19
 210:   c0 01           movw    r24, r0
 212:   a3 9f           mul r26, r19
 214:   70 0d           add r23, r0
 216:   81 1d           adc r24, r1
 218:   11 24           eor r1, r1
 21a:   91 1d           adc r25, r1
 21c:   b2 9f           mul r27, r18
 21e:   70 0d           add r23, r0
 220:   81 1d           adc r24, r1
 222:   11 24           eor r1, r1
 224:   91 1d           adc r25, r1
 226:   08 95           ret
 
00000228 <_exit>:
 228:   f8 94           cli
 
0000022a <__stop_program>:
 22a:   ff cf           rjmp    .-2         ; 0x22a <__stop_program>
Добавлено через 49 секунд
А так код медленнее , но подпрограммы выделеннее

Добавлено через 12 минут
После выполнения в дебаггере одного действия декодирования для ATMEGA16A
Code
1
2
3
cycle counter  не менее 3236 
Frequency 12,000 MHz
StopWatch 269,67 us
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
29.03.2020, 19:16  [ТС]
piniosubs.h

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#define   PIN37_DDR DDRC     ;
#define PIN37_PORT  PORTC  ; use invertor after this pin
#define OUT_PIN37 PORTC0;
#define PIN39_DDR DDRC  ;
#define PIN39_PORT DDRC;
#define OUT_PIN39 PORTC1  ;use invertor after this pin
#define PIN36_DDR DDRC;
#define PIN36_PORT PORTC;
#define OUT_PIN36 PORTC2;
 
#define PORT_PIN34  PORTC;
#define PORTIN_PIN34  PINC;
#define PIN34_DDR DDRC;
#define OUT_PIN34 PORTC3;
#define IN_PIN34 PINC3;
 
 
 
 
#define ADDR_IN_LD_SYNC_POOL    0x00;
#define ADDR_IN_GCD_SYNC   0x01;
#define ADDR_INFORM_WAIT  0x02;
 
 
 
#define cbi ( PORT , BIT  )   ( (PORT)&=~(1<<(BIT)))  
#define sbi ( PORT , BIT  )   ( (PORT)|=(1<<(BIT)))  
#define out (PORTOUT, BYTE) ((PORTOUT)=(BYTE))
#define in (BYTE, PORTIN) ((BYTE)=(PORTIN))
 
 
 
 
 
 void SetPin23High()
{ 
; turn on 6dB 
 cbi (PIN23_PORT, PIN23_OUT) ;
 }
 
void SetPin23Low()
{ 
; turn off 6dB 
sbi (PIN23_PORT, PIN23_OUT) ;
}
 
 
void SetPin37Low(){     
cbi (PIN37_PORT, OUT_PIN37) ;        
}
 
void SetPin37High(){     
sbi  (PIN36_PORT, OUT_PIN36) ;    
}
  
 
void SetPin36Low(){
cbi (PIN36_PORT, OUT_PIN36) ;
}
 
void  SetPin36High(){     
sbi (PIN36_PORT, OUT_PIN36) ;    
}
 
 
void   SetPin39Low(){
cbi (PIN39_PORT, OUT_PIN39) ;
}
 
void  SetPin39High(){ 
sbi (PIN39_PORT, OUT_PIN39) ;
}
 
 
void  SetPin34Out(){ 
sbi (PIN34_DDR, OUT_PIN34) ;
}
 
void  SetPin34Input(){ 
cbi (PIN34_DDR,OUT_PIN34) ;
}
 
void  SetPin34High(){ 
sbi (PORT_PIN34,OUT_PIN34) ;
}
    
void  SetPin34Low(){ 
cbi (PORT_PIN34, OUT_PIN34) ;
}
 
 
 
 
 
 
void  InitPins(){ 
 
out (DDR_ADDR, 0x0f);    
 
 
sbi (PIN23_DDR, PIN23_OUT)  ;
sbi (PIN23_DDR, OUT_PIN37) ;
sbi (PIN36_DDR, OUT_PIN36)  ;
sbi (PIN39_DDR, OUT_PIN39) ;
cbi (PIN34_DDR, OUT_PIN34) ;
return;
} 
 
 
 
 
 
 
 
 
void Set6dBOn()
{
if (data==0) { SetPin23Low () ; } else  { SetPin23High();  } 
return;
 }
 
void  CheckPin34In()
{ 
SetPin34Input();
 if ((PORTIN_PIN34&(1<<IN_PIN34))==0) { return 0; } else {return 1;}
}
 
 
 
void  SetAddr( uint8_t  data )
{
 ; data=addr
PORT_ADDR= (data&0x0f)  ;
}
 
void  SetAddrInform()
{
 PORT_ADDR=ADDRESS_INFORM;
}
 
void  SetAddrInformInGCd() 
{
PORT_ADDR=ADDR_IN_GCD  ;
}
 
 
void  SetAddrInformInLD()
{
PORT_ADDR=ADDR_IN_LD;
}
Добавлено через 1 минуту
siosubs.h

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
#include "piniosubs.h"
/*
#define  ADDR_IN_LD_SYNC      
#define  ADDR_IN_GCD_SYNC   
 
#define  ADDR_SYNC_POOL 0x00
#define   ADR_SYNC  0x01
*/
#define  ADDR_INFORM_WAIT 0x02
 
 
#define  ADDR_AM_VREF    0x04
#define  ADDR_FM                0x03
#define ADDR_BLINKOFF    0x05
#define  ADDR_HFO              0x06  
#define  ADDR_SYNCSTATIC      0x07
 
#define  ADDR_SYNCBLINK  0x08
 
#define  ADDR_MODE            0x0a
 
#define  ADDR_DPKD   0x0c
#define  ADDR_LFO     0x0d
#define  ADDR_ATT      0x0e
#define  ADDR_SYNCRAM  0x0f
 
//#defineADDR_SYNCRAM  15
 
 void SetPinsDefault1(){
 
SetPin37Low() ; //    not active  , for 1 on the    on the trigger,  use invertor  and D12
SetPin39Low() ; //    not active  , for 1 on the    on the MemWr RAM, use invertor
SetPin36Low() ;   //   not active  , for 0 on the    on the multiplexer , use invertor and D12
return;
}
 
 void SendPin36Pulse(){ 
 
 _delay_us(1);
SetPin36High();  // send pulse 
_delay_us(20);
SetPin36Low;    //not active  
_delay_us(50);
}
 
 
 void SendPin37Pulse(){
_delay_us(1);
 SetPin37High(); //  send pulse 
_delay_us(20);
SetPin37Low() ;    //not active   
_delay_us(50) ;
}
 
 
 
 void SendPin39Pulse(){
 
_delay_us(1);
SetPin39High() ;  //send pulse 
_delay_us(20) ;
SetPin39Low() ;    //not active  , for 1 on the    on the trigger,  use invertor  and D12
_delay_us(50) ;
}
 
 
uint8_t  GetBitInformLD()
{  
 SetPinsDefault1() ;
//SetPin34Input ;  
 
SetAddrInformInLD() ;
SetPin34Input() ; 
uint8_t tmp = 0x00;
if ((PORTIN_PIN34&(1<< IN_PIN34))!=0 ) {tmp=0x01; }
return tmp; 
}
 
 
 void  SendStrobeSync(uint8_t addr){   
 SetPinsDefault1() ;
 SetPin34Out() ; 
 SetAddrSync(addr) ;  
 SendPin36Pulse ;
}
 
 
 
 
uint8_t GetBitInformGCd()
{
 
 SetPin34Input() ; 
 SetPinsDefault1() ;
 SetAddrInformInGCd() ;
 SetPin34Input() ; 
 
 SendStrobeSync (ADDR_SYNC) ;
 SetPin34Input() ;
uint8_t tmp =0x00;
if((PORTIN_PIN34&(1<<IN_PIN34))!=0) { tmp=0x01; } 
return tmp;
}
 
 
 
void SendPin34LowIfDataIsZero(uint8_t data )
{
 if (data!=0x00)  { SetPin34High();  } else { SetPin34Low();  }
return;
}
 
 
 
void SendBitInform(uint8_t data)  
 {
 SetPinsDefault1();
 SetAddrInform() ;
 SetPin34Out() ;
 SendPin34LowIfDataIsZero(data);
}
 
void SendMemWrPulse()
{ 
 SetPinsDefault1() ;
 SendPin37Pulse() ;
}
 
void SendMemWrRAMPulse(){
 SetPinsDefault1() ;
 SendPin39Pulse() ;
}
 
 
void SendPin36Pulse1()
{
_delay_us(1);
SetPin36High(); //send pulse 
_delay_us(50); // fix
SetPin36Low();   not active  
_delay_us(40);  //fix 
}
 
void SendPin36Pulse2()
{
_delay_us(1);
SetPin36High(); // send pulse 
_dela_us(40);  //fix
SetPin36Low(); // not active  
_delay_40us(40);   //fix 
}
 
void SendPulseSyncInLD()
{
SetPinsDefault1() ;
SetPin34In() ; 
SetAddrSync(ADR_SYNC) ;   
SendPin36Pulse1() ; 
}
 
 
void SendPulseSyncInGCD() 
{ 
SetPinsDefault1() ;
SetPin34In() ; 
SetAddrSync(ADDR_SYNC_POOL) ; 
SendPin36Pulse2() ; 
}
 
 
uint8_t CheckFirstBit(uint8_t byte)  
{
if((byte&0x01)==0)  { return 0x00; } else  { return 0x01; } 
}
 
void Send_nInformBit_0_IfByteFalse(uint8_t byte)  
{
if ( byte ==0) { SendBitInform(0);  }  else { SendBitInform(1); }  
}
 
void Send_nInformBit_1_IfByteFalse(uint8_t byte)  
{
 if ( byte ==0) { SendBitInform(1);  }  else { SendBitInform(0); }  
}
 
 
 
void Send_nInformBit_0_IfFirtstBitTrue(uint8_t byte)  
{
if ( (byte&0x01)==0) { SendBitInform(1);  }  else { SendBitInform(0); }
} 
 
 
void Send_nInformBit_1_IfFirtstBitTrue(uint8_t byte)  
{ 
 if ((byte&0x01)==0) { SendBitInform(0);  }  else { SendBitInform(1); }  
 }
 
 
void Sendnbits_nInform_0If_nthBit_is1( uint 8_t byte, uint 8_t Addr, uint8_t num ) 
uint8_t count =0;  
LabelNextByte:
SetPinsDefault1();
SetAddrInform() ;
SetPin34Out();
if((byte&0x01)==0) { SetPin34High() ;  } else  {  SetPin34Low();}
SendStrobeSync(Addr); 
count++;
if (count<num) {  byte=(byte>>1);  goto LabelNextByte ;}
return;
}
 
void Sendnbits_nInform_1If_nthBitis1( uint 8_t byte, uint 8_t Addr, uint8_t num ) 
uint8_t count =0;  
LabelNextByte:
SetPinsDefault1();
SetAddrInform() ;
SetPin34Out();
if((byte&0x01)!=0) { SetPin34High() ;  } else  {  SetPin34Low();}
SendStrobeSync(Addr); 
count++;
if (count<num) {  byte=(byte>>1);  goto LabelNextByte ;}
return;
}
 
/*************************************/
 
void  SendDivCoefDVDC( uint8_t digits[6]) 
 {
 /*
; for bit=1 in the register set 0  on the pin34 as output , 1-st bit of the LSB digit of the dividing coeff.  first 
;  bit 0  digit1  , LSB  Send_nInformBit_0_IfFirtstBitTrue 
;  bit 1  digit1
;  bit 2  digit1
;  bit 3  digit1
;  bit 0  digit2  digits_f[1];  , for D26
;  bit 1  digit2
;  bit 2  digit2
;  bit 3  digit2
;  bit 0  digit3  digits_f[2];  , for D7
;  bit 1  digit3
;  bit 2  digit3
;  bit 3  digit3
;  bit 0  digit4   ;  digits_f[3];//9, for D10
;  bit 1  digit4
;  bit 2  digit4
;  bit 3  digit4
;  bit 0  digit5   digits_f[4];//7,for D16
;  bit 1  digit5
;  bit 2  digit5
;  bit 3  digit5
;  bit 0  digit6   ; digits_f[5];//12, for D20
;  bit 1  digit6
;  bit 2  digit6
;  bit 3  digit6
 
; mov reg_data, reg_byte0 ; digits_f[0];   8, for D24
*/
 
 
Sendnbits_nInform_0If_nthBit_is1(digits[0], ADDR_DPKD, 0x04);
Sendnbits_nInform_0If_nthBit_is1(digits[1], ADDR_DPKD, 0x04);
Sendnbits_nInform_0If_nthBit_is1(digits[2], ADDR_DPKD, 0x04);
Sendnbits_nInform_0If_nthBit_is1(digits[3], ADDR_DPKD, 0x04);
Sendnbits_nInform_0If_nthBit_is1(digits[4], ADDR_DPKD, 0x04);
Sendnbits_nInform_0If_nthBit_is1(digits[5], ADDR_DPKD, 0x04); 
    
//SendMemWrPulse(); 
}
 
 
 
void SendDAC_FM_DAC(uint8_t DACFM, uint8_t DACAt   ){
 /*
; for send 1  to the trigger FM/At  set 0   on the pin 34 and send SyncFM pulse 
 
 ; bit '8' DAC at, no data
 ; bit '4' DAC at
 ; bit '2' DAC at
 ; bit '1' DAC at 
 
; bit 2 DAC FM 
; bit 3 DAC FM
; bit 4 DAC FM 
; bit 5 DAC FM 
; bit 6 DAC FM  
; bit 7 DAC FM
; bit 8 DAC FM
; bit 9 DAC FM  
*/
//;    db1=DACAt,  LSB bit '8' DACAt  ;   
  Sendnbits_nInform_0If_nthBit_is1( DACAt, ADDR_FM, 0x04);
//; send DAC FM coefs , bit '2' DAC FM
  Sendnbits_nInform_0If_nthBit_is1(DAC FM, ADDR_FM, 0x08);
// ;  12 pulses 
 
}
 
 
 
 
void  SendModeBits(uint8_t BitsOut, uint8_t BitsModul, uint8_t  BitsLFO){
/*
 ;   BitsOut reg_byte0 ,  BitsModul reg_byte1 ,  BitsLFO reg_byte2
 ;  24 bit data
 ; 8   no      LSB
 ; 4   no
 ; 2   no
 ;  1 Out 
 ;  8 +6dB
 ;  4 uV
 ;  2 mV
 ;  1 dBV
 
 ;   no LSB
 ;   no
 ;   PM ext
 ;  AM ext
;  FM ext
 ;  PM
;   AM
;   FM
 
 ;  10k LSB   reg_byte2  BitsLFO
 ;  3,4k
 ;  2,5k
 ;  1k
;   0,4k
;   0,3k
;   0,2k
;   0,05k 
*/
 
  Sendnbits_nInform_0If_nthBit_is1( BitsOut, ADDR_MODE, 0x08);
  Sendnbits_nInform_0If_nthBit_is1( BitsModul, ADDR_MODE, 0x08);
  Sendnbits_nInform_0If_nthBit_is1 (BitsLFO, ADDR_MODE, 0x08);
 
}
 
void   SendDAC_AM_VRefCoefs(uint8_t DACVref[2],  uint8_t DACAM[2] ) 
{ 
//  ; DACVref reg_byte1, reg_byte0 ,  DACAM   reg_byte3,reg_byte2 
 /*
; for send 0  to the trigger AM/Vref  set 1   on the pin 34 and send SyncAM pulse 
;send DAC Vref 0...9 coefs , 1000= 0x03e8=0b 0000 0011 1110 1000 
 ; db1=DACVref ; 
 
;   bit 0 DAC VRef, reg_byte0,  LSB 
;   bit 1 DAC VRef  
;   bit 2 DAC VRef 
;   bit 3 DAC VRef
;   bit 4 DAC VRef 
;   bit 5 DAC VRef 
;   bit 6 DAC VRef  
;   bit 7 DAC VRef  
 
;   bit 8 DAC VRef reg_byte1, LSB
;   bit 9 DAC VRef 
 
 ;  bit 0 DAC AM , reg_byte2, LSB
 ;  bit 1 DAC AM
 ;  bit 2 DAC AM
 ;  bit 3 DAC AM
 ;  bit 4 DAC AM
 ;  bit 5 DAC AM
 ;  bit 6 DAC AM
 ;  bit 7 DAC AM
 
 ;  bit 8 DAC AM reg_byte3, LSB
 ;  bit 9 DAC AM
*/
 
Sendnbits_nInform_0If_nthBit_is1(DACVref[0], ADDR_AM_VREF, 0x08);
Sendnbits_nInform_0If_nthBit_is1(DACVref[1], ADDR_AM_VREF, 0x02);
 
//;send DAC AM coeffs 0...9
//; send DAC Vref 0...9 coefs 
Sendnbits_nInform_0If_nthBit_is1(DACAM[0], ADDR_AM_VREF, 0x08);
Sendnbits_nInform_0If_nthBit_is1(DACAM[1], ADDR_AM_VREF, 0x02);
 
// ;  20 pulses StrobeSyncAM 
}
 
 
void SendLFOBits( uint8_t LFObits, uint8_t LFOenabled) 
{
/* 
;  0  bit nE   reg_byte1 LFOenabled;  
;  1  bit '1' LFO reg_byte0 LFObits;  
;  2  bit '2' LFO
;  3  bit '4'   LFO
*/
Sendnbits_nInform_0If_nthBit_is1(LFOenabled, ADDR_LFO, 0x01);
Sendnbits_nInform_0If_nthBit_is1(LFObits, ADDR_LFO, 0x03);
//; SendMemWrPulse();
}
 
 
 
 
void  SendHFObits(uint8_t OscCode, uint8_t FMAtt)
{
/* 
; FMAtt reg_byte0 ,   OscCode  reg_byte1
 
;    FM Att 1/10     reg_byte0 ,LSB 
 
 ;     OSCSEL '1'   reg_byte1 ,LSB 
;      OSCSEL '2'
;      OSCSEL '4'
 ;     FilterBand
 ;     BandSel '1' 
;     BandSel '2'
;     BandSel '4'
*/
 
Sendnbits_nInform_0If_nthBit_is1(   FMAtt,  ADDR_HFO, 0x01);
Sendnbits_nInform_0If_nthBit_is1(  OscCode, ADDR_HFO, 0x07);
 
}
 
 
 
 
/***************************************/
 
 uint8_t SelectAtt2(uint8_t value , uint8_t *Flag10dB)
 {
/*
 ;0 means yoke off (  for 1 on the inform bus, 0 on the nInform  pin  )
 ;1 means yoke on  (  for 0 on the inform bus, 1 on the nInform  pin  )
 
*/      
if(value==0)   { *Flag10dB=0;  return  0b11110000; }    // 0 dB, 1000...317, DAC Vref decoder off
if(value==1)  { *Flag10dB=1;   return  0b11100001; } //10 dB, 999...319 , DAC Vref decoder on
if(value==2) {   *Flag10dB=0;  return  0b11010010; }//20 dB
if(value==3) {  *Flag10dB=1;  return  0b11000011; }//30 dB  
if(value==4) {  *Flag10dB=0;  return  0b10110100; }//40dB
if(value==5) {  *Flag10dB=1;   return  0b10100101; }//50dB
if(value==6) {  *Flag10dB=0;   return  0b10010110; }//60dB
if(value==7) {  *Flag10dB=1;    return  0b10000111; }//70dB
if(value==8) {  *Flag10dB=0;    return  0b01111000; }//80dB
if(value==9) {  *Flag10dB=1;    return  0b01101001; }//90dB
if(value==10) {  *Flag10dB=0;  return  0b01011010; }//100dB
if(value==11) {  *Flag10dB=1;  return  0b01001011; }//110dB          
if(value==12) {  *Flag10dB=0; return  0b00111100; }//120dB               
if(value==13) {  *Flag10dB=1; return  0b00101101; }//130dB                
if(value==14) {  *Flag10dB=0; return  0b00011110; }//140dB 
return 0;   
 }
 
 
void  SendAttBits(uint8 _t natt_data ,  uint8_t FlagOff )  
{
 /*
 ; uint8_t db1;
 ;db1=bits_att;
 ;0 means yoke off (  for 1 on the inform bus )
;1 means yoke on  (  for 0 on the inform bus )
; 0    10dB
; 1    20 dB
; 2    40 dB
; 3    80 dB
; 4    10 dB off
; 5    20 dB off
; 6    40 dB off
; 7    80 dB off 
*/
 
if(FlagOff==1){ natt_data=0x00;    }
Sendnbits_nInform_1If_nthBitis1( natt_data, ADDR_ATT, 0x08);
}
 
void  SendStaticCMDBits() ; StaticCMD 
{
/*
;
; uint8_t db1;
; for 0 on the trigger out (for not inverted outputs) send 0 via the inform bus
; for 1 on the trigger out (for not inverted outputs) set 1 via the inform bus
; for 1 on the trigger out  for   inverted outputs AMext,FMext,PMext  send 0 via the inform bus
; for 0 on the trigger out  for   inverted outputs  AMext,FMext,PMext send 1  via the inform bus
; nPMext ; nFMext ; nAMext ; PM; FM; AM; MixOn; 1kHz 
; db1=StaticCMD ;
1 0 ;   1 kHz
2 1 ;    MixOn 
3 2 ;   AM 
4 3 ;    FM  
5 4 ; PM
6 5 ; notAMext, see inverse output of the trigger D16
7 6 ;  notFMext, see inverse output of the trigger D16
8 7 ;  notPMext, see inverse output of the trigger D16
*/
 
Sendnbits_nInform_0If_nthBit_is1(  reg_byte0, ADDR_SYNCSTATIC, 0x08);
 //;SendMemWrPulse();
}
 
 /******************************************/
 
//in the  PROGMEM
uint8_t IndTableInvCode[16]  =
{
 0b10001000 , 0b11101101,0b10010100,0b10000101,0b10100001,0b10000011,0b10000010, 0b10101101,0b10000000, 0b10000001 ,
 0b1111011, 0b11111111 ,0b11111111,0b11111111,0b11111111,0b11111111
};
 
uint8_t  SevenSegment( uint8_t Digit, uint8_t Comma )  
{
/*
;
;LSB  e; c; b; d; f; g; a; h  MSB
;     a 
;b        c
;     d
;e        f
;     g
;              h
;1 on the inform bus means turn on segment
;                                          ecbdfga; 
; 
*/
 
uint8_t tmp= IndTableInvCode[Digit];
if(Comma!=0) {  return (IndTableInvCode[Digit]&0b01111111);        } //h  
 return (uint8_t) IndTableInvCode[(uint8_t)Digit];
}
 
 
 
void  SendBitsBlink( uint8_t BitsAddrBlink)    
 {
/*
; first sent bit 3  2   1  0 last sent bit 
; for 1 on the inform bus send 0 to pin 34 ( and send strobe after it )
*/
Send_nInformBit_1_IfByteFalse( (BitsAddrBlink&0x08)   ) ;
SendStrobeSync(ADDR_SYNCBLINK );
Send_nInformBit_1_IfByteFalse( (BitsAddrBlink&0x04)   ) ;
SendStrobeSync(ADDR_SYNCBLINK );
Send_nInformBit_1_IfByteFalse( (BitsAddrBlink&0x02)   ) ;
SendStrobeSync(ADDR_SYNCBLINK );
Send_nInformBit_1_IfByteFalse( (BitsAddrBlink&0x01)   ) ;
SendStrobeSync(ADDR_SYNCBLINK );
//; without SyncWRRAM pulse , use after send all digits for blink control with TurnOnBlink(),TurnOffBlink(); 
}
 
 
 
void SendBitsRAM(uint8_t BitsAddr, uint8_t Digit , uint8_t BitComma/*,  uint8_t BitsBlink*/)
{ 
/*
;
;     a 
;b        c
;     d
;e        f
;     g
 ;             h
;1 on the inform bus means turn on segment
;
;Inform n8; n4; n2 ; n1 ; e; c; b; d; f; g; a; h;
;
;
;0 1 2 3 4 5 6      7 8 9         a b      c d e f      Addr
;f  e d c b  a 9      8 7 6        5 4      3 2 1 0   ~Addr
;x x x x x x x      x x x         x x      x x x x ;
; Digit  reg_byte0 ,   Comma reg_byte1
; send address bit using inverse code  
;  for set 1 on the bit Inform set 0 on the nInform (for pin 34 emulation )   
; for set 0 on the bit Inform set 1 on the nInform (for pin 34 emulation )    
*/
uint8_t byte= SevenSegment() ;  
Send_nInformBit_1_IfByteFalse( (BitsAddrBlink&0x08)   ) ;  //  addr 8 
SendStrobeSync(ADDR_SYNCRAM ); //1
Send_nInformBit_1_IfByteFalse( (BitsAddrBlink&0x04)   ) ;  //  addr 4   
SendStrobeSync(ADDR_SYNCRAM ); //2 
Send_nInformBit_1_IfByteFalse( (BitsAddrBlink&0x02)   ) ;  //  addr 2   
SendStrobeSync(ADDR_SYNCRAM ); //3  
Send_nInformBit_1_IfByteFalse( (BitsAddrBlink&0x01)   ) ;  //  addr 1   
SendStrobeSync(ADDR_SYNCRAM ); //4   
 
 
/* for turn on segment set 1  on the Inform Bus, set nIform(34)=0,  as the output */
Sendnbits_nInform_0If_nthBit_is1( byte, ADDR_SYNCRAM , 0x08);
SendMemWrRAMPulse() ; 
 
 
/*
0 e LSB
1 c
2 b 
3 d
4 f
5 g
6 a
7 h
 
*/
 
 
 
 
 
return;
}
 
 
  
/****************************************************/
 
 
 
 
uint8_t  GetByteLD()
{
//; nLD0 ,nLD1,nLD2,nLD3,nLD4,nLD4,nLD5,nLD6, 1 
SetPin34Input() ;  
 
uint8_t reg_data=0; 
for (uint8_t  count=0; count<8; i++)
{
SendPulseSyncInLD() ; //   Pin36 to multiplexer , Sync 
 SetPin34Input() ; 
if ( GetBitInformLD()==0 ) { reg_data|=(1<<count);  }   // decode for true bits  
}
 
reg_data&=0x7F;    
//; call SendPulse_data_accept;   
return reg_data;
}
 
 
 
 
uint8_t  GetByteGCd()
{
/*
;7 6  5  4    3     2     1    0 
;x;x;x;nc1;nr1;nr2;nc0;nr0;   
*/
SetPin34Input() ;  
 
uint8_t reg_data=0; 
for (uint8_t count=0; count<8; i++)
{
 SendPulseSyncInGCD() ; //   Pin36 to multiplexer , SyncPool
 SetPin34Input() ; 
if ( GetBitInformGCd()!=0 ) { reg_data|=(1<<count);  }  
}
 
//; call SendPulse_data_accept;  optimize plce of this subroutine 
return reg_data;
}
Добавлено через 41 секунду
Еще не отлажены .

Добавлено через 2 минуты
На адрес ADDR_INFORM_WAIT переходить после выполнения всего пакета посылок кодов и выхода в цикл ожидания прерывания . Подумать еще про безопасность адреса после посылки кодов (помехоустойчивость).

Добавлено через 3 часа 41 минуту
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#define GetHBYTE (  WORD ) (  (uint8_t) (((WORD)&0xff00)>>8)   )
#define GetLBYTE (  WORD ) (  (uint8_t) (((WORD)&0x00ff)>>0)   )
 
 
//read  using uint16_t word=pgm_read_word_near(LogTable1 + k); k= minusdbV*10
const uint16_t  LogTable1[100]   PROGMEM 
{
  0x03e8,  0x03dd,  0x03d1,  0x03c6,  0x03bb,  0x03b0,  0x03a5,  0x039b,  0x0390,  0x0386 ,  /* 0.0-0.9   */
 0x037b,  0x0371,  0x0367,  0x035d,  0x0353,  0x0349,  0x0340,  0x0336,  0x032d,  0x0324 ,   /* 1.0-1.9   */
 0x031a,  0x0311,  0x0308,  0x02ff,  0x02f7,  0x02ee,  0x02e5,  0x02dd,  0x02d4,  0x02cc ,      /* 2.0-2.9   */
  0x02c4,  0x02bc,  0x02b4,  0x02ac,  0x02a4,  0x029c,  0x0295,  0x028d,  0x0286,  0x027e,   /* 3.0-3.9   */
  0x0277,  0x0270,  0x0269,  0x0262,  0x025b,  0x0254,  0x024d,  0x0246,  0x023f,  0x0239 ,  /* 4.0-4.9   */
  0x0232,  0x022c,  0x0226,  0x021f,  0x0219,  0x0213,  0x020d,  0x0207,  0x0201,  0x01fb ,    /* 5.0-5.9   */
  0x01f5,  0x01ef,  0x01ea,  0x01e4,  0x01df,  0x01d9,  0x01d4,  0x01ce,  0x01c9,  0x01c4 ,      /* 6.0-6.9   */
  0x01bf,  0x01ba,  0x01b5,  0x01b0,  0x01ab,  0x01a6,  0x01a1,  0x019c,  0x0197,  0x0193,     /* 7.0-7.9   */
  0x018e,  0x018a,  0x0185,  0x0181,  0x017c,  0x0178,  0x0174,  0x016f,  0x016b,  0x0167 ,   /* 8.0-8.9   */
  0x0163,  0x015f,  0x015b,  0x0157,  0x0153,  0x014f,  0x014b,  0x0147,  0x0144,  0x0140     /* 9.0-9.9   */
} ;
 
//read  using uint16_t word=pgm_read_word_near(LinTable316 + k);   k=316-u
const uint16_t LinTable316[216] PROGMEM
{
 0x03e7,  0x03e4,  0x03e1,  0x03de,  0x03db,  0x03d8,  0x03d4,  0x03d1,  0x03ce,  0x03cb,  /* 0-9   ,  316,315...307*/
 0x03c8,  0x03c5,  0x03c1,  0x03be,  0x03bb,  0x03b8,  0x03b5,  0x03b2,  0x03ae,  0x03ab , /* 10-19,  306,305...297 */
 0x03a8,  0x03a5,  0x03a2,  0x039f,  0x039b,  0x0398,  0x0395,  0x0392,  0x038f,  0x038c,   /* 20-29 ,  296,295...287*/
 0x0388,  0x0385,  0x0382,  0x037f,  0x037c,  0x0379,  0x0376,  0x0372,  0x036f,  0x036c, /* 30-39,  286,285...277 */
 0x0369,  0x0366,  0x0363,  0x035f,  0x035c,  0x0359,  0x0356,  0x0353,  0x0350,  0x034c, /* 40-49,  276,275...267 */
 0x0349,  0x0346,  0x0343,  0x0340,  0x033d,  0x0339,  0x0336,  0x0333,  0x0330,  0x032d, /* 50-59,  266,265...257 */
 0x032a,  0x0326,  0x0323,  0x0320,  0x031d,  0x031a,  0x0317,  0x0313,  0x0310,  0x030d ,/* 60-69 ,  256,255...247*/
 0x030a,  0x0307,  0x0304,  0x0301,  0x02fd,  0x02fa,  0x02f7,  0x02f4,  0x02f1,  0x02ee, /* 70-79 ,  246,245...237*/
 0x02ea,  0x02e7,  0x02e4,  0x02e1,  0x02de,  0x02db,  0x02d7,  0x02d4,  0x02d1,  0x02ce, /* 80-89,  236,235...227 */
 0x02cb,  0x02c8,  0x02c4,  0x02c1,  0x02be,  0x02bb,  0x02b8,  0x02b5,  0x02b1,  0x02ae, /* 90-99 ,  226,225...217*/
 
 0x02ab,  0x02a8,  0x02a5,  0x02a2,  0x029e,  0x029b,  0x0298,  0x0295,  0x0292,  0x028f , /* 100-109,  216,215...207 */
 0x028b,  0x0288,  0x0285,  0x0282,  0x027f,  0x027c,  0x0279,  0x0275,  0x0272,  0x026f , /* 110-119 ,  206,205...197 */
 0x026c,  0x0269,  0x0266,  0x0262,  0x025f,  0x025c,  0x0259,  0x0256,  0x0253,  0x024f , /* 120-129 ,  196,195...187 */
 0x024c,  0x0249,  0x0246,  0x0243,  0x0240,  0x023c,  0x0239,  0x0236,  0x0233,  0x0230 , /* 130-139 ,  186,185...177 */
 0x022d,  0x0229,  0x0226,  0x0223,  0x0220,  0x021d,  0x021a,  0x0216,  0x0213,  0x0210 , /* 140-149 ,  176,175...167 */
 0x020d,  0x020a,  0x0207,  0x0203,  0x0200,  0x01fd,  0x01fa,  0x01f7,  0x01f4,  0x01f1 ,      /* 150-159,  166,165...157  */
 0x01ed,  0x01ea,  0x01e7,  0x01e4,  0x01e1,  0x01de,  0x01da,  0x01d7,  0x01d4,  0x01d1 , /* 160-169,  156,155...147  */
 0x01ce,  0x01cb,  0x01c7,  0x01c4,  0x01c1,  0x01be,  0x01bb,  0x01b8,  0x01b4,  0x01b1, /* 170-179,  146,145...137  */
 0x01ae,  0x01ab,  0x01a8,  0x01a5,  0x01a1,  0x019e,  0x019b,  0x0198,  0x0195,  0x0192, /* 180-189,  136,135...127  */
 0x018e,  0x018b,  0x0188,  0x0185,  0x0182,  0x017f,  0x017c,  0x0178,  0x0175,  0x0172, /* 190-199,  126,125...117 */
 
 0x016f,  0x016c,  0x0169,  0x0165,  0x0162,  0x015f,  0x015c,  0x0159,  0x0156,  0x0152 ,  /* 200-209 ,   116,115...107*/
 0x014f,  0x014c,  0x0149,  0x0146,  0x0143,  0x013f    /* 210-215 ,   106,105...101 */
};
Добавлено через 10 минут
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <avr/pgmspace.h>
//uint8_t hbyte=pgm_read_byte_near(LogTableH + k);
const uint8_t  LogTableH[100]   PROGMEM 
{
  0x03,   0x03,  0x03,  0x03,   0x03,   0x03,  0x03,    0x03,   0x03,   0x03, 
 0x03,   0x03,  0x03,  0x03,   0x03,   0x03,   0x03,   0x03,   0x03,   0x03,  
 0x03,   0x03,   0x03,   0x02,   0x02,   0x02,   0x02,   0x02,   0x02,   0x02,  
  0x02,   0x02,  0x02,  0x02,   0x02,   0x02,   0x02,   0x02,  0x02,   0x02, 
  0x02,   0x02,   0x02,   0x02,  0x02,   0x02,    0x02,   0x02,   0x02,  0x02, 
  0x02,  0x02,   0x02,  0x02,   0x02,   0x02,  0x02,   0x02,  0x02,  0x01, 
  0x01,   0x01,   0x01,   0x01,   0x01,   0x01,   0x01,   0x01,   0x01,   0x01, 
  0x01,   0x01,  0x01,  0x01,   0x01,   0x01,   0x01,  0x01,   0x01,  0x01, 
  0x01,   0x01,    0x01,   0x01,  0x01,  0x01,   0x01,   0x01,  0x01,   0x01, 
  0x01,   0x01,   0x01,   0x01,   0x01,   0x01,  0x01,   0x01,   0x01,   0x01  
};
//uint8_t lbyte=pgm_read_byte_near(LogTableL + k);
const uint8_t  LogTableL[100]   PROGMEM 
{
  0xe8,   0xdd,   0xd1,   0xc6,   0xbb,   0xb0,   0xa5,   0x9b,   0x90,   0x86 ,
  0x7b,   0x71,   0x67,   0x5d,   0x53,   0x49,   0x40,   0x36,   0x2d,   0x24, 
  0x1a,   0x11,   0x08,   0xff,     0xf7,    0xee,   0xe5,   0xdd,   0xd4,   0xcc ,
   0xc4,  0xbc,   0xb4,   0xac,   0xa4,     0x9c,  0x95,   0x8d,   0x86,    0x7e ,
   0x77,   0x70,  0x69,   0x62,   0x5b,   0x54,   0x4d,   0x46,   0x3f,   0x39 ,
   0x32,   0x2c,   0x26,   0x1f,   0x19,   0x13,   0x0d,   0x07,   0x01,   0xfb, 
   0xf5,    0xef,   0xea,   0xe4,   0xdf,   0xd9,   0xd4,   0xce,   0xc9,   0xc4 ,
   0xbf,   0xba,   0xb5,   0xb0,   0xab,   0xa6,  0xa1,   0x9c,   0x97,   0x93 ,
   0x8e,   0x8a,   0x85,   0x81,   0x7c,   0x78,   0x74,   0x6f,   0x6b,   0x67 ,
   0x63,   0x5f,   0x5b,   0x57,   0x53,   0x4f,   0x4b,   0x47,   0x44,   0x40 
};
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
29.03.2020, 23:38  [ТС]
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const uint16_t LinTable316H[216] PROGMEM
{
 0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  /* 0-9   ,  316,315...307*/
 0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03  , /* 10-19,  306,305...297 */
 0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,   /* 20-29 ,  296,295...287*/
 0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 , /* 30-39,  286,285...277 */
 0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 , /* 40-49,  276,275...267 */
 0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 , /* 50-59,  266,265...257 */
 0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x03  ,/* 60-69 ,  256,255...247*/
 0x03 ,  0x03 ,  0x03 ,  0x03 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 , /* 70-79 ,  246,245...237*/
 0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 , /* 80-89,  236,235...227 */
 0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 , /* 90-99 ,  226,225...217*/
 
 0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02  , /* 100-109,  216,215...207 */
 0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02  , /* 110-119 ,  206,205...197 */
 0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02  , /* 120-129 ,  196,195...187 */
 0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02  , /* 130-139 ,  186,185...177 */
 0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02  , /* 140-149 ,  176,175...167 */
 0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x02 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01  ,      /* 150-159,  166,165...157  */
 0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01  , /* 160-169,  156,155...147  */
 0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 , /* 170-179,  146,145...137  */
 0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 , /* 180-189,  136,135...127  */
 0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 , /* 190-199,  126,125...117 */
 
 0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01  ,  /* 200-209 ,   116,115...107*/
 0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01 ,  0x01     /* 210-215 ,   106,105...101 */
}; 
 
const uint16_t LinTable316L[216] PROGMEM
{
 0xe7,  0xe4,  0xe1,  0xde,  0xdb,  0xd8,  0xd4,  0xd1,  0xce,  0xcb,  /* 0-9   ,  316,315...307*/
 0xc8,  0xc5,  0xc1,  0xbe,  0xbb,  0xb8,  0xb5,  0xb2,  0xae,  0xab , /* 10-19,  306,305...297 */
 0xa8,  0xa5,  0xa2,  0x9f,  0x9b,  0x98,  0x95,  0x92,  0x8f,  0x8c,   /* 20-29 ,  296,295...287*/
 0x88,  0x85,  0x82,  0x7f,  0x7c,  0x79,  0x76,  0x72,  0x6f,  0x6c, /* 30-39,  286,285...277 */
 0x69,  0x66,  0x63,  0x5f,  0x5c,  0x59,  0x56,  0x53,  0x50,  0x4c, /* 40-49,  276,275...267 */
 0x49,  0x46,  0x43,  0x40,  0x3d,  0x39,  0x36,  0x33,  0x30,  0x2d, /* 50-59,  266,265...257 */
 0x2a,  0x26,  0x23,  0x20,  0x1d,  0x1a,  0x17,  0x13,  0x10,  0x0d ,/* 60-69 ,  256,255...247*/
 0x0a,  0x07,  0x04,  0x01,  0xfd,  0xfa,  0xf7,  0xf4,  0xf1,  0xee, /* 70-79 ,  246,245...237*/
 0xea,  0xe7,  0xe4,  0xe1,  0xde,  0xdb,  0xd7,  0xd4,  0xd1,  0xce, /* 80-89,  236,235...227 */
 0xcb,  0xc8,  0xc4,  0xc1,  0xbe,  0xbb,  0xb8,  0xb5,  0xb1,  0xae, /* 90-99 ,  226,225...217*/
 
 0xab,  0xa8,  0xa5,  0xa2,  0x9e,  0x9b,  0x98,  0x95,  0x92,  0x8f , /* 100-109,  216,215...207 */
 0x8b,  0x88,  0x85,  0x82,  0x7f,  0x7c,  0x079,  0x75,  0x72,  0x6f , /* 110-119 ,  206,205...197 */
 0x6c,  0x69,  0x66,  0x62,  0x5f,  0x5c,  0x59,  0x56,  0x53,  0x4f , /* 120-129 ,  196,195...187 */
 0x4c,  0x49,  0x46,  0x43,  0x40,  0x3c,  0x39,  0x36,  0x33,  0x30 , /* 130-139 ,  186,185...177 */
 0x2d,  0x29,  0x26,  0x23,  0x20,  0x1d,  0x1a,  0x16,  0x13,  0x10 , /* 140-149 ,  176,175...167 */
 0x0d,  0x0a,  0x07,  0x03,  0x00,  0xfd,  0xfa,  0xf7,  0xf4,  0xf1 ,      /* 150-159,  166,165...157  */
 0xed,  0xea,  0xe7,  0xe4,  0xe1,  0xde,  0xda,  0xd7,  0xd4,  0xd1 , /* 160-169,  156,155...147  */
 0xce,  0xcb,  0xc7,  0xc4,  0xc1,  0xbe,  0xbb,  0xb8,  0xb4,  0xb1, /* 170-179,  146,145...137  */
 0xae,  0xab,  0xa8,  0xa5,  0xa1,  0x9e,  0x9b,  0x98,  0x95,  0x92, /* 180-189,  136,135...127  */
 0x8e,  0x8b,  0x88,  0x85,  0x82,  0x7f,  0x7c,  0x78,  0x75,  0x72, /* 190-199,  126,125...117 */
 
 0x6f,  0x6c,  0x69,  0x65,  0x62,  0x5f,  0x5c,  0x59,  0x56,  0x52 ,  /* 200-209 ,   116,115...107*/
 0x4f,  0x4c,  0x49,  0x46,  0x43,  0x3f    /* 210-215 ,   106,105...101 */
};
Добавлено через 1 час 15 минут
Принцип выбора ослабления в децибелах и напряжения ЦАП ОН в логарифмическом режиме



C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#define  nATT_0_dB ~(0b11110000)  // уточнить инверсию  и порядок битов 
#define  nATT_10_dB ~(0b11100001)
#define  nATT_20_dB ~(0b11010010)
#define  nATT_30_dB  ~(0b11000011)
#define  nATT_40_dB  ~(0b10110100)
#define  nATT_50_dB  ~(0b10100101)
#define  nATT_60_dB  ~(0b10010110)
#define  nATT_70_dB  ~(0b10000111)
#define  nATT_80_dB  ~(0b01111000)
#define  nATT_90_dB  ~(0b01101001)
#define  nATT_100_dB  ~(0b01011010)
#define  nATT_110_dB  ~(0b01001011)
#define  nATT_120_dB  ~(0b00111100)
#define  nATT_130_dB   ~(0b00101101)
#define  nATT_140_dB  ~(0b00011110)
 
uint16_t  GetDACValue_dBV( uint16_t Value_dBV    ,  uint8_t  *attcode      )
{
uint8_t AttNum;
  
if(Value_dBV>=0){   
if(Value_dBV<=99){
*attcode=nATT_0_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV))  ;
 }}
 
if(Value_dBV>=100){
if(Value_dBV<=199){
 
*attcode=nATT_10_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-100))  ;
 }} 
if(Value_dBV>=200){
if(Value_dBV<=299){
 
*attcode=nATT_20_dB; 
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-200))  ; 
 }}
if(Value_dBV>=300){
if(Value_dBV<=399){
 
*attcode=nATT_30_dB; 
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-300))  ; 
 }}
 
if(Value_dBV>=400){
if(Value_dBV<=499){
 
*attcode=nATT_40_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-400))  ;  
 }}
 
if(Value_dBV>=500){
if(Value_dBV<=599){
 
*attcode=nATT_50_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-500))  ;  
 }}
 
if(Value_dBV>=600){
if(Value_dBV<=699){
 
*attcode=nATT_60_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-600))  ; 
 }}
 
if(Value_dBV>=700){
if(Value_dBV<=799){
 
*attcode=nATT_70_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-700))  ;  
 }}
 
if(Value_dBV>=800){
if(Value_dBV<=899){
 
*attcode=nATT_80_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-800))  ; 
 }}
if(Value_dBV>=900){
if(Value_dBV<=999){
 
*attcode=nATT_90_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-900))  ;  
 }}
 
if(Value_dBV>=1000){
if(Value_dBV<=1099){
 
*attcode=nATT_100_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1000))  ;  
 }}
 
if(Value_dBV>=1100){
if(Value_dBV<=1199){
 
*attcode=nATT_110_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1100))  ; 
 }}
 
 
if(Value_dBV>=1200){
if(Value_dBV<=1299){
 
*attcode=nATT_120_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1200))  ; 
 }}
if(Value_dBV>=1300){
if(Value_dBV<=1399){
 
*attcode=nATT_130_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1300))  ; 
 }}
 
if(Value_dBV>=1400){
if(Value_dBV<=1499){
 
*attcode=nATT_0_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1400))  ; 
 }}
 
 
 
}
 
 
uint16_t  GetDACValue_mV( uint16_t Value_mV    , uint8_t commapos,  uint8_t  *attcode      )
{
uint8_t AttNum;
 
 
if(Value_mV>=317){      //1000. ...317. mV
if(Value_mV<=1000){
if(commapos==COMMA_4DIGIT){   *attcode=nATT_0_dB; }  //1000. ...317. mV
if(commapos==COMMA_3DIGIT){   *attcode=nATT_20_dB; }//100.0  ...31.7 mV
if(commapos==COMMA_2DIGIT){   *attcode=nATT_40_dB; }//10.00  ...3.17 mV
return (uint16_t )  Value_mV     ;
 }}
 
 if(Value_mV>=101){   //101. ...316. mV 
if(Value_mV<=316){
if(commapos==COMMA_4DIGIT){   *attcode=nATT_10_dB; } //316. ...101. mV
if(commapos==COMMA_3DIGIT){   *attcode=nATT_30_dB; } //31.6  ...10.1  mV
if(commapos==COMMA_2DIGIT){   *attcode=nATT_50_dB; } //3.16  ...1.01  mV
 
 
return (uint16_t ) pgm_read_word_near(LinTable316 +(uint16_t) (316-Value_mV) )      ;
 }}
 
return 0;  
}
 
 
 
 
uint16_t  GetDACValue_mkV( uint16_t Value_mkV    , uint8_t commapos,  uint8_t  *attcode      )
{
uint8_t AttNum;
 
 
if(Value_mkV>=317){      //1000. ...317. mkV
if(Value_mkV<=1000){
if(commapos==COMMA_4DIGIT){   *attcode=nATT_60_dB; }  //1000. ...317. uV
if(commapos==COMMA_3DIGIT){   *attcode=nATT_80_dB; }//100.0  ...31.7 uV
if(commapos==COMMA_2DIGIT){   *attcode=nATT_100_dB; }//10.00  ...3.17 uV
if(commapos==COMMA_1DIGIT){   *attcode=nATT_120_dB; }//1.000  ...0.317 uV 
return (uint16_t )  Value_mkV     ;
 }}
 
 if(Value_mkV>=101){   //101. ...316. mkV
if(Value_mkV<=316){
if(commapos==COMMA_4DIGIT){   *attcode=nATT_70_dB; } //316. ...101. uV
if(commapos==COMMA_3DIGIT){   *attcode=nATT_90_dB; } //31.6  ...10.1  uV
if(commapos==COMMA_2DIGIT){   *attcode=nATT_110_dB; } //3.16  ...1.01  uV
if(commapos==COMMA_1DIGIT){   *attcode=nATT_130_dB; }//0.316  ...0.101 uV  
return (uint16_t ) pgm_read_word_near(LinTable316 +(uint16_t)  (316-Value_mkV))      ;
 }}
 
if(Value_mkV>=32){   //0.100 ... 0.032 mkV
if(Value_mkV<=100){
if(commapos==COMMA_1DIGIT){   *attcode=nATT_140_dB; }//0.100  ...0.032 uV  
 
return (uint16_t )    (Value_mkV*10);   //fix for fast mul10
 }}
 
 
return 0;  
 
}
 
 
uint16_t GetDACValue ( uint8_t digits[4], uint8_t commapos,  uint8_t  *attcode , uint8_t mode    )
{
uint16_t  Value ;
Value=GetOutValueFromDigits(digits);  //0032...1000
if(mode==TOKEN_Out_dB)  {  return   GetDACValue_dBV(Value, attcode );  } 
if(mode==TOKEN_Out_mkV)  { return GetDACValue_mV( Value, commapos, attcode);   } 
if(mode==TOKEN_Out_mV)  {   return GetDACValue_mkV(  Value, commapos,attcode );  } 
return 0;
}
Добавлено через 2 минуты
digits[4], commapos, mode берутся из структуры состояния в памяти , GetDACValue() к программе выработки по выходу

Добавлено через 23 минуты
Подпрограмма выработки кода АМ (глубину модуляции умножить на 10, порядок байтов оптимизировать ):
C++
1
2
3
4
5
6
7
uint16_t GetDACAMValue ( uint8_t digits )
{
uint16_t AMValue=0;    // AMValue=(uint16_t) 10*M 
for(uint8_t i=0;i<digit[1];i++) { AMValue+=10;  }
for(uint8_t i=0;i<digit[0];i++) { AMValue+=100;  } 
return  AMValue;
}
Добавлено через 57 минут
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
uint32_t freq_fromdigits_div10( uint8_t freq[7])
{
uint32 result=0;
result+=(uint32) freq[1];
for(uint8_t i=0;i<freq[2];i++) { result+=10;  } 
for(uint8_t i=0;i<freq[3];i++) { result+=100;  } 
for(uint8_t i=0;i<freq[4];i++) { result+=1000;  }
for(uint8_t i=0;i<freq[5];i++) { result+=10000;  }
for(uint8_t i=0;i<freq[6];i++) { result+=100000;  }
 
}
 
 
uint32_t freq_fromdigits ( uint8_t freq[7])
{
uint32 result=0;
result+=(uint32) freq[0];
for(uint8_t i=0;i<freq[1];i++) { result+=10;  } 
for(uint8_t i=0;i<freq[2];i++) { result+=100;  } 
for(uint8_t i=0;i<freq[3];i++) { result+=1000;  }
for(uint8_t i=0;i<freq[4];i++) { result+=10000;  }
for(uint8_t i=0;i<freq[5];i++) { result+=100000;  } 
for(uint8_t i=0;i<freq[5];i++) { result+=1000000;  } 
}
 
 
uint8_t *GetDVDCDigitsFromUint32_t( uint32_t in)  //"uint24_t" 
{
 uint8_t digits[5];
    /*
    digits[0]=(uint8_t)(in/100000) ;  in=in%100000;     
    digits[1]=(uint8_t)(in/10000) ;  in=in%10000;  
    digits[2]=(uint8_t)(in/1000) ;  in=in%1000;
    digits[3]=(uint8_t)(in/100) ;  in=in%100;
    digits[4]=(uint8_t)(in/10) ;  in=in%10;
    digits[5]=(uint8_t) (in);
        */    
   digits[0]=(uint8_t) divmod(  in , 0x000186A0 /*100000*/ ,  &in );
   digits[1]=(uint8_t) divmod(  in , 0x00002710 /*10000*/,  &in );
   digits[2]=(uint8_t) divmod(  in , 0x000003e8 /*1000*/,  &in );
   digits[3]=(uint8_t) divmod(  in , 0x00000064 /*100*/,  &in );
   digits[4]=(uint8_t) divmod(  in , 0x0000000A /*10*/,  &in ); 
   digits[5]=(uint8_t) divmod(  in , 0x00000001 /* 1*/ ,  &in );   
     
     
return (uint8_t *) digits;  
}
 
 
uint8_t * GetCoeffDPKD(uint8_t freq[7] ,  uint8_t *compfreq)
{
 
 
/*  Kddpkd_num= freq*Kd/5)  for f= 1.25 kHz
 Kddpkd_num=freq*Kd/4  for f=1 kHz
*/
  
      
 uint32_t FreqValue= freq_fromdigits_div10(freq);
 if(FreqValue<=639999 ){               640 000...1 279 998‬
 if( FreqValue>=320000){
*compfreq=FREQ1_25kHz                                   
return (uint8_t *)  GetDVDCDigitsFromUint32_t(  (uint32_t)(FreqValue <<1)    ); //Kddpkd=  freq/5=(freq/10)  *2 ; 
}}
             
 
 
 if( FreqValue<=319999){
 if(FreqValue>=160000 ){               640 000...1 279 996‬
 *compfreq=FREQ1_25kHz                                   
return (uint8_t *)  GetDVDCDigitsFromUint32_t(  (uint32_t)(FreqValue <<2)    );  // Kddpkd=  (freq*2 /5);   =(freq/10)  *4 ; 
}}
 /* *************** */            
 FreqValue= freq_fromdigits (freq);
 if(FreqValue<=1599999 ){               
 if( FreqValue>=800000){
   *compfreq=FREQ1kHz                                      
return (uint8_t *)  GetDVDCDigitsFromUint32_t( FreqValue ); //Kddpkd=  freq ; 
}}
 
 if(FreqValue<=799999 ){               
 if( FreqValue>=400000){
   *compfreq=FREQ1kHz                                      
return (uint8_t *)  GetDVDCDigitsFromUint32_t( (uint32_t)(FreqValue<<1) );   //  Kddpkd=  freq*2 ;
}}
 
 if(FreqValue<=399999 ){               
 if( FreqValue>=200000){
   *compfreq=FREQ1kHz                                      
return (uint8_t *)  GetDVDCDigitsFromUint32_t( (uint32_t)(FreqValue<<2) );  // Kddpkd=  freq*4 ;
}}
 
 if(FreqValue<=199999 ){               
 if( FreqValue>=140000){
   *compfreq=FREQ1kHz                                      
return (uint8_t *)  GetDVDCDigitsFromUint32_t( (uint32_t)(FreqValue<<3) ); // Kddpkd=  freq*8 ;
}} 
/********************************** mixer on  *******************************/
 if(FreqValue<=139999 ){               
 if( FreqValue>=1000){
*compfreq=FREQ1kHz                                      
return (uint8_t *)  GetDVDCDigitsFromUint32_t( (uint32_t)(FreqValue+1000000 )); // Kddpkd=  freq ;
}} 
 
 return 0;
}
Добавлено через 1 минуту
К подпрограмме выработки кодов ДДПКД .
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
30.03.2020, 00:03  [ТС]
Подборка некоторых файлов по теме (могут быть с багами ), программы нормализации, индикации , некоторые программы выработки еще не готовы .
Вложения
Тип файла: zip subroutines.zip (419.6 Кб, 8 просмотров)
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
30.03.2020, 00:25  [ТС]
Для нормальной работы стека и 11 ячеек памяти потребуется не менее 1К байт памяти.
Мерцание выбранного (до адресации прибора) разряда выбранного режима при переходе прибора в состояние СПАД или СПАК не выключается, пока в состоянии СПАК не будет принят байт запятой на исполнение команды .
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
31.03.2020, 11:46  [ТС]
Возможный метод умножения на 10 на основе сдвига (для умножения на 100 повторить 2 раза)
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <stdint.h>
 
 
using namespace std; 
 
int main()
{
uint8_t byte1,byte2;
int data; 
scanf("%d",&data);
byte1=(uint8_t) data;  
scanf("%d",&data); 
byte2=(uint8_t) data;  
uint16_t byte=byte1*10+byte2;
 
 
 printf("\n %d", byte);  
 
uint16_t  byte3= (byte <<3)+ (byte <<1);  // y=x*8+x*2
printf("\n %d", byte3);
 
}
Добавлено через 15 секунд
Возможный метод умножения на 10 на основе сдвига (для умножения на 100 повторить 2 раза)
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <stdint.h>
 
 
using namespace std; 
 
int main()
{
uint8_t byte1,byte2;
int data; 
scanf("%d",&data);
byte1=(uint8_t) data;  
scanf("%d",&data); 
byte2=(uint8_t) data;  
uint16_t byte=byte1*10+byte2;
 
 
 printf("\n %d", byte);  
 
uint16_t  byte3= (byte <<3)+ (byte <<1);  // y=x*8+x*2
printf("\n %d", byte3);
 
}
Добавлено через 30 секунд
(для АМ)
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
31.03.2020, 12:03  [ТС]
Информация на тему BCDHex (про скобки и умножение, но у нас "лонговые" типы в проблемном месте для семибитного , для АМ , ЧМ и выхода проще ).
Миниатюры
Замена  микросхемы 1827ВЕ1-0000000 в Г4-164 на AVR -МК  
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
31.03.2020, 12:23  [ТС]
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using namespace std; 
 
int main()
{
uint8_t byte1,byte2;
int data; 
scanf("%d",&data);
byte1=(uint8_t) data;  
scanf("%d",&data); 
byte2=(uint8_t) data;  
uint16_t byte=byte1*10+byte2;
 
 
 printf("\n %d", byte);  
 
 //mul10{
 
 //uint16_t  byte3= (byte <<3)+ (byte <<1);
  uint16_t byte3=(byte <<1);
  byte3+=(byte3 <<2);
//}
 
 
printf("\n %d", byte3);
 
}
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
31.03.2020, 21:43  [ТС]
При вводе цифры выбранного режима с клавиатуры индицирует ее начиная с правого знакоместа,
предыдущие цифры сдвигает влево .


После нормализации по частоте выводит частоту в мегегерцах , 3 знака после запятой , если от 160,000 МГц до 639,999 МГц
(частота сравнения 1,25 кГц) , если ниже - 4 знака после запятой (частота сравнения ФАПЧ 1 кГц), гашение незначащих нулей перед запятой , кроме разряда ,
в котором запятая (например, 0.4650 МГц ) .
При вводе не всех знаков после запятой остальные дополняются нулями .


1.1 МГц -> 1.1000 МГц.

15.2 МГц ->15.2000 MHz нуль перед 1 выключается, но в буфер записывается.

159.9999 МГц 4 знака после запятой .

160.000[0] 3 знака после запятой (один правый разряд выключается ).
639.999[0]


100.0 kHz ->0.1000 МГц
>640 MHz- цифры записываются в буфер , после нажатия МГц цифры остаются остается предыдущее
<0.1000 МГц (после нажатия МГц )цифры остаются предыдущие .

Добавлено через 16 минут
ЧМ перестраивается через 5 единиц младшего разряда (0.00 кГц ... 995. кГц с ограничением сверху для каждого поддиапазона и переключением положения запятой ) или через единицу мигающего разряда для более старших разрядов .
Например , на 20 МГц при ЧМ 100 кГц не вводится, при перестройке от 40 МГц до 39,9999 МГц включаются три прочерка .

АМ вводится от 0. до 99. % .

При вводе напряжения 1.000 мВ вводится 1000 мкВ и обрабатывается как 1000 мкВ , меньше 0.032 мкВ и больше 1000 мВ не вводится, +6 дБ (в 2 раза ) включается и выключается отдельной кнопкой через отдельный пин и хранится независимо в отдельном регистре, инкрементируется- декрементируется через единицу последнего разряда минимально (или с шагом единицы мигающего разряда или с шагом, введенным в режиме шага.)

Шаг по частоте вводится в килогерцах.
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
02.04.2020, 15:23  [ТС]
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#define lowbyte(x)   ( (uint8_t)((x) & 0xFF))
#define highbyte(x)   ( (uint8_t)(((x)>>8) & 0xFF))
#define pin_test_(pinreg, bit) ((pinreg) & (1 << (bit))) // test for pin in PORTn
#define bit_test(byte,bit) ((byte) & (1 << (bit))) // test for bit set
 
 
 
void   SendDAC_AM_VRefCoefs(uint16_t DACVref ,  uint16_t DACAM  ) 
{ 
//  ; DACVref reg_byte1, reg_byte0 ,  DACAM   reg_byte3,reg_byte2 
 /*
; for send 0  to the trigger AM/Vref  set 1   on the pin 34 and send SyncAM pulse 
;send DAC Vref 0...9 coefs , 1000= 0x03e8=0b 0000 0011 1110 1000 
 ; db1=DACVref ; 
 
;   bit 0 DAC VRef, reg_byte0,  LSB 
;   bit 1 DAC VRef  
;   bit 2 DAC VRef 
;   bit 3 DAC VRef
;   bit 4 DAC VRef 
;   bit 5 DAC VRef 
;   bit 6 DAC VRef  
;   bit 7 DAC VRef  
 
;   bit 8 DAC VRef reg_byte1, LSB
;   bit 9 DAC VRef 
 
 ;  bit 0 DAC AM , reg_byte2, LSB
 ;  bit 1 DAC AM
 ;  bit 2 DAC AM
 ;  bit 3 DAC AM
 ;  bit 4 DAC AM
 ;  bit 5 DAC AM
 ;  bit 6 DAC AM
 ;  bit 7 DAC AM
 
 ;  bit 8 DAC AM reg_byte3, LSB
 ;  bit 9 DAC AM
*/
 
Sendnbits_nInform_0If_nthBit_is1( lowbyte(DACVref), ADDR_AM_VREF, 0x08);
Sendnbits_nInform_0If_nthBit_is1( highbyte(DACVref), ADDR_AM_VREF, 0x02);
 
//;send DAC AM coeffs 0...9
//; send DAC Vref 0...9 coefs 
Sendnbits_nInform_0If_nthBit_is1( lowbyte(DACAM), ADDR_AM_VREF, 0x08);
Sendnbits_nInform_0If_nthBit_is1(highbyte(DACAM), ADDR_AM_VREF, 0x02);
 
// ;  20 pulses StrobeSyncAM 
}
Добавлено через 2 минуты
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//in the  PROGMEM
uint8_t IndTableInvCode[16]  =
{
 0b10001000 , 0b11101101,0b10010100,0b10000101,0b10100001,0b10000011,0b10000010, 0b10101101,0b10000000, 0b10000001 ,
 0b1111011, 0b11111111 ,0b11111111,0b11111111,0b11111111,0b11111111
};
 
uint8_t  SevenSegment( uint8_t Digit, uint8_t Comma )  
{
/*
;
;LSB  e; c; b; d; f; g; a; h  MSB
;     a 
;b        c
;     d
;e        f
;     g
;              h
;1 on the inform bus means turn on segment
;                                          ecbdfga; 
; 
*/
 
uint8_t tmp= IndTableInvCode[Digit];
if(Comma!=0) {  return (IndTableInvCode[Digit]&0b01111111);        } //h  
 return (uint8_t) IndTableInvCode[(uint8_t)Digit];
}
 
 
 
void  SendBitsBlink( uint8_t BitsAddrBlink)    
 {
/*
; first sent bit 3  2   1  0 last sent bit 
; for 1 on the inform bus send 0 to pin 34 ( and send strobe after it )
*/
Send_nInformBit_1_IfByteFalse(  bit_test(BitsAddrBlink,3)    ) ;
SendStrobeSync(ADDR_SYNCBLINK );
Send_nInformBit_1_IfByteFalse(  bit_test(BitsAddrBlink,2)    ) ;
SendStrobeSync(ADDR_SYNCBLINK );
Send_nInformBit_1_IfByteFalse(  bit_test(BitsAddrBlink,1)   ) ;
SendStrobeSync(ADDR_SYNCBLINK );
Send_nInformBit_1_IfByteFalse( bit_test(BitsAddrBlink,0)    ) ;
SendStrobeSync(ADDR_SYNCBLINK );
//; without SyncWRRAM pulse , use after send all digits for blink control with TurnOnBlink(),TurnOffBlink(); 
}
 
 
 
void SendBitsRAM(uint8_t BitsAddr, uint8_t Digit , uint8_t BitComma/*,  uint8_t BitsBlink*/)
{ 
/*
;
;     a 
;b        c
;     d
;e        f
;     g
 ;             h
;1 on the inform bus means turn on segment
;
;Inform n8; n4; n2 ; n1 ; e; c; b; d; f; g; a; h;
;
;
;0 1 2 3 4 5 6      7 8 9         a b      c d e f      Addr
;f  e d c b  a 9      8 7 6        5 4      3 2 1 0   ~Addr
;x x x x x x x      x x x         x x      x x x x ;
; Digit  reg_byte0 ,   Comma reg_byte1
; send address bit using inverse code  
;  for set 1 on the bit Inform set 0 on the nInform (for pin 34 emulation )   
; for set 0 on the bit Inform set 1 on the nInform (for pin 34 emulation )    
*/
uint8_t byte= SevenSegment() ;  
Send_nInformBit_1_IfByteFalse( bit_test(BitsAddr ,3)  ) ;  //  addr 8 
SendStrobeSync(ADDR_SYNCRAM ); //1
Send_nInformBit_1_IfByteFalse(  bit_test(BitsAddr ,2)    ) ;  //  addr 4   
SendStrobeSync(ADDR_SYNCRAM ); //2 
Send_nInformBit_1_IfByteFalse(  bit_test(BitsAddr ,1)    ) ;  //  addr 2   
SendStrobeSync(ADDR_SYNCRAM ); //3  
Send_nInformBit_1_IfByteFalse(  bit_test(BitsAddr ,0)    ) ;  //  addr 1   
SendStrobeSync(ADDR_SYNCRAM ); //4   
 
 
/* for turn on segment set 1  on the Inform Bus, set nIform(34)=0,  as the output */
Sendnbits_nInform_0If_nthBit_is1( byte, ADDR_SYNCRAM , 0x08);
SendMemWrRAMPulse() ; 
 
 
/*
0 e LSB
1 c
2 b 
3 d
4 f
5 g
6 a
7 h
 
*/
 
 
 
 
 
return;
}
Добавлено через 46 минут
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//call before  check_digit 
 
 
 
 
 
void CheckComma(uint8_t byte , uint8_t  count, uint8_t *CommaSet, uint8_t *CommaPos    )
{
if ((byte==TOKEN_DOT)&&(*CommaSet!=1)   )//fix 
{
if (count==0) { digits[0]=0; }   //set zero before comma in the  firsf digit of stack 
*CommaPos= count;
*CommaSet=1;
return  ;  //commaPos= count , no comma enter after, without  counter increment 
}
 
return  ; //return  
}
 
// call if digit was entered
uint8_t AppendDigit(uint8_t byte ,uint8_t *count, ndigits   )  // ndigits  7 for freq , 3 for  FM,2 for AM, 4  for  Vout    
{
if (count<ndigits )
{
digits[count]=byte;  // from shared variables in the ram (7...8 digits max , first byte is  MSB ), temporary stack of digits  
*count+=1;
return 0 ;
}
else { return 1; } //flag stop , no digits more 
}
 
 
/*        may be in the sharedvals.h    with uint8_t digits[7]   , data before normalisation , counter of entered digits for normaliser and comma position  register */
uint8_t count=0; //reset if call new mode for invalidate data in the "stack" of the digits 
uint8_t CommaSet=0; //reset  if call new mode , no change  if '.'(or  token ',' from keyboard ) was entered , temporary variable 
uint8_t IfNumDigit(uint8_t byte , uint8_t ndigits, uint8_t *CommaPos, uint8_t *count)
{
CheckComma( byte , count, &CommaSet,  CommaPos);
return AppendDigit( byte ,count, ndigits   );
}
Добавлено через 1 час 10 минут
Проверка элементов программы выработки кодов управления установкой выходного уровня
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Gccapp1.c
 *
 * Created: 20.03.2020 02:09:14
 * Author : USERPC01
 */ 
 
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <math.h>
#include "vrefparser.h"
 #define low_byte(x)   ( (uint8_t)(((x)>>0) & 0xFF))
 #define high_byte(x)   ( (uint8_t)(((x)>>8) & 0xFF))
 
int main(void)
{
     
       
      //uint8_t mode_out =TOKEN_Out_dB;
    //  uint8_t mode_out =TOKEN_Out_mV;
       uint8_t mode_out =TOKEN_Out_mkV;
      uint8_t digit[7];
      
     main1: 
       digit[0]=0x00;
      digit[1]=0x09;
       digit[2]=0x09;
        digit[3]=0x09;
        uint8_t commapos=COMMA_4DIGIT;
        uint8_t attcode;
        
        uint16_t Value=GetDACValue(  digit , commapos,  &attcode ,   mode_out);
        
        
        
        PORTA=attcode;
        PORTB=low_byte(Value);
        PORTC=high_byte(Value);
        
        
      while (1) 
    {
         
     goto main1;
     
    
 
    
    
    
   
   
    
     
        
        
    }
}
Добавлено через 1 минуту
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
//#include "tables.h"
#include <avr/pgmspace.h>
#include <math.h>
//ParseCodesAtt() ; 
 
//void  SendAttBits(uint8 _t  natt_data ,  uint8_t FlagOff )  ;
 
/*   vrefparser.h   */
 
 
#define  nATT_0_dB  (uint8_t) ~(0b11110000)
#define  nATT_10_dB (uint8_t) ~(0b11100001)
#define  nATT_20_dB (uint8_t) ~(0b11010010)
#define  nATT_30_dB  (uint8_t) ~(0b11000011)
#define  nATT_40_dB (uint8_t)  ~(0b10110100)
#define  nATT_50_dB  (uint8_t) ~(0b10100101)
#define  nATT_60_dB  (uint8_t) ~(0b10010110)
#define  nATT_70_dB  (uint8_t) ~(0b10000111)
#define  nATT_80_dB  (uint8_t) ~(0b01111000)
#define  nATT_90_dB  (uint8_t) ~(0b01101001)
#define  nATT_100_dB (uint8_t)  ~(0b01011010)
#define  nATT_110_dB  (uint8_t) ~(0b01001011)
#define  nATT_120_dB  (uint8_t) ~(0b00111100)
#define  nATT_130_dB  (uint8_t)  ~(0b00101101)
#define  nATT_140_dB  (uint8_t) ~(0b00011110)
 
 
#define   ATT_0_dB_10dBFlag 0
#define   ATT_10_dB_10dBFlag 1
#define   ATT_20_dB_10dBFlag 0
#define  ATT_30_dB_10dBFlag  1
#define   ATT_40_dB_10dBFlag  0
#define   ATT_50_dB_10dBFlag  1
#define   ATT_60_dB_10dBFlag 0
#define   ATT_70_dB_10dBFlag 1
#define  ATT_80_dB_10dBFlag  0
#define   ATT_90_dB_10dBFlag  1
#define   ATT_100_dB_10dBFlag 0
#define   ATT_110_dB_10dBFlag  1
#define   ATT_120_dB_10dBFlag  0
#define   ATT_130_dB_10dBFlag   1
#define   ATT_140_dB_10dBFlag  0
 
 
#define TOKEN_Out_dB 1
#define TOKEN_Out_mV 2
#define TOKEN_Out_mkV 3
 
 
#define COMMA_4DIGIT 3
#define COMMA_3DIGIT 2
#define COMMA_2DIGIT 1
#define COMMA_1DIGIT 0
 
 
 
 
 const uint16_t  LogTable1[100]   PROGMEM =
{
  0x03e8,  0x03dd,  0x03d1,  0x03c6,  0x03bb,  0x03b0,  0x03a5,  0x039b,  0x0390,  0x0386 ,  /* 0.0-0.9   */
 0x037b,  0x0371,  0x0367,  0x035d,  0x0353,  0x0349,  0x0340,  0x0336,  0x032d,  0x0324 ,   /* 1.0-1.9   */
 0x031a,  0x0311,  0x0308,  0x02ff,  0x02f7,  0x02ee,  0x02e5,  0x02dd,  0x02d4,  0x02cc ,      /* 2.0-2.9   */
  0x02c4,  0x02bc,  0x02b4,  0x02ac,  0x02a4,  0x029c,  0x0295,  0x028d,  0x0286,  0x027e,   /* 3.0-3.9   */
  0x0277,  0x0270,  0x0269,  0x0262,  0x025b,  0x0254,  0x024d,  0x0246,  0x023f,  0x0239 ,  /* 4.0-4.9   */
  0x0232,  0x022c,  0x0226,  0x021f,  0x0219,  0x0213,  0x020d,  0x0207,  0x0201,  0x01fb ,    /* 5.0-5.9   */
  0x01f5,  0x01ef,  0x01ea,  0x01e4,  0x01df,  0x01d9,  0x01d4,  0x01ce,  0x01c9,  0x01c4 ,      /* 6.0-6.9   */
  0x01bf,  0x01ba,  0x01b5,  0x01b0,  0x01ab,  0x01a6,  0x01a1,  0x019c,  0x0197,  0x0193,     /* 7.0-7.9   */
  0x018e,  0x018a,  0x0185,  0x0181,  0x017c,  0x0178,  0x0174,  0x016f,  0x016b,  0x0167 ,   /* 8.0-8.9   */
  0x0163,  0x015f,  0x015b,  0x0157,  0x0153,  0x014f,  0x014b,  0x0147,  0x0144,  0x0140     /* 9.0-9.9   */
} ;
 
//read  using uint16_t word=pgm_read_word_near(LinTable316 + k);   k=316-u
const uint16_t  LinTable316[216] PROGMEM= 
{
 0x03e7,  0x03e4,  0x03e1,  0x03de,  0x03db,  0x03d8,  0x03d4,  0x03d1,  0x03ce,  0x03cb,  /* 0-9   ,  316,315...307*/
 0x03c8,  0x03c5,  0x03c1,  0x03be,  0x03bb,  0x03b8,  0x03b5,  0x03b2,  0x03ae,  0x03ab , /* 10-19,  306,305...297 */
 0x03a8,  0x03a5,  0x03a2,  0x039f,  0x039b,  0x0398,  0x0395,  0x0392,  0x038f,  0x038c,   /* 20-29 ,  296,295...287*/
 0x0388,  0x0385,  0x0382,  0x037f,  0x037c,  0x0379,  0x0376,  0x0372,  0x036f,  0x036c, /* 30-39,  286,285...277 */
 0x0369,  0x0366,  0x0363,  0x035f,  0x035c,  0x0359,  0x0356,  0x0353,  0x0350,  0x034c, /* 40-49,  276,275...267 */
 0x0349,  0x0346,  0x0343,  0x0340,  0x033d,  0x0339,  0x0336,  0x0333,  0x0330,  0x032d, /* 50-59,  266,265...257 */
 0x032a,  0x0326,  0x0323,  0x0320,  0x031d,  0x031a,  0x0317,  0x0313,  0x0310,  0x030d ,/* 60-69 ,  256,255...247*/
 0x030a,  0x0307,  0x0304,  0x0301,  0x02fd,  0x02fa,  0x02f7,  0x02f4,  0x02f1,  0x02ee, /* 70-79 ,  246,245...237*/
 0x02ea,  0x02e7,  0x02e4,  0x02e1,  0x02de,  0x02db,  0x02d7,  0x02d4,  0x02d1,  0x02ce, /* 80-89,  236,235...227 */
 0x02cb,  0x02c8,  0x02c4,  0x02c1,  0x02be,  0x02bb,  0x02b8,  0x02b5,  0x02b1,  0x02ae, /* 90-99 ,  226,225...217*/
 
 0x02ab,  0x02a8,  0x02a5,  0x02a2,  0x029e,  0x029b,  0x0298,  0x0295,  0x0292,  0x028f , /* 100-109,  216,215...207 */
 0x028b,  0x0288,  0x0285,  0x0282,  0x027f,  0x027c,  0x0279,  0x0275,  0x0272,  0x026f , /* 110-119 ,  206,205...197 */
 0x026c,  0x0269,  0x0266,  0x0262,  0x025f,  0x025c,  0x0259,  0x0256,  0x0253,  0x024f , /* 120-129 ,  196,195...187 */
 0x024c,  0x0249,  0x0246,  0x0243,  0x0240,  0x023c,  0x0239,  0x0236,  0x0233,  0x0230 , /* 130-139 ,  186,185...177 */
 0x022d,  0x0229,  0x0226,  0x0223,  0x0220,  0x021d,  0x021a,  0x0216,  0x0213,  0x0210 , /* 140-149 ,  176,175...167 */
 0x020d,  0x020a,  0x0207,  0x0203,  0x0200,  0x01fd,  0x01fa,  0x01f7,  0x01f4,  0x01f1 ,      /* 150-159,  166,165...157  */
 0x01ed,  0x01ea,  0x01e7,  0x01e4,  0x01e1,  0x01de,  0x01da,  0x01d7,  0x01d4,  0x01d1 , /* 160-169,  156,155...147  */
 0x01ce,  0x01cb,  0x01c7,  0x01c4,  0x01c1,  0x01be,  0x01bb,  0x01b8,  0x01b4,  0x01b1, /* 170-179,  146,145...137  */
 0x01ae,  0x01ab,  0x01a8,  0x01a5,  0x01a1,  0x019e,  0x019b,  0x0198,  0x0195,  0x0192, /* 180-189,  136,135...127  */
 0x018e,  0x018b,  0x0188,  0x0185,  0x0182,  0x017f,  0x017c,  0x0178,  0x0175,  0x0172, /* 190-199,  126,125...117 */
 
 0x016f,  0x016c,  0x0169,  0x0165,  0x0162,  0x015f,  0x015c,  0x0159,  0x0156,  0x0152 ,  /* 200-209 ,   116,115...107*/
 0x014f,  0x014c,  0x0149,  0x0146,  0x0143,  0x013f    /* 210-215 ,   106,105...101 */
}; 
 
 
 
uint16_t  GetDACValue_dBV( uint16_t Value_dBV    ,  uint8_t  *attcode      )
{
 
  
if(Value_dBV>=0){   
if(Value_dBV<=99){
*attcode=nATT_0_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV))  ;
 }}
 
if(Value_dBV>=100){
if(Value_dBV<=199){
 
*attcode=nATT_10_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-100))  ;
 }} 
if(Value_dBV>=200){
if(Value_dBV<=299){
 
*attcode=nATT_20_dB; 
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-200))  ; 
 }}
if(Value_dBV>=300){
if(Value_dBV<=399){
 
*attcode=nATT_30_dB; 
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-300))  ; 
 }}
 
if(Value_dBV>=400){
if(Value_dBV<=499){
 
*attcode=nATT_40_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-400))  ;  
 }}
 
if(Value_dBV>=500){
if(Value_dBV<=599){
 
*attcode=nATT_50_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-500))  ;  
 }}
 
if(Value_dBV>=600){
if(Value_dBV<=699){
 
*attcode=nATT_60_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-600))  ; 
 }}
 
if(Value_dBV>=700){
if(Value_dBV<=799){
 
*attcode=nATT_70_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-700))  ;  
 }}
 
if(Value_dBV>=800){
if(Value_dBV<=899){
 
*attcode=nATT_80_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-800))  ; 
 }}
if(Value_dBV>=900){
if(Value_dBV<=999){
 
*attcode=nATT_90_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-900))  ;  
 }}
 
if(Value_dBV>=1000){
if(Value_dBV<=1099){
 
*attcode=nATT_100_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1000))  ;  
 }}
 
if(Value_dBV>=1100){
if(Value_dBV<=1199){
 
*attcode=nATT_110_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1100))  ; 
 }}
 
 
if(Value_dBV>=1200){
if(Value_dBV<=1299){
 
*attcode=nATT_120_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1200))  ; 
 }}
if(Value_dBV>=1300){
if(Value_dBV<=1399){
 
*attcode=nATT_130_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1300))  ; 
 }}
 
if(Value_dBV>=1400){
if(Value_dBV<=1499){
 
*attcode=nATT_0_dB;
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1400))  ; 
 }}
 
 
return 0x0000;
}
 
 
 
uint16_t  GetDACValue_mV( uint16_t Value_mV    , uint8_t commapos,  uint8_t  *attcode      )
{
 
 
if(Value_mV>=317){      //1000. ...317. mV
if(Value_mV<=1000){
if(commapos==COMMA_4DIGIT){   *attcode=nATT_0_dB; }  //1000. ...317. mV
if(commapos==COMMA_3DIGIT){   *attcode=nATT_20_dB; }//100.0  ...31.7 mV
if(commapos==COMMA_2DIGIT){   *attcode=nATT_40_dB; }//10.00  ...3.17 mV
return (uint16_t )  Value_mV     ;
 }}
 
 if(Value_mV>=101){   //101. ...316.
if(Value_mV<=316){
if(commapos==COMMA_4DIGIT){   *attcode=nATT_10_dB; } //316. ...101. mV
if(commapos==COMMA_3DIGIT){   *attcode=nATT_30_dB; } //31.6  ...10.1  mV
if(commapos==COMMA_2DIGIT){   *attcode=nATT_50_dB; } //3.16  ...1.01  mV
 
//[0]  +(uint16_t) (316-Value_mV)
return (uint16_t )  pgm_read_word_near(LinTable316+(uint16_t)(316-Value_mV))        ;
 }}
 
return 0;  
}
 
 
 
 
uint16_t  GetDACValue_mkV( uint16_t Value_mkV    , uint8_t commapos,  uint8_t  *attcode      )
{
 
 
 
if(Value_mkV>=317){      //1000. ...317. mkV
if(Value_mkV<=1000){
if(commapos==COMMA_4DIGIT){   *attcode=nATT_60_dB; }  //1000. ...317. uV
if(commapos==COMMA_3DIGIT){   *attcode=nATT_80_dB; }//100.0  ...31.7 uV
if(commapos==COMMA_2DIGIT){   *attcode=nATT_100_dB; }//10.00  ...3.17 uV
if(commapos==COMMA_1DIGIT){   *attcode=nATT_120_dB; }//1.000  ...0.317 uV 
return (uint16_t )  Value_mkV     ;
 }}
 
 if(Value_mkV>=101){   //101. ...316. mkV
if(Value_mkV<=316){
if(commapos==COMMA_4DIGIT){   *attcode=nATT_70_dB; } //316. ...101. uV
if(commapos==COMMA_3DIGIT){   *attcode=nATT_90_dB; } //31.6  ...10.1  uV
if(commapos==COMMA_2DIGIT){   *attcode=nATT_110_dB; } //3.16  ...1.01  uV
if(commapos==COMMA_1DIGIT){   *attcode=nATT_130_dB; }//0.316  ...0.101 uV  
return (uint16_t ) pgm_read_word_near(LinTable316 +(uint16_t)  (316-Value_mkV))      ;
 }}
 
if(Value_mkV>=32){   //0.100 ... 0.032 mkV
if(Value_mkV<=100){
if(commapos==COMMA_1DIGIT){   *attcode=nATT_140_dB; }//0.100  ...0.032 uV  
 
return (uint16_t )    (Value_mkV*10);  
 }}
 
 
return 0;  
 
}
 
uint16_t GetOutValueFromDigits ( uint8_t val[7])
{
    uint16_t result=0;
    result+=(uint16_t) val[3];
    for(uint8_t i=0;i<val[2];i++) { result+=10;  }
    for(uint8_t i=0;i<val[1];i++) { result+=100;  }
    for(uint8_t i=0;i<val[0];i++) { result+=1000;  }
 return result;
}
 
 
 
 
uint16_t GetDACValue ( uint8_t digits[4], uint8_t commapos,  uint8_t  *attcode , uint8_t mode    )
{
uint16_t  Value ;
Value=GetOutValueFromDigits(digits);  //0032...1000
if(mode==TOKEN_Out_dB)  {  return   GetDACValue_dBV(Value, attcode );  } 
if(mode==TOKEN_Out_mkV)  { return GetDACValue_mkV( Value, commapos, attcode);   } 
if(mode==TOKEN_Out_mV)  {   return GetDACValue_mV(  Value, commapos,attcode );  } 
return 0;
}
Добавлено через 1 минуту
Подпрограмма выработки кодов ЦАП выполнилась при 12 МГц примерно за 19,58 ...20 мкс.
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
02.04.2020, 15:27  [ТС]
Пример для испытания подпрограммы .
Вложения
Тип файла: zip Gccapp5.zip (58.2 Кб, 6 просмотров)
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
02.04.2020, 15:29  [ТС]
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
Gccapp1.elf:     file format elf32-avr
 
Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         0000070e  00000000  00000000  00000054  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         00000000  00800060  00800060  00000762  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  2 .comment      00000030  00000000  00000000  00000762  2**0
                  CONTENTS, READONLY
  3 .note.gnu.avr.deviceinfo 0000003c  00000000  00000000  00000794  2**2
                  CONTENTS, READONLY
  4 .debug_aranges 00000048  00000000  00000000  000007d0  2**0
                  CONTENTS, READONLY, DEBUGGING
  5 .debug_info   00000bda  00000000  00000000  00000818  2**0
                  CONTENTS, READONLY, DEBUGGING
  6 .debug_abbrev 00000692  00000000  00000000  000013f2  2**0
                  CONTENTS, READONLY, DEBUGGING
  7 .debug_line   0000057f  00000000  00000000  00001a84  2**0
                  CONTENTS, READONLY, DEBUGGING
  8 .debug_frame  00000098  00000000  00000000  00002004  2**2
                  CONTENTS, READONLY, DEBUGGING
  9 .debug_str    00000397  00000000  00000000  0000209c  2**0
                  CONTENTS, READONLY, DEBUGGING
 10 .debug_loc    0000086c  00000000  00000000  00002433  2**0
                  CONTENTS, READONLY, DEBUGGING
 11 .debug_ranges 00000038  00000000  00000000  00002c9f  2**0
                  CONTENTS, READONLY, DEBUGGING
 
Disassembly of section .text:
 
00000000 <__vectors>:
   0:   0c 94 66 01     jmp 0x2cc   ; 0x2cc <__ctors_end>
   4:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
   8:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
   c:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  10:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  14:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  18:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  1c:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  20:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  24:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  28:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  2c:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  30:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  34:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  38:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  3c:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  40:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  44:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  48:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  4c:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
  50:   0c 94 70 01     jmp 0x2e0   ; 0x2e0 <__bad_interrupt>
 
00000054 <LinTable316>:
  54:   e7 03 e4 03 e1 03 de 03 db 03 d8 03 d4 03 d1 03     ................
  64:   ce 03 cb 03 c8 03 c5 03 c1 03 be 03 bb 03 b8 03     ................
  74:   b5 03 b2 03 ae 03 ab 03 a8 03 a5 03 a2 03 9f 03     ................
  84:   9b 03 98 03 95 03 92 03 8f 03 8c 03 88 03 85 03     ................
  94:   82 03 7f 03 7c 03 79 03 76 03 72 03 6f 03 6c 03     ....|.y.v.r.o.l.
  a4:   69 03 66 03 63 03 5f 03 5c 03 59 03 56 03 53 03     i.f.c._.\.Y.V.S.
  b4:   50 03 4c 03 49 03 46 03 43 03 40 03 3d 03 39 03     P.L.I.F.C.@.=.9.
  c4:   36 03 33 03 30 03 2d 03 2a 03 26 03 23 03 20 03     6.3.0.-.*.&.#. .
  d4:   1d 03 1a 03 17 03 13 03 10 03 0d 03 0a 03 07 03     ................
  e4:   04 03 01 03 fd 02 fa 02 f7 02 f4 02 f1 02 ee 02     ................
  f4:   ea 02 e7 02 e4 02 e1 02 de 02 db 02 d7 02 d4 02     ................
 104:   d1 02 ce 02 cb 02 c8 02 c4 02 c1 02 be 02 bb 02     ................
 114:   b8 02 b5 02 b1 02 ae 02 ab 02 a8 02 a5 02 a2 02     ................
 124:   9e 02 9b 02 98 02 95 02 92 02 8f 02 8b 02 88 02     ................
 134:   85 02 82 02 7f 02 7c 02 79 02 75 02 72 02 6f 02     ......|.y.u.r.o.
 144:   6c 02 69 02 66 02 62 02 5f 02 5c 02 59 02 56 02     l.i.f.b._.\.Y.V.
 154:   53 02 4f 02 4c 02 49 02 46 02 43 02 40 02 3c 02     S.O.L.I.F.C.@.<.
 164:   39 02 36 02 33 02 30 02 2d 02 29 02 26 02 23 02     9.6.3.0.-.).&.#.
 174:   20 02 1d 02 1a 02 16 02 13 02 10 02 0d 02 0a 02      ...............
 184:   07 02 03 02 00 02 fd 01 fa 01 f7 01 f4 01 f1 01     ................
 194:   ed 01 ea 01 e7 01 e4 01 e1 01 de 01 da 01 d7 01     ................
 1a4:   d4 01 d1 01 ce 01 cb 01 c7 01 c4 01 c1 01 be 01     ................
 1b4:   bb 01 b8 01 b4 01 b1 01 ae 01 ab 01 a8 01 a5 01     ................
 1c4:   a1 01 9e 01 9b 01 98 01 95 01 92 01 8e 01 8b 01     ................
 1d4:   88 01 85 01 82 01 7f 01 7c 01 78 01 75 01 72 01     ........|.x.u.r.
 1e4:   6f 01 6c 01 69 01 65 01 62 01 5f 01 5c 01 59 01     o.l.i.e.b._.\.Y.
 1f4:   56 01 52 01 4f 01 4c 01 49 01 46 01 43 01 3f 01     V.R.O.L.I.F.C.?.
 
00000204 <LogTable1>:
 204:   e8 03 dd 03 d1 03 c6 03 bb 03 b0 03 a5 03 9b 03     ................
 214:   90 03 86 03 7b 03 71 03 67 03 5d 03 53 03 49 03     ....{.q.g.].S.I.
 224:   40 03 36 03 2d 03 24 03 1a 03 11 03 08 03 ff 02     @.6.-.$.........
 234:   f7 02 ee 02 e5 02 dd 02 d4 02 cc 02 c4 02 bc 02     ................
 244:   b4 02 ac 02 a4 02 9c 02 95 02 8d 02 86 02 7e 02     ..............~.
 254:   77 02 70 02 69 02 62 02 5b 02 54 02 4d 02 46 02     w.p.i.b.[.T.M.F.
 264:   3f 02 39 02 32 02 2c 02 26 02 1f 02 19 02 13 02     ?.9.2.,.&.......
 274:   0d 02 07 02 01 02 fb 01 f5 01 ef 01 ea 01 e4 01     ................
 284:   df 01 d9 01 d4 01 ce 01 c9 01 c4 01 bf 01 ba 01     ................
 294:   b5 01 b0 01 ab 01 a6 01 a1 01 9c 01 97 01 93 01     ................
 2a4:   8e 01 8a 01 85 01 81 01 7c 01 78 01 74 01 6f 01     ........|.x.t.o.
 2b4:   6b 01 67 01 63 01 5f 01 5b 01 57 01 53 01 4f 01     k.g.c._.[.W.S.O.
 2c4:   4b 01 47 01 44 01 40 01                             K.G.D.@.
 
000002cc <__ctors_end>:
 2cc:   11 24           eor r1, r1
 2ce:   1f be           out 0x3f, r1    ; 63
 2d0:   cf e5           ldi r28, 0x5F   ; 95
 2d2:   d4 e0           ldi r29, 0x04   ; 4
 2d4:   de bf           out 0x3e, r29   ; 62
 2d6:   cd bf           out 0x3d, r28   ; 61
 2d8:   0e 94 68 03     call    0x6d0   ; 0x6d0 <main>
 2dc:   0c 94 85 03     jmp 0x70a   ; 0x70a <_exit>
 
000002e0 <__bad_interrupt>:
 2e0:   0c 94 00 00     jmp 0   ; 0x0 <__vectors>
 
000002e4 <GetDACValue_dBV>:
uint16_t  GetDACValue_dBV( uint16_t Value_dBV    ,  uint8_t  *attcode      )
{
 
  
if(Value_dBV>=0){   
if(Value_dBV<=99){
 2e4:   84 36           cpi r24, 0x64   ; 100
 2e6:   91 05           cpc r25, r1
 2e8:   58 f4           brcc    .+22        ; 0x300 <GetDACValue_dBV+0x1c>
*attcode=nATT_0_dB;
 2ea:   2f e0           ldi r18, 0x0F   ; 15
 2ec:   fb 01           movw    r30, r22
 2ee:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV))  ;
 2f0:   fc 01           movw    r30, r24
 2f2:   ee 0f           add r30, r30
 2f4:   ff 1f           adc r31, r31
 2f6:   ec 5f           subi    r30, 0xFC   ; 252
 2f8:   fd 4f           sbci    r31, 0xFD   ; 253
 2fa:   85 91           lpm r24, Z+
 2fc:   94 91           lpm r25, Z
 2fe:   08 95           ret
 }}
 
if(Value_dBV>=100){
if(Value_dBV<=199){
 300:   88 3c           cpi r24, 0xC8   ; 200
 302:   91 05           cpc r25, r1
 304:   58 f4           brcc    .+22        ; 0x31c <GetDACValue_dBV+0x38>
 
*attcode=nATT_10_dB;
 306:   2e e1           ldi r18, 0x1E   ; 30
 308:   fb 01           movw    r30, r22
 30a:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-100))  ;
 30c:   fc 01           movw    r30, r24
 30e:   ee 0f           add r30, r30
 310:   ff 1f           adc r31, r31
 312:   e4 5c           subi    r30, 0xC4   ; 196
 314:   fe 4f           sbci    r31, 0xFE   ; 254
 316:   85 91           lpm r24, Z+
 318:   94 91           lpm r25, Z
 31a:   08 95           ret
 }} 
if(Value_dBV>=200){
if(Value_dBV<=299){
 31c:   8c 32           cpi r24, 0x2C   ; 44
 31e:   f1 e0           ldi r31, 0x01   ; 1
 320:   9f 07           cpc r25, r31
 322:   58 f4           brcc    .+22        ; 0x33a <GetDACValue_dBV+0x56>
 
*attcode=nATT_20_dB; 
 324:   2d e2           ldi r18, 0x2D   ; 45
 326:   fb 01           movw    r30, r22
 328:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-200))  ; 
 32a:   fc 01           movw    r30, r24
 32c:   ee 0f           add r30, r30
 32e:   ff 1f           adc r31, r31
 330:   ec 58           subi    r30, 0x8C   ; 140
 332:   ff 4f           sbci    r31, 0xFF   ; 255
 334:   85 91           lpm r24, Z+
 336:   94 91           lpm r25, Z
 338:   08 95           ret
 }}
if(Value_dBV>=300){
if(Value_dBV<=399){
 33a:   80 39           cpi r24, 0x90   ; 144
 33c:   f1 e0           ldi r31, 0x01   ; 1
 33e:   9f 07           cpc r25, r31
 340:   58 f4           brcc    .+22        ; 0x358 <GetDACValue_dBV+0x74>
 
*attcode=nATT_30_dB; 
 342:   2c e3           ldi r18, 0x3C   ; 60
 344:   fb 01           movw    r30, r22
 346:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-300))  ; 
 348:   fc 01           movw    r30, r24
 34a:   ee 0f           add r30, r30
 34c:   ff 1f           adc r31, r31
 34e:   e4 55           subi    r30, 0x54   ; 84
 350:   f0 40           sbci    r31, 0x00   ; 0
 352:   85 91           lpm r24, Z+
 354:   94 91           lpm r25, Z
 356:   08 95           ret
 }}
 
if(Value_dBV>=400){
if(Value_dBV<=499){
 358:   84 3f           cpi r24, 0xF4   ; 244
 35a:   f1 e0           ldi r31, 0x01   ; 1
 35c:   9f 07           cpc r25, r31
 35e:   58 f4           brcc    .+22        ; 0x376 <GetDACValue_dBV+0x92>
 
*attcode=nATT_40_dB;
 360:   2b e4           ldi r18, 0x4B   ; 75
 362:   fb 01           movw    r30, r22
 364:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-400))  ;  
 366:   fc 01           movw    r30, r24
 368:   ee 0f           add r30, r30
 36a:   ff 1f           adc r31, r31
 36c:   ec 51           subi    r30, 0x1C   ; 28
 36e:   f1 40           sbci    r31, 0x01   ; 1
 370:   85 91           lpm r24, Z+
 372:   94 91           lpm r25, Z
 374:   08 95           ret
 }}
 
if(Value_dBV>=500){
if(Value_dBV<=599){
 376:   88 35           cpi r24, 0x58   ; 88
 378:   f2 e0           ldi r31, 0x02   ; 2
 37a:   9f 07           cpc r25, r31
 37c:   58 f4           brcc    .+22        ; 0x394 <GetDACValue_dBV+0xb0>
 
*attcode=nATT_50_dB;
 37e:   2a e5           ldi r18, 0x5A   ; 90
 380:   fb 01           movw    r30, r22
 382:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-500))  ;  
 384:   fc 01           movw    r30, r24
 386:   ee 0f           add r30, r30
 388:   ff 1f           adc r31, r31
 38a:   e4 5e           subi    r30, 0xE4   ; 228
 38c:   f1 40           sbci    r31, 0x01   ; 1
 38e:   85 91           lpm r24, Z+
 390:   94 91           lpm r25, Z
 392:   08 95           ret
 }}
 
if(Value_dBV>=600){
if(Value_dBV<=699){
 394:   8c 3b           cpi r24, 0xBC   ; 188
 396:   f2 e0           ldi r31, 0x02   ; 2
 398:   9f 07           cpc r25, r31
 39a:   58 f4           brcc    .+22        ; 0x3b2 <GetDACValue_dBV+0xce>
 
*attcode=nATT_60_dB;
 39c:   29 e6           ldi r18, 0x69   ; 105
 39e:   fb 01           movw    r30, r22
 3a0:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-600))  ; 
 3a2:   fc 01           movw    r30, r24
 3a4:   ee 0f           add r30, r30
 3a6:   ff 1f           adc r31, r31
 3a8:   ec 5a           subi    r30, 0xAC   ; 172
 3aa:   f2 40           sbci    r31, 0x02   ; 2
 3ac:   85 91           lpm r24, Z+
 3ae:   94 91           lpm r25, Z
 3b0:   08 95           ret
 }}
 
if(Value_dBV>=700){
if(Value_dBV<=799){
 3b2:   80 32           cpi r24, 0x20   ; 32
 3b4:   f3 e0           ldi r31, 0x03   ; 3
 3b6:   9f 07           cpc r25, r31
 3b8:   58 f4           brcc    .+22        ; 0x3d0 <GetDACValue_dBV+0xec>
 
*attcode=nATT_70_dB;
 3ba:   28 e7           ldi r18, 0x78   ; 120
 3bc:   fb 01           movw    r30, r22
 3be:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-700))  ;  
 3c0:   fc 01           movw    r30, r24
 3c2:   ee 0f           add r30, r30
 3c4:   ff 1f           adc r31, r31
 3c6:   e4 57           subi    r30, 0x74   ; 116
 3c8:   f3 40           sbci    r31, 0x03   ; 3
 3ca:   85 91           lpm r24, Z+
 3cc:   94 91           lpm r25, Z
 3ce:   08 95           ret
 }}
 
if(Value_dBV>=800){
if(Value_dBV<=899){
 3d0:   84 38           cpi r24, 0x84   ; 132
 3d2:   f3 e0           ldi r31, 0x03   ; 3
 3d4:   9f 07           cpc r25, r31
 3d6:   58 f4           brcc    .+22        ; 0x3ee <GetDACValue_dBV+0x10a>
 
*attcode=nATT_80_dB;
 3d8:   27 e8           ldi r18, 0x87   ; 135
 3da:   fb 01           movw    r30, r22
 3dc:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-800))  ; 
 3de:   fc 01           movw    r30, r24
 3e0:   ee 0f           add r30, r30
 3e2:   ff 1f           adc r31, r31
 3e4:   ec 53           subi    r30, 0x3C   ; 60
 3e6:   f4 40           sbci    r31, 0x04   ; 4
 3e8:   85 91           lpm r24, Z+
 3ea:   94 91           lpm r25, Z
 3ec:   08 95           ret
 }}
if(Value_dBV>=900){
if(Value_dBV<=999){
 3ee:   88 3e           cpi r24, 0xE8   ; 232
 3f0:   f3 e0           ldi r31, 0x03   ; 3
 3f2:   9f 07           cpc r25, r31
 3f4:   58 f4           brcc    .+22        ; 0x40c <__LOCK_REGION_LENGTH__+0xc>
 
*attcode=nATT_90_dB;
 3f6:   26 e9           ldi r18, 0x96   ; 150
 3f8:   fb 01           movw    r30, r22
 3fa:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-900))  ;  
 3fc:   fc 01           movw    r30, r24
 3fe:   ee 0f           add r30, r30
 400:   ff 1f           adc r31, r31
 402:   e4 50           subi    r30, 0x04   ; 4
 404:   f5 40           sbci    r31, 0x05   ; 5
 406:   85 91           lpm r24, Z+
 408:   94 91           lpm r25, Z
 40a:   08 95           ret
 }}
 
if(Value_dBV>=1000){
if(Value_dBV<=1099){
 40c:   8c 34           cpi r24, 0x4C   ; 76
 40e:   f4 e0           ldi r31, 0x04   ; 4
 410:   9f 07           cpc r25, r31
 412:   58 f4           brcc    .+22        ; 0x42a <__LOCK_REGION_LENGTH__+0x2a>
 
*attcode=nATT_100_dB;
 414:   25 ea           ldi r18, 0xA5   ; 165
 416:   fb 01           movw    r30, r22
 418:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1000))  ;  
 41a:   fc 01           movw    r30, r24
 41c:   ee 0f           add r30, r30
 41e:   ff 1f           adc r31, r31
 420:   ec 5c           subi    r30, 0xCC   ; 204
 422:   f5 40           sbci    r31, 0x05   ; 5
 424:   85 91           lpm r24, Z+
 426:   94 91           lpm r25, Z
 428:   08 95           ret
 }}
 
if(Value_dBV>=1100){
if(Value_dBV<=1199){
 42a:   80 3b           cpi r24, 0xB0   ; 176
 42c:   f4 e0           ldi r31, 0x04   ; 4
 42e:   9f 07           cpc r25, r31
 430:   58 f4           brcc    .+22        ; 0x448 <__LOCK_REGION_LENGTH__+0x48>
 
*attcode=nATT_110_dB;
 432:   24 eb           ldi r18, 0xB4   ; 180
 434:   fb 01           movw    r30, r22
 436:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1100))  ; 
 438:   fc 01           movw    r30, r24
 43a:   ee 0f           add r30, r30
 43c:   ff 1f           adc r31, r31
 43e:   e4 59           subi    r30, 0x94   ; 148
 440:   f6 40           sbci    r31, 0x06   ; 6
 442:   85 91           lpm r24, Z+
 444:   94 91           lpm r25, Z
 446:   08 95           ret
 }}
 
 
if(Value_dBV>=1200){
if(Value_dBV<=1299){
 448:   84 31           cpi r24, 0x14   ; 20
 44a:   f5 e0           ldi r31, 0x05   ; 5
 44c:   9f 07           cpc r25, r31
 44e:   58 f4           brcc    .+22        ; 0x466 <__stack+0x7>
 
*attcode=nATT_120_dB;
 450:   23 ec           ldi r18, 0xC3   ; 195
 452:   fb 01           movw    r30, r22
 454:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1200))  ; 
 456:   fc 01           movw    r30, r24
 458:   ee 0f           add r30, r30
 45a:   ff 1f           adc r31, r31
 45c:   ec 55           subi    r30, 0x5C   ; 92
 45e:   f7 40           sbci    r31, 0x07   ; 7
 460:   85 91           lpm r24, Z+
 462:   94 91           lpm r25, Z
 464:   08 95           ret
 }}
if(Value_dBV>=1300){
if(Value_dBV<=1399){
 466:   88 37           cpi r24, 0x78   ; 120
 468:   f5 e0           ldi r31, 0x05   ; 5
 46a:   9f 07           cpc r25, r31
 46c:   58 f4           brcc    .+22        ; 0x484 <__stack+0x25>
 
*attcode=nATT_130_dB;
 46e:   22 ed           ldi r18, 0xD2   ; 210
 470:   fb 01           movw    r30, r22
 472:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1300))  ; 
 474:   fc 01           movw    r30, r24
 476:   ee 0f           add r30, r30
 478:   ff 1f           adc r31, r31
 47a:   e4 52           subi    r30, 0x24   ; 36
 47c:   f8 40           sbci    r31, 0x08   ; 8
 47e:   85 91           lpm r24, Z+
 480:   94 91           lpm r25, Z
 482:   08 95           ret
 }}
 
if(Value_dBV>=1400){
if(Value_dBV<=1499){
 484:   8c 3d           cpi r24, 0xDC   ; 220
 486:   f5 e0           ldi r31, 0x05   ; 5
 488:   9f 07           cpc r25, r31
 48a:   58 f4           brcc    .+22        ; 0x4a2 <__stack+0x43>
 
*attcode=nATT_0_dB;
 48c:   2f e0           ldi r18, 0x0F   ; 15
 48e:   fb 01           movw    r30, r22
 490:   20 83           st  Z, r18
return (uint16_t )    pgm_read_word_near(LogTable1 + (Value_dBV-1400))  ; 
 492:   fc 01           movw    r30, r24
 494:   ee 0f           add r30, r30
 496:   ff 1f           adc r31, r31
 498:   ec 5e           subi    r30, 0xEC   ; 236
 49a:   f8 40           sbci    r31, 0x08   ; 8
 49c:   85 91           lpm r24, Z+
 49e:   94 91           lpm r25, Z
 4a0:   08 95           ret
 }}
 
 
return 0x0000;
 4a2:   80 e0           ldi r24, 0x00   ; 0
 4a4:   90 e0           ldi r25, 0x00   ; 0
}
 4a6:   08 95           ret
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
02.04.2020, 16:44  [ТС]
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
000004a8 <GetDACValue_mV>:
 
uint16_t  GetDACValue_mV( uint16_t Value_mV    , uint8_t commapos,  uint8_t  *attcode      )
{
 
 
if(Value_mV>=317){      //1000. ...317. mV
 4a8:   8d 33           cpi r24, 0x3D   ; 61
 4aa:   21 e0           ldi r18, 0x01   ; 1
 4ac:   92 07           cpc r25, r18
 4ae:   a8 f1           brcs    .+106       ; 0x51a <GetDACValue_mV+0x72>
if(Value_mV<=1000){
 4b0:   89 3e           cpi r24, 0xE9   ; 233
 4b2:   e3 e0           ldi r30, 0x03   ; 3
 4b4:   9e 07           cpc r25, r30
 4b6:   70 f5           brcc    .+92        ; 0x514 <GetDACValue_mV+0x6c>
if(commapos==COMMA_4DIGIT){   *attcode=nATT_0_dB; }  //1000. ...317. mV
 4b8:   63 30           cpi r22, 0x03   ; 3
 4ba:   21 f4           brne    .+8         ; 0x4c4 <GetDACValue_mV+0x1c>
 4bc:   2f e0           ldi r18, 0x0F   ; 15
 4be:   fa 01           movw    r30, r20
 4c0:   20 83           st  Z, r18
 4c2:   08 95           ret
if(commapos==COMMA_3DIGIT){   *attcode=nATT_20_dB; }//100.0  ...31.7 mV
 4c4:   62 30           cpi r22, 0x02   ; 2
 4c6:   21 f4           brne    .+8         ; 0x4d0 <GetDACValue_mV+0x28>
 4c8:   2d e2           ldi r18, 0x2D   ; 45
 4ca:   fa 01           movw    r30, r20
 4cc:   20 83           st  Z, r18
 4ce:   08 95           ret
if(commapos==COMMA_2DIGIT){   *attcode=nATT_40_dB; }//10.00  ...3.17 mV
 4d0:   61 30           cpi r22, 0x01   ; 1
 4d2:   41 f5           brne    .+80        ; 0x524 <GetDACValue_mV+0x7c>
 4d4:   2b e4           ldi r18, 0x4B   ; 75
 4d6:   fa 01           movw    r30, r20
 4d8:   20 83           st  Z, r18
 4da:   08 95           ret
return (uint16_t )  Value_mV     ;
 }}
 
 if(Value_mV>=101){   //101. ...316.
if(Value_mV<=316){
if(commapos==COMMA_4DIGIT){   *attcode=nATT_10_dB; } //316. ...101. mV
 4dc:   63 30           cpi r22, 0x03   ; 3
 4de:   21 f4           brne    .+8         ; 0x4e8 <GetDACValue_mV+0x40>
 4e0:   2e e1           ldi r18, 0x1E   ; 30
 4e2:   fa 01           movw    r30, r20
 4e4:   20 83           st  Z, r18
 4e6:   0b c0           rjmp    .+22        ; 0x4fe <GetDACValue_mV+0x56>
if(commapos==COMMA_3DIGIT){   *attcode=nATT_30_dB; } //31.6  ...10.1  mV
 4e8:   62 30           cpi r22, 0x02   ; 2
 4ea:   21 f4           brne    .+8         ; 0x4f4 <GetDACValue_mV+0x4c>
 4ec:   2c e3           ldi r18, 0x3C   ; 60
 4ee:   fa 01           movw    r30, r20
 4f0:   20 83           st  Z, r18
 4f2:   05 c0           rjmp    .+10        ; 0x4fe <GetDACValue_mV+0x56>
if(commapos==COMMA_2DIGIT){   *attcode=nATT_50_dB; } //3.16  ...1.01  mV
 4f4:   61 30           cpi r22, 0x01   ; 1
 4f6:   19 f4           brne    .+6         ; 0x4fe <GetDACValue_mV+0x56>
 4f8:   2a e5           ldi r18, 0x5A   ; 90
 4fa:   fa 01           movw    r30, r20
 4fc:   20 83           st  Z, r18
 
//[0]  +(uint16_t) (316-Value_mV)
return (uint16_t )  pgm_read_word_near(LinTable316+(uint16_t)(316-Value_mV))        ;
 4fe:   ee 27           eor r30, r30
 500:   ff 27           eor r31, r31
 502:   e8 1b           sub r30, r24
 504:   f9 0b           sbc r31, r25
 506:   ee 0f           add r30, r30
 508:   ff 1f           adc r31, r31
 50a:   e4 53           subi    r30, 0x34   ; 52
 50c:   fd 4f           sbci    r31, 0xFD   ; 253
 50e:   85 91           lpm r24, Z+
 510:   94 91           lpm r25, Z
 512:   08 95           ret
 }}
 
return 0;  
 514:   80 e0           ldi r24, 0x00   ; 0
 516:   90 e0           ldi r25, 0x00   ; 0
 518:   08 95           ret
if(commapos==COMMA_3DIGIT){   *attcode=nATT_20_dB; }//100.0  ...31.7 mV
if(commapos==COMMA_2DIGIT){   *attcode=nATT_40_dB; }//10.00  ...3.17 mV
return (uint16_t )  Value_mV     ;
 }}
 
 if(Value_mV>=101){   //101. ...316.
 51a:   85 36           cpi r24, 0x65   ; 101
 51c:   91 05           cpc r25, r1
 51e:   f0 f6           brcc    .-68        ; 0x4dc <GetDACValue_mV+0x34>
 
//[0]  +(uint16_t) (316-Value_mV)
return (uint16_t )  pgm_read_word_near(LinTable316+(uint16_t)(316-Value_mV))        ;
 }}
 
return 0;  
 520:   80 e0           ldi r24, 0x00   ; 0
 522:   90 e0           ldi r25, 0x00   ; 0
}
 524:   08 95           ret
 
00000526 <GetDACValue_mkV>:
uint16_t  GetDACValue_mkV( uint16_t Value_mkV    , uint8_t commapos,  uint8_t  *attcode      )
{
 
 
 
if(Value_mkV>=317){      //1000. ...317. mkV
 526:   8d 33           cpi r24, 0x3D   ; 61
 528:   21 e0           ldi r18, 0x01   ; 1
 52a:   92 07           cpc r25, r18
 52c:   08 f4           brcc    .+2         ; 0x530 <GetDACValue_mkV+0xa>
 52e:   5f c0           rjmp    .+190       ; 0x5ee <GetDACValue_mkV+0xc8>
if(Value_mkV<=1000){
 530:   89 3e           cpi r24, 0xE9   ; 233
 532:   e3 e0           ldi r30, 0x03   ; 3
 534:   9e 07           cpc r25, r30
 536:   c0 f4           brcc    .+48        ; 0x568 <GetDACValue_mkV+0x42>
if(commapos==COMMA_4DIGIT){   *attcode=nATT_60_dB; }  //1000. ...317. uV
 538:   63 30           cpi r22, 0x03   ; 3
 53a:   21 f4           brne    .+8         ; 0x544 <GetDACValue_mkV+0x1e>
 53c:   29 e6           ldi r18, 0x69   ; 105
 53e:   fa 01           movw    r30, r20
 540:   20 83           st  Z, r18
 542:   0c c0           rjmp    .+24        ; 0x55c <GetDACValue_mkV+0x36>
if(commapos==COMMA_3DIGIT){   *attcode=nATT_80_dB; }//100.0  ...31.7 uV
 544:   62 30           cpi r22, 0x02   ; 2
 546:   21 f4           brne    .+8         ; 0x550 <GetDACValue_mkV+0x2a>
 548:   27 e8           ldi r18, 0x87   ; 135
 54a:   fa 01           movw    r30, r20
 54c:   20 83           st  Z, r18
 54e:   08 95           ret
if(commapos==COMMA_2DIGIT){   *attcode=nATT_100_dB; }//10.00  ...3.17 uV
 550:   61 30           cpi r22, 0x01   ; 1
 552:   21 f4           brne    .+8         ; 0x55c <GetDACValue_mkV+0x36>
 554:   25 ea           ldi r18, 0xA5   ; 165
 556:   fa 01           movw    r30, r20
 558:   20 83           st  Z, r18
 55a:   08 95           ret
if(commapos==COMMA_1DIGIT){   *attcode=nATT_120_dB; }//1.000  ...0.317 uV 
 55c:   61 11           cpse    r22, r1
 55e:   50 c0           rjmp    .+160       ; 0x600 <GetDACValue_mkV+0xda>
 560:   23 ec           ldi r18, 0xC3   ; 195
 562:   fa 01           movw    r30, r20
 564:   20 83           st  Z, r18
 566:   08 95           ret
return (uint16_t )  Value_mkV     ;
 }}
 
 if(Value_mkV>=101){   //101. ...316. mkV
 568:   85 36           cpi r24, 0x65   ; 101
 56a:   91 05           cpc r25, r1
 56c:   d0 f5           brcc    .+116       ; 0x5e2 <GetDACValue_mkV+0xbc>
 56e:   43 c0           rjmp    .+134       ; 0x5f6 <GetDACValue_mkV+0xd0>
if(Value_mkV<=316){
if(commapos==COMMA_4DIGIT){   *attcode=nATT_70_dB; } //316. ...101. uV
 570:   63 30           cpi r22, 0x03   ; 3
 572:   21 f4           brne    .+8         ; 0x57c <GetDACValue_mkV+0x56>
 574:   28 e7           ldi r18, 0x78   ; 120
 576:   fa 01           movw    r30, r20
 578:   20 83           st  Z, r18
 57a:   0c c0           rjmp    .+24        ; 0x594 <GetDACValue_mkV+0x6e>
if(commapos==COMMA_3DIGIT){   *attcode=nATT_90_dB; } //31.6  ...10.1  uV
 57c:   62 30           cpi r22, 0x02   ; 2
 57e:   21 f4           brne    .+8         ; 0x588 <GetDACValue_mkV+0x62>
 580:   26 e9           ldi r18, 0x96   ; 150
 582:   fa 01           movw    r30, r20
 584:   20 83           st  Z, r18
 586:   0b c0           rjmp    .+22        ; 0x59e <GetDACValue_mkV+0x78>
if(commapos==COMMA_2DIGIT){   *attcode=nATT_110_dB; } //3.16  ...1.01  uV
 588:   61 30           cpi r22, 0x01   ; 1
 58a:   21 f4           brne    .+8         ; 0x594 <GetDACValue_mkV+0x6e>
 58c:   24 eb           ldi r18, 0xB4   ; 180
 58e:   fa 01           movw    r30, r20
 590:   20 83           st  Z, r18
 592:   05 c0           rjmp    .+10        ; 0x59e <GetDACValue_mkV+0x78>
if(commapos==COMMA_1DIGIT){   *attcode=nATT_130_dB; }//0.316  ...0.101 uV  
 594:   61 11           cpse    r22, r1
 596:   03 c0           rjmp    .+6         ; 0x59e <GetDACValue_mkV+0x78>
 598:   22 ed           ldi r18, 0xD2   ; 210
 59a:   fa 01           movw    r30, r20
 59c:   20 83           st  Z, r18
return (uint16_t ) pgm_read_word_near(LinTable316 +(uint16_t)  (316-Value_mkV))      ;
 59e:   ee 27           eor r30, r30
 5a0:   ff 27           eor r31, r31
 5a2:   e8 1b           sub r30, r24
 5a4:   f9 0b           sbc r31, r25
 5a6:   ee 0f           add r30, r30
 5a8:   ff 1f           adc r31, r31
 5aa:   e4 53           subi    r30, 0x34   ; 52
 5ac:   fd 4f           sbci    r31, 0xFD   ; 253
 5ae:   85 91           lpm r24, Z+
 5b0:   94 91           lpm r25, Z
 5b2:   08 95           ret
 }}
 
if(Value_mkV>=32){   //0.100 ... 0.032 mkV
 5b4:   9c 01           movw    r18, r24
 5b6:   20 52           subi    r18, 0x20   ; 32
 5b8:   31 09           sbc r19, r1
 5ba:   25 34           cpi r18, 0x45   ; 69
 5bc:   31 05           cpc r19, r1
 5be:   a0 f4           brcc    .+40        ; 0x5e8 <GetDACValue_mkV+0xc2>
if(Value_mkV<=100){
if(commapos==COMMA_1DIGIT){   *attcode=nATT_140_dB; }//0.100  ...0.032 uV  
 5c0:   61 11           cpse    r22, r1
 5c2:   03 c0           rjmp    .+6         ; 0x5ca <GetDACValue_mkV+0xa4>
 5c4:   21 ee           ldi r18, 0xE1   ; 225
 5c6:   fa 01           movw    r30, r20
 5c8:   20 83           st  Z, r18
 
return (uint16_t )    (Value_mkV*10);  
 5ca:   9c 01           movw    r18, r24
 5cc:   22 0f           add r18, r18
 5ce:   33 1f           adc r19, r19
 5d0:   88 0f           add r24, r24
 5d2:   99 1f           adc r25, r25
 5d4:   88 0f           add r24, r24
 5d6:   99 1f           adc r25, r25
 5d8:   88 0f           add r24, r24
 5da:   99 1f           adc r25, r25
 5dc:   82 0f           add r24, r18
 5de:   93 1f           adc r25, r19
 5e0:   08 95           ret
 }}
 
 
return 0;  
 5e2:   80 e0           ldi r24, 0x00   ; 0
 5e4:   90 e0           ldi r25, 0x00   ; 0
 5e6:   08 95           ret
 5e8:   80 e0           ldi r24, 0x00   ; 0
 5ea:   90 e0           ldi r25, 0x00   ; 0
 5ec:   08 95           ret
if(commapos==COMMA_2DIGIT){   *attcode=nATT_100_dB; }//10.00  ...3.17 uV
if(commapos==COMMA_1DIGIT){   *attcode=nATT_120_dB; }//1.000  ...0.317 uV 
return (uint16_t )  Value_mkV     ;
 }}
 
 if(Value_mkV>=101){   //101. ...316. mkV
 5ee:   85 36           cpi r24, 0x65   ; 101
 5f0:   91 05           cpc r25, r1
 5f2:   00 f3           brcs    .-64        ; 0x5b4 <GetDACValue_mkV+0x8e>
 5f4:   bd cf           rjmp    .-134       ; 0x570 <GetDACValue_mkV+0x4a>
if(commapos==COMMA_2DIGIT){   *attcode=nATT_110_dB; } //3.16  ...1.01  uV
if(commapos==COMMA_1DIGIT){   *attcode=nATT_130_dB; }//0.316  ...0.101 uV  
return (uint16_t ) pgm_read_word_near(LinTable316 +(uint16_t)  (316-Value_mkV))      ;
 }}
 
if(Value_mkV>=32){   //0.100 ... 0.032 mkV
 5f6:   80 32           cpi r24, 0x20   ; 32
 5f8:   91 05           cpc r25, r1
 5fa:   10 f7           brcc    .-60        ; 0x5c0 <GetDACValue_mkV+0x9a>
 
return (uint16_t )    (Value_mkV*10);  
 }}
 
 
return 0;  
 5fc:   80 e0           ldi r24, 0x00   ; 0
 5fe:   90 e0           ldi r25, 0x00   ; 0
 
}
 600:   08 95           ret
 
00000602 <GetOutValueFromDigits>:
 
uint16_t GetOutValueFromDigits ( uint8_t val[7])
{
 602:   fc 01           movw    r30, r24
    uint16_t result=0;
    result+=(uint16_t) val[3];
 604:   23 81           ldd r18, Z+3    ; 0x03
 606:   42 2f           mov r20, r18
 608:   50 e0           ldi r21, 0x00   ; 0
    for(uint8_t i=0;i<val[2];i++) { result+=10;  }
 60a:   32 81           ldd r19, Z+2    ; 0x02
 60c:   33 23           and r19, r19
 60e:   b1 f0           breq    .+44        ; 0x63c <GetOutValueFromDigits+0x3a>
 610:   90 e0           ldi r25, 0x00   ; 0
 612:   9f 5f           subi    r25, 0xFF   ; 255
 614:   93 13           cpse    r25, r19
 616:   fd cf           rjmp    .-6         ; 0x612 <GetOutValueFromDigits+0x10>
 618:   46 5f           subi    r20, 0xF6   ; 246
 61a:   5f 4f           sbci    r21, 0xFF   ; 255
 61c:   31 50           subi    r19, 0x01   ; 1
 61e:   23 2f           mov r18, r19
 620:   30 e0           ldi r19, 0x00   ; 0
 622:   c9 01           movw    r24, r18
 624:   88 0f           add r24, r24
 626:   99 1f           adc r25, r25
 628:   22 0f           add r18, r18
 62a:   33 1f           adc r19, r19
 62c:   22 0f           add r18, r18
 62e:   33 1f           adc r19, r19
 630:   22 0f           add r18, r18
 632:   33 1f           adc r19, r19
 634:   28 0f           add r18, r24
 636:   39 1f           adc r19, r25
 638:   42 0f           add r20, r18
 63a:   53 1f           adc r21, r19
    for(uint8_t i=0;i<val[1];i++) { result+=100;  }
 63c:   31 81           ldd r19, Z+1    ; 0x01
 63e:   33 23           and r19, r19
 640:   71 f0           breq    .+28        ; 0x65e <GetOutValueFromDigits+0x5c>
 642:   90 e0           ldi r25, 0x00   ; 0
 644:   9f 5f           subi    r25, 0xFF   ; 255
 646:   93 13           cpse    r25, r19
 648:   fd cf           rjmp    .-6         ; 0x644 <GetOutValueFromDigits+0x42>
 64a:   31 50           subi    r19, 0x01   ; 1
 64c:   ca 01           movw    r24, r20
 64e:   64 e6           ldi r22, 0x64   ; 100
 650:   36 9f           mul r19, r22
 652:   80 0d           add r24, r0
 654:   91 1d           adc r25, r1
 656:   11 24           eor r1, r1
 658:   ac 01           movw    r20, r24
 65a:   4c 59           subi    r20, 0x9C   ; 156
 65c:   5f 4f           sbci    r21, 0xFF   ; 255
    for(uint8_t i=0;i<val[0];i++) { result+=1000;  }
 65e:   30 81           ld  r19, Z
 660:   33 23           and r19, r19
 662:   81 f0           breq    .+32        ; 0x684 <GetOutValueFromDigits+0x82>
 664:   90 e0           ldi r25, 0x00   ; 0
 666:   9f 5f           subi    r25, 0xFF   ; 255
 668:   93 13           cpse    r25, r19
 66a:   fd cf           rjmp    .-6         ; 0x666 <GetOutValueFromDigits+0x64>
 66c:   31 50           subi    r19, 0x01   ; 1
 66e:   68 ee           ldi r22, 0xE8   ; 232
 670:   73 e0           ldi r23, 0x03   ; 3
 672:   36 9f           mul r19, r22
 674:   c0 01           movw    r24, r0
 676:   37 9f           mul r19, r23
 678:   90 0d           add r25, r0
 67a:   11 24           eor r1, r1
 67c:   88 51           subi    r24, 0x18   ; 24
 67e:   9c 4f           sbci    r25, 0xFC   ; 252
 680:   48 0f           add r20, r24
 682:   59 1f           adc r21, r25
 return result;
}
 684:   ca 01           movw    r24, r20
 686:   08 95           ret
 
00000688 <GetDACValue>:
 
 
 
 
uint16_t GetDACValue ( uint8_t digits[4], uint8_t commapos,  uint8_t  *attcode , uint8_t mode    )
{
 688:   0f 93           push    r16
 68a:   1f 93           push    r17
 68c:   cf 93           push    r28
 68e:   df 93           push    r29
 690:   d6 2f           mov r29, r22
 692:   8a 01           movw    r16, r20
 694:   c2 2f           mov r28, r18
uint16_t  Value ;
Value=GetOutValueFromDigits(digits);  //0032...1000
 696:   0e 94 01 03     call    0x602   ; 0x602 <GetOutValueFromDigits>
if(mode==TOKEN_Out_dB)  {  return   GetDACValue_dBV(Value, attcode );  } 
 69a:   c1 30           cpi r28, 0x01   ; 1
 69c:   21 f4           brne    .+8         ; 0x6a6 <GetDACValue+0x1e>
 69e:   b8 01           movw    r22, r16
 6a0:   0e 94 72 01     call    0x2e4   ; 0x2e4 <GetDACValue_dBV>
 6a4:   10 c0           rjmp    .+32        ; 0x6c6 <GetDACValue+0x3e>
if(mode==TOKEN_Out_mkV)  { return GetDACValue_mkV( Value, commapos, attcode);   } 
 6a6:   c3 30           cpi r28, 0x03   ; 3
 6a8:   29 f4           brne    .+10        ; 0x6b4 <GetDACValue+0x2c>
 6aa:   a8 01           movw    r20, r16
 6ac:   6d 2f           mov r22, r29
 6ae:   0e 94 93 02     call    0x526   ; 0x526 <GetDACValue_mkV>
 6b2:   09 c0           rjmp    .+18        ; 0x6c6 <GetDACValue+0x3e>
if(mode==TOKEN_Out_mV)  {   return GetDACValue_mV(  Value, commapos,attcode );  } 
 6b4:   c2 30           cpi r28, 0x02   ; 2
 6b6:   29 f4           brne    .+10        ; 0x6c2 <GetDACValue+0x3a>
 6b8:   a8 01           movw    r20, r16
 6ba:   6d 2f           mov r22, r29
 6bc:   0e 94 54 02     call    0x4a8   ; 0x4a8 <GetDACValue_mV>
 6c0:   02 c0           rjmp    .+4         ; 0x6c6 <GetDACValue+0x3e>
return 0;
 6c2:   80 e0           ldi r24, 0x00   ; 0
 6c4:   90 e0           ldi r25, 0x00   ; 0
}
 6c6:   df 91           pop r29
 6c8:   cf 91           pop r28
 6ca:   1f 91           pop r17
 6cc:   0f 91           pop r16
 6ce:   08 95           ret
 
000006d0 <main>:
#include "vrefparser.h"
 #define low_byte(x)   ( (uint8_t)(((x)>>0) & 0xFF))
 #define high_byte(x)   ( (uint8_t)(((x)>>8) & 0xFF))
 
int main(void)
{
 6d0:   cf 93           push    r28
 6d2:   df 93           push    r29
 6d4:   cd b7           in  r28, 0x3d   ; 61
 6d6:   de b7           in  r29, 0x3e   ; 62
 6d8:   28 97           sbiw    r28, 0x08   ; 8
 6da:   0f b6           in  r0, 0x3f    ; 63
 6dc:   f8 94           cli
 6de:   de bf           out 0x3e, r29   ; 62
 6e0:   0f be           out 0x3f, r0    ; 63
 6e2:   cd bf           out 0x3d, r28   ; 61
       uint8_t mode_out =TOKEN_Out_mkV;
      uint8_t digit[7];
      
     main1: 
       digit[0]=0x00;
      digit[1]=0x09;
 6e4:   19 e0           ldi r17, 0x09   ; 9
    //  uint8_t mode_out =TOKEN_Out_mV;
       uint8_t mode_out =TOKEN_Out_mkV;
      uint8_t digit[7];
      
     main1: 
       digit[0]=0x00;
 6e6:   19 82           std Y+1, r1 ; 0x01
      digit[1]=0x09;
 6e8:   1a 83           std Y+2, r17    ; 0x02
       digit[2]=0x09;
 6ea:   1b 83           std Y+3, r17    ; 0x03
        digit[3]=0x09;
 6ec:   1c 83           std Y+4, r17    ; 0x04
        uint8_t commapos=COMMA_4DIGIT;
        uint8_t attcode;
        
        uint16_t Value=GetDACValue(  digit , commapos,  &attcode ,   mode_out);
 6ee:   23 e0           ldi r18, 0x03   ; 3
 6f0:   ae 01           movw    r20, r28
 6f2:   48 5f           subi    r20, 0xF8   ; 248
 6f4:   5f 4f           sbci    r21, 0xFF   ; 255
 6f6:   63 e0           ldi r22, 0x03   ; 3
 6f8:   ce 01           movw    r24, r28
 6fa:   01 96           adiw    r24, 0x01   ; 1
 6fc:   0e 94 44 03     call    0x688   ; 0x688 <GetDACValue>
        
        
        
        PORTA=attcode;
 700:   28 85           ldd r18, Y+8    ; 0x08
 702:   2b bb           out 0x1b, r18   ; 27
        PORTB=low_byte(Value);
 704:   88 bb           out 0x18, r24   ; 24
        PORTC=high_byte(Value);
 706:   95 bb           out 0x15, r25   ; 21
 708:   ee cf           rjmp    .-36        ; 0x6e6 <main+0x16>
 
0000070a <_exit>:
 70a:   f8 94           cli
 
0000070c <__stop_program>:
 70c:   ff cf           rjmp    .-2         ; 0x70c <__stop_program>
Добавлено через 1 час 14 минут
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*
(first sent bit )nr0; nc0;nr2;nr1;nc1;x;x;x;(last sent bit )
after GetByteGCd()  byte is  
MSB                            LSB 
;7 6  5  4    3     2     1    0 
;x;x;x;nc1;nr1;nr2;nc0;nr0;   
 
*/
 
 
 
 
#define nR0   0
#define nC0   1
#define nR2   2
#define nR1   3
#define nC1   4
#define nENC2  5 
#define nENC1  6
#define nENC0  7 
 
 
 
#define BITMASK_KEYBOARD (uint8_t) ( (1<<nR0)|(1<<nC0)|(1<<nR2)|(1<<nR1)|(1<<nC1))
 
 
#define BUTTON_0    (uint8_t) ((1<<nR0)|(1<<nC0)|(1<<nR2)|(1<<nR1)|(1<<nC1)) 
#define BUTTON_1    (uint8_t) ((0<<nR0)|(1<<nC0)|(1<<nR2)|(1<<nR1)|(1<<nC1)) 
#define BUTTON_2    (uint8_t) ((1<<nR0)|(1<<nC0)|(1<<nR2)|(0<<nR1)|(1<<nC1)) 
#define BUTTON_3    (uint8_t) ((0<<nR0)|(1<<nC0)|(1<<nR2)|(0<<nR1)|(1<<nC1)) 
#define BUTTON_4    (uint8_t) ((1<<nR0)|(1<<nC0)|(0<<nR2)|(1<<nR1)|(1<<nC1))
#define BUTTON_5    (uint8_t) ((0<<nR0)|(0<<nC0)|(1<<nR2)|(1<<nR1)|(1<<nC1))
#define BUTTON_6    (uint8_t) ((1<<nR0)|(1<<nC0)|(0<<nR2)|(0<<nR1)|(1<<nC1))
#define BUTTON_7    (uint8_t) ((0<<nR0)|(1<<nC0)|(0<<nR2)|(0<<nR1)|(1<<nC1))
#define BUTTON_8    (uint8_t) ((1<<nR0)|(0<<nC0)|(1<<nR2)|(1<<nR1)|(1<<nC1))
#define BUTTON_9    (uint8_t) ((0<<nR0)|(0<<nC0)|(1<<nR2)|(1<<nR1)|(1<<nC1))
 
#define BUTTON_SHARP    (uint8_t) ((1<<nR0)|(0<<nC0)|(1<<nR2)|(0<<nR1)|(0<<nC1))
#define BUTTON_RECALL (uint8_t) ((1<<nR0)|(0<<nC0)|(1<<nR2)|(1<<nR1)|(0<<nC1))
 
 
#define BUTTON_F (uint8_t) ((0<<nR0)|(0<<nC0)|(0<<nR2)|(0<<nR1)|(1<<nC1))
#define BUTTON_FM   (uint8_t) ((1<<nR0)|(0<<nC0)|(0<<nR2)|(0<<nR1)|(1<<nC1))
#define BUTTON_AM  (uint8_t) ((0<<nR0)|(1<<nC0)|(1<<nR2)|(1<<nR1)|(0<<nC1))
#define BUTTON_PM (uint8_t) ((1<<nR0)|(1<<nC0)|(1<<nR2)|(1<<nR1)|(0<<nC1))
#define BUTTON_MOD_OFF   (uint8_t) ((0<<nR0)|(1<<nC0)|(1<<nR2)|(0<<nR1)|(0<<nC1))
#define BUTTON_EXT   (uint8_t) ((1<<nR0)|(1<<nC0)|(0<<nR2)|(1<<nR1)|(0<<nC1))
#define BUTTON_STEP (uint8_t) ((0<<nR0)|(1<<nC0)|(0<<nR2)|(0<<nR1)|(0<<nC1))
#define BUTTON_OUT  (uint8_t) ((1<<nR0)|(1<<nC0)|(1<<nR2)|(0<<nR1)|(0<<nC1))
#define BUTTON_LFO (uint8_t) ((0<<nR0)|(1<<nC0)|(0<<nR2)|(1<<nR1)|(0<<nC1))
#define BUTTON_MHz  (uint8_t) ((0<<nR0)|(0<<nC0)|(0<<nR2)|(1<<nR1)|(1<<nC1))
#define BUTTON_kHz   (uint8_t) ((1<<nR0)|(0<<nC0)|(0<<nR2)|(1<<nR1)|(1<<nC1))
#define  BUTTON_PERCENT  (uint8_t) ((0<<nR0)|(0<<nC0)|(1<<nR2)|(0<<nR1)|(1<<nC1))
#define  BUTTON_mV  (uint8_t) ((1<<nR0)|(0<<nC0)|(0<<nR2)|(1<<nR1)|(1<<nC1))
#define  BUTTON_mkV (uint8_t) ((0<<nR0)|(0<<nC0)|(1<<nR2)|(0<<nR1)|(1<<nC1))
#define  BUTTON_dBV (uint8_t) ((0<<nR0)|(0<<nC0)|(0<<nR2)|(1<<nR1)|(1<<nC1))
#define  BUTTON_6dB  (uint8_t) ((1<<nR0)|(0<<nC0)|(0<<nR2)|(1<<nR1)|(0<<nC1))
#define  BUTTON_OUT_OFF  (uint8_t) ((0<<nR0)|(0<<nC0)|(1<<nR2)|(0<<nR1)|(0<<nC1))
#define  BUTTON_LEFT  (uint8_t) ((0<<nR0)|(0<<nC0)|(0<<nR2)|(1<<nR1)|(0<<nC1))
#define  BUTTON_RIGHT (uint8_t) ((0<<nR0)|(0<<nC0)|(1<<nR2)|(1<<nR1)|(0<<nC1))
 
#define SCANCODE_FWD 0x00
 
 
 #define TOKEN_Out_dB 1
 #define TOKEN_Out_mV 2
 #define TOKEN_Out_mkV 3
 
 
 
 
 
#define COMMA_7DIGIT 6
#define COMMA_6DIGIT 5
#define COMMA_5DIGIT 4
#define COMMA_4DIGIT 3
#define COMMA_3DIGIT 2
#define COMMA_2DIGIT 1
#define COMMA_1DIGIT 0
 
 
 
#define INTERUPT3_BYTEMASK (1<<2)
#define INTERUPT2_BYTEMASK (1<<1)
#define INTERUPT2_BYTEMASK (1<<0)
 
 
//for byte=SetSelectedFunctionParams() 
#define FREQ_BYTEMASK (1<<0)
#define FM_BYTEMASK     (1<<1)
#define AM_BYTEMASK    (1<<2)
 
//reg_data0
#define MASK_FLAG_PARSECODE_FM (1<<0)
#define MASK_FLAG_PARSECODE_AM (1<<1)
#define MASK_FLAG_PARSECODE_OUT(1<<2)
#define  MASK_FLAG_PARSECODE_FREQ(1<<3)
 
 
//reg_data1
#define  MASK_FLAG_INC_STEP  (1<<0)
#define  MASK_FLAG_DEC_STEP (1<<1)
 
//reg_data2
#define MASK_FLAG_TURN_OFF (1<<0)
#define MASK_FLAG_DISP_ERROR (1<<1)
#define MASK_FLAG_DISP_FM (1<<2)
#define MASK_FLAG_DISP_AM (1<<3)
#define MASK_FLAG_DISP_OUT (1<<4)
#define MASK_FLAG_DISP_FREQ (1<<5)
#define MASK_BLINK_OFF (1<<6)
#define MASK_FLAG_BLINK_CODE (1<<7)
 
 
//reg_data3 
#define  MASK_FLAG_MODE (1<<0)
#define  MASK_FLAG_LFO (1<<1)
#define  MASK_FLAG_FM_CODE (1<<2)
#define  MASK_FLAG_AM_CODE (1<<3)
#define  MASK_FLAG_ATT_CODE (1<<4)
#define  MASK_FLAG_HFO_CODE (1<<5)
#define  MASK_FLAG_DVDC_CODE  (1<<6)
 
 
// 1kHz pin   low 1kHz (set nInform  low), high  1.25 kHz    (set nInform  high)
#define FREQ1kHz  0x00         //check for circuit 
#define FREQ1_25kHz  0x01
 
#define  HFO_FM0_1 0   //fix for sender 
#define  HFO_G1 1
#define  HFO_G2 2
#define  HFO_G4 3
#define  HFO_HL 4
#define  HFO_B1 5
#define  HFO_B2 6
#define  HFO_B4 7
 
 
#define   FILTER_R52 (0<<HFO_HL)| (1<<HFO_B1)| (0<<HFO_B2)|(0 <<HFO_B4) //1      
#define   FILTER_R51 (1<<HFO_HL)| (1<<HFO_B1)| (0<<HFO_B2)|(0 <<HFO_B4) //1
#define   FILTER_R50 (0<<HFO_HL)| (0<<HFO_B1)| (1<<HFO_B2)|(0 <<HFO_B4) //2
#define   FILTER_R49 (1<<HFO_HL)| (0<<HFO_B1)| (1<<HFO_B2)|(0 <<HFO_B4) //2
#define   FILTER_R48 (0<<HFO_HL)| (1<<HFO_B1)| (1<<HFO_B2)|(0 <<HFO_B4) //3
#define   FILTER_R47 (1<<HFO_HL)| (1<<HFO_B1)| (1<<HFO_B2)|(0 <<HFO_B4) //3
#define   FILTER_R46 (0<<HFO_HL)| (0<<HFO_B1)| (0<<HFO_B2)|(1 <<HFO_B4) //4
#define   FILTER_R45 (1<<HFO_HL)| (0<<HFO_B1)| (0<<HFO_B2)|(1 <<HFO_B4) //4
#define   FILTER_R44 (0<<HFO_HL )| (1<<HFO_B1)| (0<<HFO_B2)|(1 <<HFO_B4) //5
#define   FILTER_R43 (1<<HFO_HL)| (1<<HFO_B1)|(0<<HFO_B2)| (1 <<HFO_B4) //5
#define   FILTER_R42 (0<<HFO_HL)| (1<<HFO_B1)| (0<<HFO_B2)|(1 <<HFO_B4) //6
 
 
//rule for bits of register
 
#define  OSC_G4 (0<<HFO_G1)|(0<<HFO_G2) | (0<<HFO_G4)  //  G4 600-639.999
#define  OSC_G3 (1<<HFO_G1)|(0<<HFO_G2) | (0<<HFO_G4)  //  G3   560-599.999
#define  OSC_G8 (0<<HFO_G1)|(1<<HFO_G2) | (0<<HFO_G4) //   G8   520-559.999
#define  OSC_G7 (1<<HFO_G1)|(1<<HFO_G2) | (0<<HFO_G4)  //  G7   480-519.999
#define  OSC_G6 (0<<HFO_G1)|(0<<HFO_G2) | (1<<HFO_G4)  //  G6   440-479.999
#define  OSC_G5 (1<<HFO_G1)|(0<<HFO_G2) | (1<<HFO_G4)  //  G5  400-440.999
#define  OSC_G2 (0<<HFO_G1)|(1<<HFO_G2) | (1<<HFO_G4)  //  G2    360-399.999
#define  OSC_G1 (1<<HFO_G1)|(1<<HFO_G2) | (1<<HFO_G4)  // G1   320-359.999
 
#define   OSC_G4_SUBBAND_R52_HIGH  ( OSC_G4|  FILTER_R52)
#define   OSC_G3_SUBBAND_R52_HIGH  ( OSC_G3|  FILTER_R52)
#define   OSC_G8_SUBBAND_R52_HIGH  ( OSC_G8|  FILTER_R52)
#define   OSC_G7_SUBBAND_R52_HIGH  ( OSC_G4|  FILTER_R52)  
#define   OSC_G6_SUBBAND_R52_HIGH  ( OSC_G6|  FILTER_R52)  
#define   OSC_G6_SUBBAND_R51_LOW   ( OSC_G6|  FILTER_R51)  
#define   OSC_G5_SUBBAND_R51_LOW   ( OSC_G5|  FILTER_R51)  
#define   OSC_G2_SUBBAND_R51_LOW   ( OSC_G2|  FILTER_R51)    
#define   OSC_G1_SUBBAND_R51_LOW   ( OSC_G1|  FILTER_R51)  
 
#define   OSC_G4_SUBBAND_R50_HIGH  ( OSC_G4|  FILTER_R50) 
#define   OSC_G3_SUBBAND_R50_HIGH   ( OSC_G3|  FILTER_R50)  
#define   OSC_G8_SUBBAND_R50_HIGH    ( OSC_G8|  FILTER_R50) 
#define   OSC_G7_SUBBAND_R50_HIGH    ( OSC_G7|  FILTER_R50) 
#define   OSC_G6_SUBBAND_R50_HIGH    ( OSC_G6|  FILTER_R50) 
#define   OSC_G6_SUBBAND_R49_LOW     ( OSC_G6|  FILTER_R49) 
#define   OSC_G5_SUBBAND_R49_LOW    ( OSC_G5|  FILTER_R49) 
#define   OSC_G2_SUBBAND_R49_LOW    ( OSC_G2|  FILTER_R49) 
#define   OSC_G1_SUBBAND_R49_LOW    ( OSC_G1|  FILTER_R49) 
 
#define   OSC_G4_SUBBAND_R48_HIGH  ( OSC_G4|  FILTER_R48) 
#define   OSC_G3_SUBBAND_R48_HIGH  ( OSC_G3|  FILTER_R48)   
#define   OSC_G8_SUBBAND_R48_HIGH  ( OSC_G8|  FILTER_R48) 
#define   OSC_G7_SUBBAND_R48_HIGH  ( OSC_G7| FILTER_R48)  
#define   OSC_G6_SUBBAND_R48_HIGH  ( OSC_G6|  FILTER_R48)   
#define  OSC_G6_SUBBAND_R47_LOW  ( OSC_G6|  FILTER_R47) 
#define  OSC_G5_SUBBAND_R47_LOW    ( OSC_G5|  FILTER_R47)  
#define  OSC_G2_SUBBAND_R47_LOW    ( OSC_G2|  FILTER_R47)  
#define  OSC_G1_SUBBAND_R47_LOW    ( OSC_G1| FILTER_R48)  
 
#define  OSC_G4_SUBBAND_R46_HIGH ( OSC_G4|  FILTER_R46) 
#define  OSC_G3_SUBBAND_R46_HIGH ( OSC_G3|  FILTER_R46) 
#define  OSC_G8_SUBBAND_R46_HIGH ( OSC_G8|  FILTER_R46) 
#define  OSC_G7_SUBBAND_R46_HIGH ( OSC_G7|  FILTER_R46) 
#define  OSC_G6_SUBBAND_R46_HIGH ( OSC_G6|  FILTER_R46)   
#define   OSC_G6_SUBBAND_R45_LOW ( OSC_G6|  FILTER_R45)    
#define  OSC_G5_SUBBAND_R45_LOW  ( OSC_G5|  FILTER_R45)      
#define  OSC_G2_SUBBAND_R45_LOW  ( OSC_G2|  FILTER_R45)       
#define  OSC_G1_SUBBAND_R45_LOW  ( OSC_G1|  FILTER_R45)    
 
#define  OSC_G4_SUBBAND_R44_HIGH   ( OSC_G4|  FILTER_R44) 
#define  OSC_G3_SUBBAND_R43_LOW    ( OSC_G3|  FILTER_R43) 
#define  OSC_G8_SUBBAND_R42_HIGH   ( OSC_G8|  FILTER_R42)
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
02.04.2020, 16:51  [ТС]
defines.h (один из вариантов).

В основном алгоритме ,кажется, плохо сказано по кнопку "Откл. выход". Обработчик можно добавить перед обработчиком включения выхода или после (для установившегося решения ). Для быстродействия реакции на выключчение можно поставить его перед обработчиком нажатия кнопки f. В оригинальном приборе есть недостаток: после отключения кнопкой "откл выход" выхода и вращения валкодера (например, при перестройке частоты) выход включается, а светодиод откл .выход светится. Это можно устранить или иммитировать в нашей программе .

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 void ParseKeyb()
{
//;        8_1  
 
byte=GetScanCodeValue() ;
byte&=BITMASK_KEYBOARD;
if(CheckButtonsNumericKeypad( byte )==0x01) { return; } 
 
if((byte& BUTTON_OUT_OFF)!=0) { OutputOnOff();  return; }
if((byte& BUTTON_F)!=0) {  SetDutyReg(TOKEN_F);  return ;}  
if((byte& BUTTON_FM)!=0) { TurnOnFM (); SetDutyReg(TOKEN_FM);  return ;      }
if((byte& BUTTON_AM)!=0) { TurnOnAM(); SetDutyReg(TOKEN_AM);  return ;     }
if((byte&BUTTON_PM)!=0) { TurnOnPM(); SetDutyReg(TOKEN_PM);  return ;  }
if((byte& BUTTON_MOD_OFF)!=0) { TurnOffModulation(); SetDutyReg(TOKEN_MOD_OFF);  return ; }
if((byte&BUTTON_EXT)!=0)  { PrepareExtModulation () ; return; } /* 9*/
if((byte& BUTTON_STEP)!=0) { StepModeOn(); return; }
//if((byte& BUTTON_OUT_OFF)!=0) { OutputOnOff();  return; }
if((byte& BUTTON_OUT)!=0) { OutputOn(); SetDutyReg(TOKEN_OUT); return; }
if((byte& BUTTON_LFO)!=0) { ChangeLFONum(); return; }
if((byte& BUTTON_SHARP)!=0) { SetMemWrMode(); return;  }
if((byte&BUTTON_RECALL)!=0) { SetMemRecallMode(); return; }
if((byte& BUTTON_MHz)!=0) { NormalizeFreq(); return; }//;  10   
if((byte& BUTTON_kHz)!=0) { if (CheckStepModeOn()){ NormalizeStep();  return; } else { NormalizeFM();  return;}  }//;  macro,  13_2 or to 1 
if((byte& BUTTON_PERCENT)!=0) { NormalizeAMCoef(); return; }  //;   14_2   
if((byte& BUTTON_mV)!=0) { SetOutInputMode(TOKEN_Out_mV);  return;} //;   15_2  
if((byte& BUTTON_mkV)!=0) {SetOutInputMode( TOKEN_Out_mkV );  return;}//;   15_2 
if((byte& BUTTON_dBV)!=0) { SetOutInputMode(TOKEN_Out_dB);  return;} //;   15_2  
if((byte& BUTTON_6dB)!=0) { if (CheckModeAM==0)    {TurnOn6dB(); }  return; }//;   11  
//if((byte& BUTTON_OUT_OFF)!=0) { OutputOnOff();  return; }
//CaseDefault: 
if(IsModeStep==1) { ChangeFreqOneStep() ;   NormalizeFreq(); return; }   ;//  12_3,   
ChangeStepParam(); 
  return ; //to point1             
}
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
02.04.2020, 18:38  [ТС]
Упрощенный пример работы с переменными среды и ячейкой памяти на примере программы выработки кодов ЦАП (12% флэш, около 39 % СОЗУ для ATMEGA16A ).
Вложения
Тип файла: zip Gccapp5_structtest.zip (63.4 Кб, 6 просмотров)
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
02.04.2020, 22:13  [ТС]
Правильно ввести запоминание выделенного регистра и флажка до сброса и обработчик сброса флажков после выполнения соответствующих подпрограмм.

Не менее 408 байт ОЗУ + на стек процентов 20 хотя бы требуется (512 байт ОЗУ мало Мега48 плохо подходит , Мега16А, Мега32а,возможно, подойдут с 12...16 МГц кварцем ) .
Вложения
Тип файла: zip preview_sub.zip (419.7 Кб, 6 просмотров)
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
03.04.2020, 00:32  [ТС]
Упростил, через переменные в ОЗУ (дописывается еще ):
Вложения
Тип файла: zip proj_samples.zip (252.4 Кб, 9 просмотров)
0
10 / 10 / 0
Регистрация: 29.06.2018
Сообщений: 1,536
03.04.2020, 02:33  [ТС]
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
;***********************
 
#define FLAG_PARSECODE_FM  0x01
#define FLAG_PARSECODE_AM  0x02
#define FLAG_PARSECODE_OUT 0x03
#define FLAG_PARSECODE_FREQ 0x04
#define FLAG_INC_STEP 0x05
#define FLAG_DEC_STEP 0x06
#define FLAG_TURN_OFF_MODES 0x07
#define FLAG_DISP_ERROR 0x08
#define FLAG_DISP_FM 0x09
#define FLAG_DISP_AM 0x0a
#define FLAG_DISP_OUT 0x0b
#define FLAG_DISP_FREQ 0x0c
#define FLAG_BLINK_OFF 0x0d
#define FLAG_BLINK_CODE 0x0e
#define FLAG___MODE 0x0f
#define FLAG___LFO 0x10
#define  FLAG__FM_CODE 0x11
#define FLAG__AM_CODE 0x12
#define FLAG__ATT_CODE 0x13
#define FLAG__HFO_CODE 0x14
#define  FLAG__DVDC_CODE 0x15
 
uint8_t selectedflag=0;
void SetSelectedFlag ( uint8_t flag)
{
selectedflag=flag;
}
 
 
void SetSelectedFlagZero ( )
{
 
 
if(selectedflag==FLAG_PARSECODE_FM ) { Flag[0]&=~(1<<MASK_FLAG_PARSECODE_FM);      } 
if(selectedflag==FLAG_PARSECODE_AM ) { Flag[0]&=~(1<<MASK_FLAG_PARSECODE_AM);      } 
if(selectedflag==FLAG_PARSECODE_OUT ) { Flag[0]&=~(1<<MASK_FLAG_PARSECODE_OUT);      } 
if(fselectedflag==FLAG_PARSECODE_FREQ ) { Flag[0]&=~(1<<MASK_FLAG_PARSECODE_FREQ);      } 
 
if(selectedflag==FLAG_INC_STEP ) { Flag[1]&=~(1<<MASK_FLAG_INC_STEP);      } 
if(selectedflag==FLAG_DEC_STEP) { Flag[0]&=~(1<<MASK_FLAG_DEC_STEP);      } 
 
if(selectedflag==FLAG_TURN_OFF_MODES) { Flag[2]&=~(1<<MASK_FLAG_TURN_OFF);      } 
if(selectedflag==FLAG_DISP_ERROR) { Flag[2]&=~(1<<MASK_FLAG_DISP_ERROR);      } 
if(selectedflag==FLAG_DISP_FM) { Flag[2]&=~(1<<MASK_FLAG_DISP_FM);      } 
if(selectedflag==FLAG_DISP_AM) { Flag[2]&=~(1<<MASK_FLAG_DISP_AM);      } 
if(selectedflag==FLAG_DISP_OUT) { Flag[2]&=~(1<<MASK_FLAG_DISP_OUT);      } 
if(selectedflag== FLAG_DISP_FREQ) { Flag[2]&=~(1<<MASK_FLAG_DISP_FREQ);      } 
if(selectedflag==FLAG_BLINK_OFF) { Flag[2]&=~(1<<MASK_BLINK_OFF);      } 
if(selectedflag== FLAG_BLINK_CODE) { Flag[2]&=~(1<<MASK_FLAG_BLINK_CODE);      } 
 
if(selectedflag== FLAG___MODE) { Flag[3]&=~(1<<MASK_FLAG_MODE);      } 
if(selectedflag== FLAG___LFO) { Flag[3]&=~(1<<MASK_FLAG_LFO);      } 
if(selectedflag== FLAG__FM_CODE) { Flag[3]&=~(1<<MASK_FLAG_FM_CODE);      } 
if(selectedflag== FLAG__AM_CODE) { Flag[3]&=~(1<<MASK_FLAG_AM_CODE);      } 
if(selectedflag== FLAG__ATT_CODE) { Flag[3]&=~(1<<MASK_FLAG_ATT_CODE);      } 
if(selectedflag== FLAG__HFO_CODE) { Flag[3]&=~(1<<MASK_FLAG_HFO_CODE);      } 
if(selectedflag== FLAG__DVDC_CODE) { Flag[3]&=~(1<<MASK_FLAG_DVDC_CODE);      } 
selectedflag=0;
return;
}
 
 
 
 
 
 
volatile void CheckFlags1(){
 
 
 
 
if( (Flag[0]&MASK_FLAG_PARSECODE_FM)!=0){   ParseCodesFM() ;  ParseCodesHFO() ;  SetSelectedFlag (FLAG_PARSECODE_FM);  return; }
if((Flag[0]&MASK_FLAG_PARSECODE_AM)!=0) {   ParseCodesAM();   SetSelectedFlag (FLAG_PARSECODE_AM);   return; }
if((Flag[0]&MASK_FLAG_PARSECODE_OUT)!=0){  ParseCodesAtt() ; ParseStaticCommands() ; ParseCodesOut() ; 
              SetSelectedFlag (FLAG_PARSECODE_OUT);  return; }
if((Flag[0]&MASK_FLAG_PARSECODE_FREQ)!=0){ ParseCodesDVDC() ; ParseCodesBand() ; ParseStaticCommands();  
              CheckFMMax() ; SetSelectedFlag (FLAG_PARSECODE_FREQ);  return;  }
 
if((Flag[1]&MASK_FLAG_INC_STEP)!=0) { IncStep(); SetSelectedFlag (FLAG_INC_STEP); return; } //3 
if((Flag[1]&MASK_FLAG_DEC_STEP)!=0)  {DecStep(); SetSelectedFlag (); return; } 
 
if((Flag[2]&MASK_FLAG_TURN_OFF)!=0) { TurnOffUnusedModes(); SetSelectedFlag (FLAG_TURN_OFF_MODES);  return ; } 
if((Flag[2]&MASK_FLAG_DISP_ERROR)!=0) { DisplayErrorFM; SetSelectedFlag (FLAG_DISP_ERROR);  return ; }
if((Flag[2]&MASK_FLAG_DISP_FM)!=0)  { DisplayFMValue(); SetSelectedFlag (FLAG_DISP_FM); return;  }
if((Flag[2]&MASK_FLAG_DISP_AM)!=0) { DisplayAMValue(); SetSelectedFlag ( FLAG_DISP_AM); return;  }
if((Flag[2]&MASK_FLAG_DISP_OUT)!=0) { DisplayOutValue(); SetSelectedFlag ( FLAG_DISP_OUT); return; }
if((Flag[2]&MASK_FLAG_DISP_FREQ)!=0) { DisplayFreqValue(); SetSelectedFlag ( FLAG_DISP_FREQ); return; }
 
if((Flag[2]&MASK_BLINK_OFF)!=0)  { SendBlinkOff(); SetSelectedFlag ( FLAG_BLINK_OFF); return; } //4
if((Flag[2]&MASK_FLAG_BLINK_CODE)!=0)  { SendBlinkCode();  SetSelectedFlag ( FLAG_BLINK_CODE); return; }
 
 
if((Flag[3]&MASK_FLAG_MODE)!=0)  { SendStaticCommands(); SetSelectedFlag ( FLAG___MODE); return; }
if((Flag[3]&MASK_FLAG_LFO)!=0)  { SendLFOCodes(); SetSelectedFlag ( FLAG___LFO); return; }
if((Flag[3]&MASK_FLAG_FM_CODE)!=0) { SendFMCodes(); SetSelectedFlag ( FLAG__FM_CODE); return; }
if((Flag[3]&MASK_FLAG_AM_CODE)!=0)  { SendAMCodes(); SetSelectedFlag ( FLAG__AM_CODE); return;}
 
if((Flag[3]&MASK_FLAG_ATT_CODE)!=0) {SendAttCodes();   SetSelectedFlag( FLAG__ATT_CODE); return ; } //5
if((Flag[3]&MASK_FLAG_HFO_CODE)!=0) { SendHFOCodes(); SetSelectedFlag( FLAG__HFO_CODE);   return ; }
if((Flag[3]&MASK_FLAG_DVDC_CODE)!=0)  { SendDVDCCodes(); SetSelectedFlag( FLAG__DVDC_CODE);   return ; }
return; // goto  LabelPoint1 
} 
 
 
 
//; jump to this subroutine after main , init subs for loop forever if  no interrupts 
 
int  mainsub ()
{
LabelPoint1:
cli();
if( GetDutyReg ( )!=0) { goto LabelOnDutyRegNotZero;}
/* if duty reg=0 */
SendMemWrPulse();
SetAddrWait();
sei();
LabelNoInterrupts:
IntFlags=GetByteIntFlags();
 
if (IntFlags==0) {  /*sleep(); */  goto      LabelNoInterrupts;          }  // ;  loop while no interrupts
cli();
ParseInterrupts(IntFlags); 
//goto  LabelPoint2;
goto  LabelPoint1; 
LabelOnDutyRegNotZero:
SetSelectedFlagZero();
CheckFlags1();
goto LabelPoint1;
return 0;
}
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
03.04.2020, 02:33
Помогаю со студенческими работами здесь

Замена микросхемы на аналоговую
Привет всем. Какой микросхемой можно заменить микросхему FBBHAQ DM0265RB ? Она с платы 'SMPS 888 VER1.1', которая с...

Hp pavilion g6 замена микросхемы видео-чипа
Здравствуйте, может кто-то есть из сервисного центра? Какой срок гарантии дается при замене микросхемы видео-чипа? Отдал в сервисный центр,...

Acer Aspire One D255. Замена микросхемы U13
Здравствуйте форумчане. Имеется Ноут Acer Aspire One D255 (PAV70 LA-6221P Rev:1.0) , у него выгорела микросхема: U13 - G547H2 она же...

Acer aspire 5602wlmi замена сгоревшей микросхемы PG1AY 6900AS
помогите пожалуйста в ноутбуке Acer aspire 5602wlmi сгорела микросхема &quot;PG1AY 6900AS&quot; найти такую же мне не удалось, у меня есть материнка...

СМА Samsung Q1235, Замена микросхемы STK621-015. Есть аналог!!!
Здравствуйте! Подскажите возможна ли замена Микросхемы STK621-015 на STK621-140 трёхфазный инвертор двигателя? На плате MFS-Q1235-00


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
180
Ответ Создать тему
Новые блоги и статьи
Рефакторинг программы уравнивания.
Massaraksh7 26.05.2026
Пример по предыдущей записи в блоге. Но, надо заметить, что, во-первых, там оптимизация не только математики, но и работы с базой данных, и с графами, а во-вторых, это ещё не всё.
Использование TThread в Lazarus для математических вычислений.
Massaraksh7 25.05.2026
Производя рефакторинг своих программ на предмет ускорения их работы, обратил внимание на такой аспект, как сокращение времени матвычислений. Дело в том, что приходится работать с большими матрицами. . .
Модель здравосохранения 18. Чем здоровее работник, тем быстрее выгорает
anaschu 24.05.2026
Имитационная модель корпоративного здравоохранения: что показывает математика Сегодня в модели рабочего коллектива на AnyLogic появились три новые механики — выгорание через накопленную усталость,. . .
Модель здравосохранения 17. Планы на выгорание
anaschu 23.05.2026
Вот конкретная схема реализации: В классе Работник добавить: накопленнаяУсталость — растёт каждый час работы, снижается в перерывы и болезни коэффициентПрезентеизма — снижает продуктивность. . .
Изменение цветов в палитре gif файла aka фавикона
russiannick 23.05.2026
Изменение цветов в палитре gif файла, юзаемого как фавиконка в составе html-файла, помещенная в base64, средствами нативного Java Script, навеянное сном в майский день. Для работы необходим браузер,. . .
Модель здравосохранения 16. Слишком хорошие и здоровые сотрудники уходят, недовольные зарплатой
anaschu 23.05.2026
Отладка увольнений и настройка производительности Сегодня во второй половине дня разобрались с механикой увольнений и настроили коэффициент сложности заданий. Вот что было сделано. . . .
Как я стал коммунистом))) Модель сохранения здоровья сотрудников, запись блога номер 15
anaschu 23.05.2026
Внезапно хорошее здоровье сотрудников не нужно капиталистам?))
Модель здравоСохранения 15. Как мы чинили AnyLogic модель рабочего коллектива: сочленение диаграммы состояний болезней и поломок в ресурспул
anaschu 23.05.2026
Как мы чинили AnyLogic модель рабочего коллектива Сегодня разобрались с пятью багами, из-за которых модель либо падала с ошибкой, либо давала совершенно бессмысленные результаты. Каждый баг был. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru