Александр Сергеевич Пыхтин
RUSSIAN FEDERATION, THE • + Follow
Edit Project
Description
R-022 SW Radio Receiver
Radio receiver for 8 HAM SW bands. Supports SSB and CW modes using two switching 8-crystal filters. IF is 9MHz, VFO based on AD9835 chip, BFO based on two switched crystal oscillators. No coils is used, exept thoroidal transformers at crystal filter ports. LC tanks on RF block are smd. Controller based on ATmega32. Power supply is 3 batteries size 18650, 12V total. AF amp is KA2212 chip. Read more at http://www.cqham.ru/forum/showthread.php?44777
Code
R-022CPU Code
C/C++
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/eeprom.h>
#define DELAY001 /*_delay_us(5u)*/usd(10u);/*display*/
#define DELAY0022 /*_delay_ms(255u);*/msd(75u)/*init_display*/
#define DELAY0012 /*_delay_us(2u)*/usd(5u)/*no_use*/
#define DELAY002 ;;/*_delay_us(5u)*/
#define DELAY003 /*_delay_ms(150u)*/msd(5u)/*keypad*/
#define DELAY004 /*_delay_ms(755u)*/msd(75u)/*no_use*/
#define DELAY005 /*_delay_ms(5u)*/msd(5u)/*no_use*/
#define DELAY006 /*_delay_ms(5u)*/msd(5u)/*no_use*/
#define DELAY00725 ;;/*_delay_us(20u)*/
#define DELAY0086 ;;
#define DELAY00822 /*_delay_ms(2u);*/msd(2u)
unsigned short uusd;mmsd;sdu;sdm;
void usd(uusd){sdu=0u;while(sdu<uusd){sdu++;}sdu=0u;}
void msd(mmsd){sdm=0u;while(sdm<mmsd){sdm++;usd(1000u);}sdm=0u;}
/*V1.01*/
void startstrip(){sa(0u);sft_V();sft_1();sft_point();sft_00();sft_6();sft_probel ();sft_probel ();sft_probel ();}
/*1. display connections work*/
#define p_disp_data PORTC
#define p_disp_clk PORTD
#define p_disp_rs PORTD
#define p_disp_rw PORTD
#define p_disp_led PORTA
#define ddr_disp_data DDRC
#define ddr_disp_clk DDRD
#define ddr_disp_rs DDRD
#define ddr_disp_rw DDRD
#define ddr_disp_led DDRA
#define parametr_disp_clk 7u
#define parametr_disp_rs 5u
#define parametr_disp_rw 6u
#define parametr_disp_led 4u
unsigned char bpde;
unsigned char bpdrs;
unsigned char bpdrw;
unsigned char bpdled;
unsigned char dd077;
unsigned char ahr;
/*3. general calculations*/
unsigned long nn[8u];
unsigned long yy[8u];
unsigned long vlaa;
unsigned long vlbb;
/*=====end 3. general calculations*/
unsigned long fqw;
unsigned char nnflag;
unsigned char mmflag;
unsigned char s08f;
unsigned long st08[5u];
unsigned long wrqst;
unsigned char agcflag;
unsigned char sbflag;
#define encleftport PORTB
#define encleftddr DDRB
#define pin_encleft PINB
#define paramencleft 4u
unsigned char bitraskladkaencleft;
#define encrightport PORTD
#define encrightddr DDRD
#define pin_encright PIND
#define paramencright 4u
unsigned char bitraskladkaencright;
unsigned char encflagl;encflagr;encr_tnflag;encl_tnflag;enciiflag;
/*b002 registers*/
/*b002 keyboard registers work*/
#define p_clk_b002 PORTB/*clock pin11*/
#define p_data_b002 PORTB/*data_pin14*/
#define p_fs_b002 PORTB/*FS pin12*/
#define ddr_clk_b002 DDRB
#define ddr_data_b002 DDRB
#define ddr_fs_b002 DDRB
#define paramtr_clk_b002 2u
#define paramtr_data_b002 1u
#define paramtr_fs_b002 3u/*ST input*/
unsigned char ii_b002;iimsv;ii02msv;
unsigned char ii02_b002;
unsigned char ii03_b002;
unsigned char bitraskladka_clk_b002;
unsigned char bitraskladka_data_b002;
unsigned char bitraskladka_fs_b002;
unsigned char b1_b002;
unsigned char b2_b002;
unsigned short vb1_b002;
unsigned char a002_595flag;
unsigned short b16_b002;
unsigned short vb16_b002;
/*=====end b002 keyboard registers work*/
/*r002 interface registers work*/
#define p_clk_r002 PORTD/*clock pin11*/
#define p_data_r002 PORTB/*data_pin14*/
#define p_fs_r002 PORTD/*FS pin12*/
#define ddr_clk_r002 DDRD
#define ddr_data_r002 DDRB
#define ddr_fs_r002 DDRD
#define paramtr_clk_r002 0u
#define paramtr_data_r002 1u
#define paramtr_fs_r002 1u/*ST input*/
unsigned char ii_r002;
unsigned char ii02_r002;
unsigned char ii03_r002;
unsigned char bitraskladka_clk_r002;
unsigned char bitraskladka_data_r002;
unsigned char bitraskladka_fs_r002;
unsigned char b1_r002;
unsigned char b2_r002;
unsigned short vb1_r002;
unsigned char r002_595flag;
unsigned short b16_r002;
unsigned short vb16_r002;
/*=====end r002 interface registers work*/
/*4 keyboard work*/
unsigned char enf=1u;/*01-band;02-step;03-usb/lsb;04-ssb/cw;05-agc;06-af_amp;07-vcc;*/
unsigned char kkbb;
#define ddr_inputkb DDRD
#define pin_inputkb PIND
#define paramtr_inputkb 3u
unsigned char bitraskladka_inputkb;
unsigned char kb_tnflag;
unsigned char bt16;
unsigned char key_flag;
/*3.1 frequencies of bands and tuning*/
unsigned short b10f;
unsigned short b10ftmp;
unsigned long fqu;
unsigned long fquu;
unsigned long fqd;
unsigned long fqdd;
unsigned long fqkkrr;
unsigned long fqbb[10u];
unsigned char sbf;
unsigned char sbfcrnt;
unsigned char sbfa[10u];
unsigned char agcflag;
unsigned char lightflag;
unsigned char sgr;
unsigned short smetervalue;/*0to14*/
unsigned short smetervaluetemp;
unsigned char fqwwstemp[4u];
unsigned long fqbbtemp;
unsigned short fq16msb;fq16lsb;
unsigned char fqwws [40u] EEMEM;
/*=====end chapter_dch6 others*/
unsigned char adcendflag;
unsigned short resultadch;
unsigned short resultadcl;
unsigned long resultadctemp;
unsigned char ADCinput;
unsigned long adcrrtt;
unsigned char ADC_ii;
unsigned char ADC_samples;
unsigned char sddflag;
unsigned long vlrrd;
unsigned long frqww;
unsigned long mm[8u];
unsigned long frkf=85899346u;
unsigned char modeflag=0u;lm386flag=1u;
/*chapter_dch5 DDS=====================================================================================*/
/*VFO work description*/
#define ppvfs PORTB
#define ppvclk PORTA
#define ppvdta PORTA
unsigned char bitraskladkavfofs;bitraskladkavfoclk;bitraskladkavfodta;
#define ddrvfs DDRB
#define ddrvclk DDRA
#define ddrvdta DDRA
#define paramtrvfs 0u
#define paramtrvclk 4u
#define paramtrvdta 5u
unsigned long fifq;
unsigned long fvfo;
unsigned long DDSfrequencyVFO;
unsigned long DELTAphaseVFO;
unsigned char VFOWORD01;unsigned char VFOWORD02;unsigned char VFOWORD03;unsigned char VFOWORD04;
/*end VFO work description*/
/*BFO work description*/
unsigned long fbfo;
unsigned short WordDDS;
unsigned long WordDDStemp;
unsigned char DDStransferBit;
unsigned char BFOWORD01;unsigned char BFOWORD02;unsigned char BFOWORD03;unsigned char BFOWORD04;
unsigned long VXCOfrequency;
unsigned long DELTAphaseBFO;
unsigned long DDSfrequencyBFO;
unsigned long FreqIF;
unsigned long FreqIFcurrent;
#define ppbfs PORTB
#define ppbclk PORTA
#define ppbdta PORTA
unsigned char bitraskladkabfofs;bitraskladkabfoclk;bitraskladkabfodta;
#define ddrbfs DDRB
#define ddrbclk DDRA
#define ddrbdta DDRA
#define paramtrbfs 0u
#define paramtrbclk 4u
#define paramtrbdta 5u
/*end BFO work description*/
/*register description*/
unsigned short Tr07;
/*end register description*/
/*=====end chapter_dch5 DDS*/
/*chapter_wch3.1 freq_algebraic_calculations=====================================================================================*/
void makedeltha(){numccy();mm[0u]=mm[0u]*frkf;mm[1u]=mm[1u]*frkf;mm[1u]=mm[1u]/10u;mm[2u]=mm[2u]*frkf;mm[2u]=mm[2u]/100u;mm[3u]=mm[3u]*frkf;mm[3u]=mm[3u]/1000u;mm[4u]=mm[4u]*frkf;mm[4u]=mm[4u]/10000u;mm[5u]=mm[5u]*frkf;mm[5u]=mm[5u]/100000u;mm[6u]=mm[6u]*frkf;mm[6u]=mm[6u]/1000000u;mm[7u]=mm[7u]*frkf;mm[7u]=mm[7u]/10000000u;vlrrd=mm[0u];vlrrd=vlrrd+mm[1u];vlrrd=vlrrd+mm[2u];vlrrd=vlrrd+mm[3u];vlrrd=vlrrd+mm[4u];vlrrd=vlrrd+mm[5u];vlrrd=vlrrd+mm[6u];vlrrd=vlrrd+mm[7u];vlrrd=vlrrd*10u;}
/*=====end chapter_wch3.1 freq_algebraic_calculations*/
void numccy (void){cli();mm[0u]=vlrrd/10000000u;mm[1u]=vlrrd-(mm[0u]*10000000u);mm[1u]=mm[1u]/1000000u;mm[2u]=vlrrd-(mm[0u]*10000000u);mm[2u]=mm[2u]-(mm[1u]*1000000u);mm[2u]=mm[2u]/100000u;mm[3u]=vlrrd-(mm[0u]*10000000u);mm[3u]=mm[3u]-(mm[1u]*1000000u);mm[3u]=mm[3u]-(mm[2u]*100000u);mm[3u]=mm[3u]/10000u;mm[4u]=vlrrd-(mm[0u]*10000000u);mm[4u]=mm[4u]-(mm[1u]*1000000u);mm[4u]=mm[4u]-(mm[2u]*100000u);mm[4u]=mm[4u]-(mm[3u]*10000u);mm[4u]=mm[4u]/1000u;mm[5u]=vlrrd-(mm[0u]*10000000u);mm[5u]=mm[5u]-(mm[1u]*1000000u);mm[5u]=mm[5u]-(mm[2u]*100000u);mm[5u]=mm[5u]-(mm[3u]*10000u);mm[5u]=mm[5u]-(mm[4u]*1000u);mm[5u]=mm[5u]/100u;mm[6u]=vlrrd-(mm[0u]*10000000u);mm[6u]=mm[6u]-(mm[1u]*1000000u);mm[6u]=mm[6u]-(mm[2u]*100000u);mm[6u]=mm[6u]-(mm[3u]*10000u);mm[6u]=mm[6u]-(mm[4u]*1000u);mm[6u]=mm[6u]-(mm[5u]*100u);mm[6u]=mm[6u]/10u;mm[7u]=vlrrd-(mm[0u]*10000000u);mm[7u]=mm[7u]-(mm[1u]*1000000u);mm[7u]=mm[7u]-(mm[2u]*100000u);mm[7u]=mm[7u]-(mm[3u]*10000u);mm[7u]=mm[7u]-(mm[4u]*1000u);mm[7u]=mm[7u]-(mm[5u]*100u);mm[7u]=mm[7u]-(mm[6u]*10u);}
void keyscaninit (){kb_tnflag=0b00000001<<paramtr_inputkb;ddr_inputkb=ddr_inputkb&(~kb_tnflag);key_flag=0u;}
void keyscan (){work_b002();bt16=pin_inputkb&kb_tnflag;}
void sethc02(){
b16_b002=b16_b002&0x00FF;
b16_b002=b16_b002|(1u<<kkbb);
}
void keypadblock(){key01();key02();key05();key07();key08();key06();key03();key04();}
void keypadsbros (){sbrf_key01 ();sbrf_key02 ();sbrf_key05 ();sbrf_key07 ();sbrf_key06 ();sbrf_key03 ();sbrf_key04 ();sbrf_key08 ();}
void keymainblock (){keypadblock();DELAY003;keypadsbros ();/*keyscan ();if(bt16!=kb_tnflag){keypadsbros ();DELAY003;}*/}
/*keyboard buttons work*/
void key01 ()/*enc*/{kkbb=8u;sethc02();keyscan ();if (bt16==kb_tnflag){if (key_flag!=1u){setflag_key01 ();func_key01 ();disp_key01 ();}/*end if*/}/*end if*/bt16=0u;}
void setflag_key01 (){key_flag=1u;}
void sbrf_key01 (){if (key_flag==1u){kkbb=8u;sethc02();keyscan ();if(bt16!=kb_tnflag){key_flag=0u;}}}/*delete only if flag==1u*/
void func_key01 (){enf=2u;sddflag=1u;s08f++;if(s08f>4u){s08f=0u;}stdefinir();}
void disp_key01 (){textstep();}
/*==========key==========*/
void key02 ()/*band_up*/{kkbb=14u;sethc02();keyscan ();if (bt16==kb_tnflag){if (key_flag!=2u){setflag_key02 ();func_key02 ();disp_key02 ();}/*end if*/}/*end if*/bt16=0u;}
void setflag_key02 (){key_flag=2u;}
void sbrf_key02 (){if (key_flag==2u){kkbb=14u;sethc02();keyscan ();if(bt16!=kb_tnflag){key_flag=0u;}}}/*delete only if flag==2u*/
void func_key02 (){
if(enf==1u){sddflag=1u;lvb ();b10f++;if(b10f>9u){b10f=1u;}if(b10f==6u){b10f=7u;}arvb ();rband();tunevfo();}
if(enf==2u){sddflag=1u;s08f++;if(s08f>4u){s08f=0u;}stdefinir();}
if(enf==3u){sddflag=1u;sbf=1u;}
if(enf==4u){modeflag=0u;}
}
void disp_key02 (){
if(enf==1u){textnmband();frdisp();r595w();}
if(enf==2u){textstep();}
if(enf==3u){sbtext();r595w();}
if(enf==4u){modetext();r595w();}
}
/*==========key==========*/
void key07 ()/*band_down*/{kkbb=15u;sethc02();keyscan ();if (bt16==kb_tnflag){if (key_flag!=7u){setflag_key07 ();func_key07 ();disp_key07 ();}/*end if*/}/*end if*/bt16=0u;}
void setflag_key07 (){key_flag=7u;}
void sbrf_key07 (){if (key_flag==7u){kkbb=15u;sethc02();keyscan ();if(bt16!=kb_tnflag){key_flag=0u;}}}/*delete only if flag==16u*/
void func_key07 (){
if(enf==1u){sddflag=1u;lvb ();b10f--;if(b10f<1u){b10f=9u;}if(b10f==6u){b10f=5u;}arvb ();rband();tunevfo();}
if(enf==2u){sddflag=1u;if(s08f==0u){s08f=5u;}s08f--;stdefinir();}
if(enf==3u){sddflag=1u;sbf=0u;}
if(enf==4u){modeflag=1u;}
}
void disp_key07 (){
if(enf==1u){textnmband();frdisp();r595w();}
if(enf==2u){textstep();}
if(enf==3u){sbtext();r595w();}
if(enf==4u){modetext();r595w();}
}
/*==========key==========*/
void key03 ()/*select*/{kkbb=12u;sethc02();keyscan ();if (bt16==kb_tnflag){if (key_flag!=3u){setflag_key03 ();func_key03 ();disp_key03 ();}/*end if*/}/*end if*/bt16=0u;}
void setflag_key03 (){key_flag=3u;}
void sbrf_key03 (){if (key_flag==3u){kkbb=12u;sethc02();keyscan ();if(bt16!=kb_tnflag){key_flag=0u;}}}/*delete only if flag==16u*/
void func_key03 (){enf++;if(enf==7u){enf=1u;}
/*sddflag=1u;agcflag=~agcflag;agcflag=agcflag&1u;if (agcflag==1u){b16_r002=b16_r002|(1u<<13u);work_r002();}if (agcflag==0u){b16_r002=b16_r002&(~(1u<<13u));work_r002();}*/
}
void disp_key03 (){sddflag=1u;
if(enf==1u){textnmband();frdisp();r595w();}
if(enf==2u){textstep();}
if(enf==3u){sbtext();r595w();}
if(enf==4u){modetext();r595w();}
if(enf==5u){agctext();r595w();}
if(enf==6u){afamptext();r595w();}
/*if(enf==7u){;}
agctext();r595w();*/
}
/*==========key==========*/
void key04 ()/*on/off*/{kkbb=11u;sethc02();keyscan ();if (bt16==kb_tnflag){if (key_flag!=4u){setflag_key04 ();func_key04 ();disp_key04 ();}/*end if*/}/*end if*/bt16=0u;}
void setflag_key04 (){key_flag=4u;}
void sbrf_key04 (){if (key_flag==4u){kkbb=11u;sethc02();keyscan ();if(bt16!=kb_tnflag){key_flag=0u;}}}/*delete only if flag==16u*/
void func_key04 (){
if(enf==5u){agcflag=~agcflag;agcflag=agcflag&1u;if (agcflag==1u){b16_r002=b16_r002|(1u<<13u);work_r002();}if (agcflag==0u){b16_r002=b16_r002&(~(1u<<13u));work_r002();};}
if(enf==6u){lm386flag=~lm386flag;lm386flag=lm386flag&1u;
}
/*sddflag=1u;sbf=~sbf;sbf=sbf&1u;*/
}
void disp_key04 (){
/*sbtext();r595w();*/
if(enf==5u){agctext();r595w();;}
if(enf==6u){afamptext();r595w();;}
}
/*==========key==========*/
void key05 ()/*light*/{kkbb=9u;sethc02();keyscan ();if (bt16==kb_tnflag){if (key_flag!=5u){setflag_key05 ();func_key05 ();disp_key05 ();}/*end if*/}/*end if*/bt16=0u;}
void setflag_key05 (){key_flag=5u;}
void sbrf_key05 (){if (key_flag==5u){kkbb=9u;sethc02();keyscan ();if(bt16!=kb_tnflag){key_flag=0u;}}}/*delete only if flag==16u*/
void func_key05 (){sddflag=1u;lightflag=~lightflag;lightflag=lightflag&1u;}
void disp_key05 (){if(lightflag==0u){backlightoff();}if(lightflag==1u){backlighton();};}
/*==========key==========*/
void key06 ()/*esc*/{kkbb=13u;sethc02();keyscan ();if (bt16==kb_tnflag){if (key_flag!=6u){setflag_key06 ();func_key06 ();disp_key06 ();}/*end if*/}/*end if*/bt16=0u;}
void setflag_key06 (){key_flag=6u;}
void sbrf_key06 (){if (key_flag==6u){kkbb=13u;sethc02();keyscan ();if(bt16!=kb_tnflag){key_flag=0u;}}}/*delete only if flag==16u*/
void func_key06 (){sddflag=0u;enf=1u;}
void disp_key06 (){;}
/*==========key==========*/
void key08 ()/*vcc*/{kkbb=10u;sethc02();keyscan ();if (bt16==kb_tnflag){if (key_flag!=8u){setflag_key08 ();func_key08 ();disp_key08 ();}/*end if*/}/*end if*/bt16=0u;}
void setflag_key08 (){key_flag=8u;}
void sbrf_key08 (){if (key_flag==8u){kkbb=10u;sethc02();keyscan ();if(bt16!=kb_tnflag){key_flag=0u;}}}/*delete only if flag==16u*/
void func_key08 (){sddflag=1u;
/*fqwws[0u]=fqbb[0u];*/
}
void disp_key08 (){vcctext();}
/*==========key==========*/
void savetext()
{sa(40u);sft_s();sft_a();sft_v();sft_e();sft_d();sft_probel();sft_probel();sft_probel();;}
void maketosave()
{/*
lvb ();arvb();fqbb[0u]=fqw;
fqbbtemp=fqbb[0u];
fqbbtemp=fqbbtemp&0b11111111111111110000000000000000;fqbbtemp=fqbbtemp>>16u;
fq16msb=fqbbtemp;
fq16msb=fq16msb>>8u;
fq16msb=fq16msb&0b0000000011111111;
fqwwstemp[0u]=fq16msb;
fq16msb=fqbbtemp;fq16msb=0b0000000000011100;
fq16msb=fq16msb&0b0000000011111111;
fqwwstemp[1u]=fq16msb;
fqbbtemp=fqbb[0u];
fqbbtemp=fqbbtemp&0b00000000000000001111111111111111;
fq16lsb=fqbbtemp;fq16lsb=0b0100001100101000;
fq16lsb=fq16lsb>>8u;
fq16lsb=fq16lsb&0b0000000011111111;
fqwwstemp[2u]=fq16lsb;
fq16lsb=fqbbtemp;fq16lsb=0b0100001100101000;
fq16lsb=fq16lsb&0b0000000011111111;
fqwwstemp[3u]=fq16lsb;
ii02msv=0u;
fqwwstemp[0u]=0u;
fqwwstemp[1u]=0b00011100;
fqwwstemp[2u]=0b01000011;
fqwwstemp[3u]=0b00101000;
works
eeprom_write_byte(&fqwws[0u],fqwwstemp[0u]);ii02msv++;
eeprom_write_byte(&fqwws[1u],fqwwstemp[1u]);ii02msv++;
eeprom_write_byte(&fqwws[2u],fqwwstemp[2u]);ii02msv++;
eeprom_write_byte(&fqwws[3u],fqwwstemp[3u]);ii02msv++;
ii02msv=0u;*/
;
}
void r595w()
{
if(lm386flag==0u){b16_r002=b16_r002&(~(1u<<13u));work_r002();b16_b002=b16_b002&(~(1u<<2u));}
if(lm386flag==1u){b16_r002=b16_r002|(1u<<13u);work_r002();b16_b002=b16_b002|(1u<<2u);}
if(agcflag==0u){b16_b002=b16_b002&(~(1u<<1u));b16_r002=b16_r002&(~(1u<<8u));work_r002();}
if(agcflag!=0u){b16_b002=b16_b002|(1u<<1u);b16_r002=b16_r002|(1u<<8u);work_r002();}
if(modeflag==0u)
{
if(sbf==0u){b16_b002=b16_b002&(~(1u<<7u));b16_b002=b16_b002|(1u<<6u);b16_r002=b16_r002&(~(1u<<9u));b16_r002=b16_r002|(1u<<10u);work_r002();}/*lsb*/
if(sbf!=0u){b16_b002=b16_b002&(~(1u<<6u));b16_b002=b16_b002|(1u<<7u);b16_r002=b16_r002|(1u<<9u);b16_r002=b16_r002&(~(1u<<10u));work_r002();}/*usb*/
b16_r002=b16_r002|(1u<<11u);b16_r002=b16_r002&(~(1u<<12u));work_r002();
b16_b002=b16_b002|(1u<<3u);b16_b002=b16_b002&(~(1u<<4u));
}
if(modeflag==1u)
{
b16_b002=b16_b002|(1u<<4u);b16_b002=b16_b002&(~(1u<<3u));
b16_r002=b16_r002|(1u<<12u);b16_r002=b16_r002&(~(1u<<11u));work_r002();
b16_r002=b16_r002|(1u<<9u);b16_r002=b16_r002&(~(1u<<10u));work_r002();/*bfo select*/
;
}
work_b002();}
void allbtsh(){
b16_b002=b16_b002|0xFF00;
work_b002();
}
void setfrqb(){ fqkkrr=5000u;if (b10f==1u){fqd=1800000u;fqu=2000000u;fquu=fqu+fqkkrr;fqdd=fqd-fqkkrr;}if (b10f==2u){fqd=3500000u;fqu=3800000u;fquu=fqu+fqkkrr;fqdd=fqd-fqkkrr;}if (b10f==3u){fqd=7000000u;fqu=7200000u;fquu=fqu+fqkkrr;fqdd=fqd-fqkkrr;}if (b10f==4u){fqd=10100000u;fqu=10150000u;fquu=fqu+fqkkrr;fqdd=fqd-fqkkrr;}if (b10f==5u){fqd=14000000u;fqu=14350000u;fquu=fqu+fqkkrr;fqdd=fqd-fqkkrr;}if (b10f==6u){fqd=18068000u;fqu=18168000u;fquu=fqu+fqkkrr;fqdd=fqd-fqkkrr;}if (b10f==7u){fqd=21000000u;fqu=21450000u;fquu=fqu+fqkkrr;fqdd=fqd-fqkkrr;}if (b10f==8u){fqd=24890000u;fqu=24990000u;fquu=fqu+fqkkrr;fqdd=fqd-fqkkrr;}if (b10f==9u){fqd=28000000u;fqu=29700000u;fquu=fqu+fqkkrr;fqdd=fqd-fqkkrr;}if (b10f==10u){fqd=50000000u;fqu=54000000u;fquu=fqu+fqkkrr;fqdd=fqd-fqkkrr;};}
void lvb ()/*leave band*/{ if (b10f==1u){fqbb[0u]=fqw;}if (b10f==2u){fqbb[1u]=fqw;}if (b10f==3u){fqbb[2u]=fqw;}if (b10f==4u){fqbb[3u]=fqw;}if (b10f==5u){fqbb[4u]=fqw;}if (b10f==6u){fqbb[5u]=fqw;}if (b10f==7u){fqbb[6u]=fqw;}if (b10f==8u){fqbb[7u]=fqw;}if (b10f==9u){fqbb[8u]=fqw;}if (b10f==10u){fqbb[9u]=fqw;};}
void arvb ()/*arrive to band*/{ setfrqb();fqw=fqbb[b10f-1u];arvbul ();}
void initfreq(){ b10f=1u;setfrqb();fqbb[0u]=fqd;b10f++;setfrqb();fqbb[1u]=fqd;b10f++;setfrqb();fqbb[2u]=fqd;b10f++;setfrqb();fqbb[3u]=fqd;b10f++;setfrqb();fqbb[4u]=fqd;b10f++;setfrqb();fqbb[5u]=fqd;b10f++;setfrqb();fqbb[6u]=fqd;b10f++;setfrqb();fqbb[7u]=fqd;b10f++;setfrqb();fqbb[8u]=fqd;b10f++;setfrqb();fqbb[9u]=fqd;b10f++;b10f=1u;}
void arvbul ()/*arrive to band sbf*/{ if(b10f==1u){sbf=sbfa[0u];};if(b10f==2u){sbf=sbfa[1u];};if(b10f==3u){sbf=sbfa[2u];};if(b10f==4u){sbf=sbfa[3u];};if(b10f==5u){sbf=sbfa[4u];};if(b10f==6u){sbf=sbfa[5u];};if(b10f==7u){sbf=sbfa[6u];};if(b10f==8u){sbf=sbfa[7u];};if(b10f==9u){sbf=sbfa[8u];};if(b10f==10u){sbf=sbfa[9u];};}
void ulfset ()/*switching and set*/{ if(b10f==1u){sbfa[0u]=sbf;};if(b10f==2u){sbfa[1u]=sbf;};if(b10f==3u){sbfa[2u]=sbf;};if(b10f==4u){sbfa[3u]=sbf;};if(b10f==5u){sbfa[4u]=sbf;};if(b10f==6u){sbfa[5u]=sbf;};if(b10f==7u){sbfa[6u]=sbf;};if(b10f==8u){sbfa[7u]=sbf;};if(b10f==9u){sbfa[8u]=sbf;};if(b10f==10u){sbfa[9u]=sbf;};}
void makebandfreq (){if (b10f==1u){fqbb[0u]=fqw;}if (b10f==2u){fqbb[1u]=fqw;}if (b10f==3u){fqbb[2u]=fqw;}if (b10f==4u){fqbb[3u]=fqw;}if (b10f==5u){fqbb[4u]=fqw;}if (b10f==6u){fqbb[5u]=fqw;}if (b10f==7u){fqbb[6u]=fqw;}if (b10f==8u){fqbb[7u]=fqw;}if (b10f==9u){fqbb[8u]=fqw;}if (b10f==10u){fqbb[9u]=fqw;}}
void rband(){b16_r002=b16_r002&0xFF00;
if(b10f<6u){b16_r002=b16_r002|(1u<<(b10f-1u));}
if(b10f>6u){b16_r002=b16_r002|(1u<<(b10f-2u));}
work_r002();}
void bf998on(){;/*b16_r002=b16_r002&(~(1u<<11u));work_r002();*/}
void lm386on(){b16_r002=b16_r002|(1u<<10u);work_r002();}
void encscaninit(){ encr_tnflag=1u<<paramencright;encl_tnflag=1u<<paramencleft;enciiflag=0u;encleftddr=encleftddr&(~(encl_tnflag));encrightddr=encrightddr&(~(encr_tnflag));}
void portsinit()
{
DDRA=0xFF;DDRB=0xFF;DDRC=0xFF;DDRD=0xFF;
PORTA=0u;PORTB=0u;PORTC=0u;PORTD=0u;
;
}
void sasgram(sgr){ dd077=sgr|0b01000000;dispcommand();}
void makesymbol01(){sasgram(0u);dispdata(0b00000000);sasgram(1u);dispdata(0b00011011);sasgram(2u);dispdata(0b00011011);sasgram(3u);dispdata(0b00011011);sasgram(4u);dispdata(0b00011011);sasgram(5u);dispdata(0b00011011);sasgram(6u);dispdata(0b00011011);sasgram(7u);dispdata(0b00000000);}
void makesymbol02(){sasgram(8u);dispdata(0b00000000);sasgram(9u);dispdata(0b00011000);sasgram(10u);dispdata(0b00011000);sasgram(11u);dispdata(0b00011000);sasgram(12u);dispdata(0b00011000);sasgram(13u);dispdata(0b00011000);sasgram(14u);dispdata(0b00011000);sasgram(15u);dispdata(0b00000000);}
void dispportinit(){ bpde=1u<<parametr_disp_clk;ddr_disp_clk=ddr_disp_clk|bpde;bpdrs=1u<<parametr_disp_rs;ddr_disp_rs=ddr_disp_rs|bpdrs;bpdrw=1u<<parametr_disp_rw;ddr_disp_rw=ddr_disp_rw|bpdrw;bpdled=1u<<parametr_disp_led;ddr_disp_led=ddr_disp_led|bpdled;}
void backlighton(){b16_b002=b16_b002|1u;work_b002();}
void backlightoff(){b16_b002=b16_b002&(~1u);work_b002();}
void dseh(){ p_disp_clk=p_disp_clk|bpde;}
void dsel(){ p_disp_clk=p_disp_clk&(~bpde);}
void dsrsh (){ p_disp_rs=p_disp_rs|bpdrs;}
void dsrsl (){ p_disp_rs=p_disp_rs&(~bpdrs);}
void dsrwh(){ p_disp_rw=p_disp_rw|bpdrw;}
void dsrwl(){ p_disp_rw=p_disp_rw&(~bpdrw);}
void dispdata(dd077){ dsrwl();dsrsh();p_disp_data=dd077;dseh();DELAY001;dsel();DELAY001;}
void dispcommand(){ dsrwl();dsrsl();p_disp_data=dd077;dseh();DELAY001;dsel();DELAY001;}
void dispinit(){DELAY0022;dd077=0b00000110;dispcommand ();dd077=0b00111100;dispcommand ();dd077=0b00001100;dispcommand ();DELAY0022;dd077=0b00000110;dispcommand ();}
void sa(ahr){ dd077=0b10000000|ahr;dispcommand();}
void main ()
{
ccli();
portsinit();
dispportinit();
dispinit();
masterinit();
backlighton();
startstrip();
startstrip002();
msd(750u);
frdisp();
smetervalue=5u;
smetertext();
interruptsinit();
makesymbol01();
makesymbol02();
tunevfo();
lm386flag=1u;
b16_r002=b16_r002|(1u<<10u);work_r002();
while(1)
{
ssei();
/*_delay_ms(5u);*/DELAY00822;
ccli();
if(enciiflag!=0u){frdisp();enciiflag=0u;}
keymainblock ();
ADCinput=3u;adcrrtt=0u;adcscan256();smetervalue=adcrrtt;
ADCinput=0u;adcrrtt=0u;adcscan256();
if(smetervalue>adcrrtt){smetervalue=smetervalue-adcrrtt;}
else{smetervalue=0u;};
if(smetervalue>14u){smetervalue=14u;}
smetertext();
;
}
;
}
void masterinit()
{
b16_b002=0u;
b16_r002=0u;
b10f=2u;
s08f=0u;
st08[0u]=10u;
st08[1u]=50u;
st08[2u]=100u;
st08[3u]=500u;
st08[4u]=1000u;
sbfa[0u]=0u;sbfa[1u]=0u;sbfa[2u]=0u;sbfa[3u]=0u;sbfa[4u]=1u;sbfa[5u]=1u;sbfa[6u]=1u;sbfa[7u]=1u;sbfa[8u]=1u;sbfa[9u]=1u;
stdefinir();
sddflag=0u;
encscaninit();
init_b002();
init_r002();
allbtsh();
keyscaninit ();
setfrqb();initfreq();
/*
iimsv=0u;ii02msv=0u;
ii02msv=0u;
fqwwstemp[0u]=eeprom_read_byte(&fqwws[0u]);ii02msv++;
fqwwstemp[1u]=eeprom_read_byte(&fqwws[1u]);ii02msv++;
fqwwstemp[2u]=eeprom_read_byte(&fqwws[2u]);ii02msv++;
fqwwstemp[3u]=eeprom_read_byte(&fqwws[3u]);ii02msv++;
ii02msv=0u;
fqwwstemp[0u]=0u;
fqwwstemp[1u]=0b00011100;
fqwwstemp[2u]=0b01000011;
fqwwstemp[3u]=0b00101000;
fq16msb=fqwwstemp[0u];fq16msb=fq16msb<<8u;fq16msb=fq16msb|fqwwstemp[1u];
fq16lsb=fqwwstemp[2u];fq16lsb=fq16lsb<<8u;fq16lsb=fq16lsb|fqwwstemp[3u];
fqbb[0u]=fq16msb;fqbb[0u]=fqbb[0u]<<16u;
fqbb[0u]=fqbb[0u]|fq16lsb;
iimsv=0u;ii02msv=0u;
*/
arvb ();rband();
agcflag=1u;
lightflag=1u;
if(lightflag==0u){backlightoff();}if(lightflag==1u){backlighton();};
fifq=9000000u;
initvfobfo ();
VFOinit();
tunevfo();
b16_r002=b16_r002&(~(1u<<10u));work_r002();
work_r002();
lm386on();
bf998on();
r595w();
;
}
void vcctext(){sa(40u);sft_V();sft_c();sft_c();sft_1();sft_2();sft_point();sft_00();sft_V();}
void afamptext(){sa(40u);sft_S();sft_p();sft_k();sft_r();sft_probel ();if(lm386flag==0u){sft_O();sft_F();sft_F();}if(lm386flag==1u){sft_O();sft_N();sft_probel();}}
void modetext(){sa(40u);sft_m();sft_o();sft_d();sft_e();sft_probel ();if(modeflag==0u){sft_S();sft_S();sft_B();}if(modeflag==1u){sft_C();sft_W();sft_probel ();}sft_probel ();}
void sbtext(){sa(40u);sft_m();sft_o();sft_d();sft_e();sft_probel ();if(sbf==0u){sft_L();sft_S();sft_B();}if(sbf==1u){sft_U();sft_S();sft_B();}sft_probel ();}
void smetertext(){if(sddflag==0u){sa(40u);sft_S();ahr=41u;smetervaluetemp=smetervalue/2u;while(smetervaluetemp>0u){dispdata(0u);ahr++;smetervaluetemp--;}smetervaluetemp=smetervalue/2u;
smetervaluetemp=smetervaluetemp*2u;smetervaluetemp=smetervalue-smetervaluetemp;
if(smetervaluetemp!=0u){dispdata(1u);ahr++;}
while(ahr<48u){sft_probel ();ahr++;}
}}
void startstrip002(){vlbb=fifq;numbby ();sa(40u);sft_I();sft_F();nnflag=yy[0u];nndisp();nnflag=yy[1u];nndisp();nnflag=yy[2u];nndisp();nnflag=yy[3u];nndisp();nnflag=yy[4u];nndisp();nnflag=yy[5u];nndisp();}
void numaan (){ vlaa=fqw;nn[0u]=vlaa/10000000u;nn[1u]=vlaa-(nn[0u]*10000000u);nn[1u]=nn[1u]/1000000u;nn[2u]=vlaa-(nn[0u]*10000000u);nn[2u]=nn[2u]-(nn[1u]*1000000u);nn[2u]=nn[2u]/100000u;nn[3u]=vlaa-(nn[0u]*10000000u);nn[3u]=nn[3u]-(nn[1u]*1000000u);nn[3u]=nn[3u]-(nn[2u]*100000u);nn[3u]=nn[3u]/10000u;nn[4u]=vlaa-(nn[0u]*10000000u);nn[4u]=nn[4u]-(nn[1u]*1000000u);nn[4u]=nn[4u]-(nn[2u]*100000u);nn[4u]=nn[4u]-(nn[3u]*10000u);nn[4u]=nn[4u]/1000u;nn[5u]=vlaa-(nn[0u]*10000000u);nn[5u]=nn[5u]-(nn[1u]*1000000u);nn[5u]=nn[5u]-(nn[2u]*100000u);nn[5u]=nn[5u]-(nn[3u]*10000u);nn[5u]=nn[5u]-(nn[4u]*1000u);nn[5u]=nn[5u]/100u;nn[6u]=vlaa-(nn[0u]*10000000u);nn[6u]=nn[6u]-(nn[1u]*1000000u);nn[6u]=nn[6u]-(nn[2u]*100000u);nn[6u]=nn[6u]-(nn[3u]*10000u);nn[6u]=nn[6u]-(nn[4u]*1000u);nn[6u]=nn[6u]-(nn[5u]*100u);nn[6u]=nn[6u]/10u;nn[7u]=vlaa-(nn[0u]*10000000u);nn[7u]=nn[7u]-(nn[1u]*1000000u);nn[7u]=nn[7u]-(nn[2u]*100000u);nn[7u]=nn[7u]-(nn[3u]*10000u);nn[7u]=nn[7u]-(nn[4u]*1000u);nn[7u]=nn[7u]-(nn[5u]*100u);nn[7u]=nn[7u]-(nn[6u]*10u);}
void numbby (){ yy[0u]=vlbb/10000000u;yy[1u]=vlbb-(yy[0u]*10000000u);yy[1u]=yy[1u]/1000000u;yy[2u]=vlbb-(yy[0u]*10000000u);yy[2u]=yy[2u]-(yy[1u]*1000000u);yy[2u]=yy[2u]/100000u;yy[3u]=vlbb-(yy[0u]*10000000u);yy[3u]=yy[3u]-(yy[1u]*1000000u);yy[3u]=yy[3u]-(yy[2u]*100000u);yy[3u]=yy[3u]/10000u;yy[4u]=vlbb-(yy[0u]*10000000u);yy[4u]=yy[4u]-(yy[1u]*1000000u);yy[4u]=yy[4u]-(yy[2u]*100000u);yy[4u]=yy[4u]-(yy[3u]*10000u);yy[4u]=yy[4u]/1000u;yy[5u]=vlbb-(yy[0u]*10000000u);yy[5u]=yy[5u]-(yy[1u]*1000000u);yy[5u]=yy[5u]-(yy[2u]*100000u);yy[5u]=yy[5u]-(yy[3u]*10000u);yy[5u]=yy[5u]-(yy[4u]*1000u);yy[5u]=yy[5u]/100u;yy[6u]=vlbb-(yy[0u]*10000000u);yy[6u]=yy[6u]-(yy[1u]*1000000u);yy[6u]=yy[6u]-(yy[2u]*100000u);yy[6u]=yy[6u]-(yy[3u]*10000u);yy[6u]=yy[6u]-(yy[4u]*1000u);yy[6u]=yy[6u]-(yy[5u]*100u);yy[6u]=yy[6u]/10u;yy[7u]=vlbb-(yy[0u]*10000000u);yy[7u]=yy[7u]-(yy[1u]*1000000u);yy[7u]=yy[7u]-(yy[2u]*100000u);yy[7u]=yy[7u]-(yy[3u]*10000u);yy[7u]=yy[7u]-(yy[4u]*1000u);yy[7u]=yy[7u]-(yy[5u]*100u);yy[7u]=yy[7u]-(yy[6u]*10u);}
void mmdisp (){ dd077=mmflag+0x30;dispdata();}
void nndisp (){ dd077=nnflag+0x30;dispdata();}
void frdisp(){ numaan();sa(0u);nnflag=nn[0u];nndisp();nnflag=nn[1u];nndisp();sft_point ();nnflag=nn[2u];nndisp();nnflag=nn[3u];nndisp();nnflag=nn[4u];nndisp();nnflag=nn[5u];nndisp();nnflag=nn[6u];nndisp();}
void textnmband(){ sa(40u);sft_b();sft_a();sft_n();sft_d ();
if(b10f==1u){sft_1();sft_6();sft_00();sft_m();}
if(b10f==2u){sft_probel ();sft_8();sft_00();sft_m();}
if(b10f==3u){sft_probel ();sft_4();sft_00();sft_m();}
if(b10f==4u){sft_probel ();sft_3();sft_00();sft_m();}
if(b10f==5u){sft_probel ();sft_2();sft_00();sft_m();}
if(b10f==6u){sft_probel ();sft_1();sft_7();sft_m();}
if(b10f==7u){sft_probel ();sft_1();sft_5();sft_m();}
if(b10f==8u){sft_probel ();sft_1();sft_2();sft_m();}
if(b10f==9u){sft_probel ();sft_1();sft_00();sft_m();}
if(b10f==10u){sft_probel ();sft_00();sft_6();sft_m();}
}
void agctext(){ sa(40u);sft_A();sft_G();sft_C();sft_probel ();if(agcflag==0u){sft_o();sft_f();sft_f();sft_probel ();}if(agcflag==1u){sft_o();sft_n();sft_probel ();sft_probel ();};}
void textstep(){ stdefinir();sa(40u);if(wrqst<1000u){sft_s();sft_t();sft_p();sft_probel ();vlbb=wrqst;numbby ();
if(wrqst<100u){mmflag=yy[6u];mmdisp();mmflag=yy[7u];mmdisp();sft_H();sft_z();}
if(wrqst>99u){mmflag=yy[4u];mmdisp();sft_point ();mmflag=yy[5u];mmdisp();sft_k();}
}
if(wrqst>999u){ sft_s();sft_t();sft_p();sft_probel ();vlbb=wrqst;numbby ();mmflag=yy[4u];mmdisp();sft_point ();mmflag=yy[5u];mmdisp();sft_k();}
}
void stdefinir(){ wrqst=st08[s08f];}
void interruptsinit(){
SREG=0b10000000;risingedgeint00();/*risingedgeint01();*/}
void risingedgeint00(){ MCUCR=MCUCR|0b00000011;GICR=GICR|0b01000000;DDRD=DDRD&(~(1u<<2u));}
void risingedgeint01(){ MCUCR=MCUCR|0b00001100;GICR=GICR|0b10000000;DDRD=DDRD&(~(1u<<3u));}
void encscan(){ encflagl=pin_encleft&encl_tnflag;encflagr=pin_encright&encr_tnflag;
if(encflagl!=0u){encflagl=0b00000001;}
if(encflagr!=0u){encflagr=0b00000010;}
}
ISR(INT0_vect){
ccli();encscan();DELAY00822;if(encflagl==0b00000001){enctuneup ();}if(encflagr==0b00000010){enctunedwn ();}enciiflag++;
if(enciiflag>20u){frdisp();enciiflag=0u;}
}
/*ISR(INT1_vect){keymainblock ();allbtsh();}*/
void enctuneup (){if(fqw<fquu){fqw=fqw+wrqst;}else{fqw=fquu;}tunevfo();}
void enctunedwn (){if(fqw>fqdd){fqw=fqw-wrqst;}else{fqw=fqdd;}tunevfo();}
/*keyboard interface kb022 work*/
void init_b002() {bitraskladka_clk_b002=0b00000001<<paramtr_clk_b002;bitraskladka_fs_b002=0b00000001<<paramtr_fs_b002;bitraskladka_data_b002=0b00000001<<paramtr_data_b002;init_b002ddr();}/*end init_b002b*/
void init_b002ddr(){ddr_clk_b002=ddr_clk_b002|bitraskladka_clk_b002;ddr_fs_b002=ddr_fs_b002|bitraskladka_fs_b002;ddr_data_b002=ddr_data_b002|bitraskladka_data_b002;}
void clk_b002_H() {p_clk_b002=p_clk_b002|bitraskladka_clk_b002;}
void clk_b002_L() {p_clk_b002=p_clk_b002&(~bitraskladka_clk_b002);}
void fs_b002_H() { p_fs_b002=p_fs_b002|bitraskladka_fs_b002;}
void fs_b002_L() { p_fs_b002=p_fs_b002&(~bitraskladka_fs_b002);}
void work_b002(){vb16_b002=b16_b002>>8u;vb16_b002=vb16_b002&0b0000000011111111;b1_b002=vb16_b002;vb16_b002=b16_b002&0b0000000011111111;b2_b002=vb16_b002;fs_b002_H();DELAY002;fs_b002_L();DELAY002;ii_b002=0u;a002_595flag=0u;while (ii_b002<16u)/*number of register bits*/{if (a002_595flag==0u){ii02_b002=ii_b002;vb1_b002=b1_b002;ii02_b002=7u-ii02_b002;vb1_b002=vb1_b002>>ii02_b002;vb1_b002=vb1_b002<<paramtr_data_b002;vb1_b002=vb1_b002&bitraskladka_data_b002;p_data_b002=p_data_b002&(~bitraskladka_data_b002);p_data_b002=p_data_b002|vb1_b002;clk_b002_L();DELAY002;clk_b002_H();DELAY002;clk_b002_L();DELAY002;p_data_b002=p_data_b002&(~bitraskladka_data_b002);if (ii_b002==7u){a002_595flag++;}ii_b002++;}/*end if*/if (a002_595flag==1u){ii02_b002=ii_b002-8u;vb1_b002=b2_b002;ii02_b002=7u-ii02_b002;vb1_b002=vb1_b002>>ii02_b002;vb1_b002=vb1_b002<<paramtr_data_b002;vb1_b002=vb1_b002&bitraskladka_data_b002;p_data_b002=p_data_b002&(~bitraskladka_data_b002);p_data_b002=p_data_b002|vb1_b002;clk_b002_L();DELAY002;clk_b002_H();DELAY002;clk_b002_L();DELAY002;p_data_b002=p_data_b002&(~bitraskladka_data_b002);if (ii_b002==15u){a002_595flag++;}ii_b002++;}/*end if*/}/*end while*/p_data_b002=p_data_b002&(~bitraskladka_data_b002);fs_b002_H();DELAY002;fs_b002_L();DELAY002;}
void ccli(){SREG=0b00000000;}
void ssei(){SREG=0b10000000;}
void init_r002() {bitraskladka_clk_r002=0b00000001<<paramtr_clk_r002;bitraskladka_fs_r002=0b00000001<<paramtr_fs_r002;bitraskladka_data_r002=0b00000001<<paramtr_data_r002;init_r002ddr();}/*end init_r002b*/
void init_r002ddr(){ddr_clk_r002=ddr_clk_r002|bitraskladka_clk_r002;ddr_fs_r002=ddr_fs_r002|bitraskladka_fs_r002;ddr_data_r002=ddr_data_r002|bitraskladka_data_r002;}
void clk_r002_H() {p_clk_r002=p_clk_r002|bitraskladka_clk_r002;}
void clk_r002_L() {p_clk_r002=p_clk_r002&(~bitraskladka_clk_r002);}
void fs_r002_H() { p_fs_r002=p_fs_r002|bitraskladka_fs_r002;}
void fs_r002_L() { p_fs_r002=p_fs_r002&(~bitraskladka_fs_r002);}
void work_r002(){vb16_r002=b16_r002>>8u;vb16_r002=vb16_r002&0b0000000011111111;b1_r002=vb16_r002;vb16_r002=b16_r002&0b0000000011111111;b2_r002=vb16_r002;fs_r002_H();DELAY002;fs_r002_L();DELAY002;ii_r002=0u;r002_595flag=0u;while (ii_r002<16u)/*number of register bits*/{if (r002_595flag==0u){ii02_r002=ii_r002;vb1_r002=b1_r002;ii02_r002=7u-ii02_r002;vb1_r002=vb1_r002>>ii02_r002;vb1_r002=vb1_r002<<paramtr_data_r002;vb1_r002=vb1_r002&bitraskladka_data_r002;p_data_r002=p_data_r002&(~bitraskladka_data_r002);p_data_r002=p_data_r002|vb1_r002;clk_r002_L();DELAY002;clk_r002_H();DELAY002;clk_r002_L();DELAY002;p_data_r002=p_data_r002&(~bitraskladka_data_r002);if (ii_r002==7u){r002_595flag++;}ii_r002++;}/*end if*/if (r002_595flag==1u){ii02_r002=ii_r002-8u;vb1_r002=b2_r002;ii02_r002=7u-ii02_r002;vb1_r002=vb1_r002>>ii02_r002;vb1_r002=vb1_r002<<paramtr_data_r002;vb1_r002=vb1_r002&bitraskladka_data_r002;p_data_r002=p_data_r002&(~bitraskladka_data_r002);p_data_r002=p_data_r002|vb1_r002;clk_r002_L();DELAY002;clk_r002_H();DELAY002;clk_r002_L();DELAY002;p_data_r002=p_data_r002&(~bitraskladka_data_r002);if (ii_r002==15u){r002_595flag++;}ii_r002++;}/*end if*/}/*end while*/p_data_r002=p_data_r002&(~bitraskladka_data_r002);fs_r002_H();DELAY002;fs_r002_L();DELAY002;}
/*S-meter ADC*/
void adcscan256(ADCinput){MasterADC();adcrrtt=adcrrtt/30u;if(adcrrtt>255u){adcrrtt=255u;}}
void GetResultADC (){resultadcl=ADCL;resultadch=ADCH;}
void adcinit (){DDRA=DDRA&(~(1u<<7u));ADCenable ();ADCdisableAutoTrigger ();ADC256ReferenceSelect ();PrescallerADC_128u ();RightAdjustADC ();InputSelectADC ();ActivateInterrupt ();ADCstartConvertion ();}
void ADC_convertion ()
{
SFIOR=0b11100000;
adcinit ();
InputSelectADC (ADCinput);
adcendflag=(ADCSRA>>6u)&0b00000001;/*at the beginning 1, then 0*/
while (adcendflag==1)
{
adcendflag=(ADCSRA>>6u)&0b00000001;
}
GetResultADC ();
ADCdisable ();
/*ADMUX=0;*/
ADCSRA=0;
resultadctemp=resultadch;
resultadctemp=resultadctemp<<8u;
resultadctemp=resultadctemp+resultadcl;
/*resultadctemp=adcendflag;*/
}
void MasterADC ()
{
adcrrtt=0;
resultadctemp=0u;
ADC_ii=0u;
ADC_samples=5u;
while (ADC_ii<ADC_samples)
{
ADC_convertion ();
adcrrtt=adcrrtt+resultadctemp;
ADC_ii++;
}}
void ADC256ReferenceSelect (){ADMUX=ADMUX&0b00111111;ADMUX=ADMUX|0b01000000;}
void LeftAdjustADC () {ADMUX=ADMUX|0b00100000;}
void RightAdjustADC (){ADMUX=ADMUX&0b11011111;}
void InputSelectADC (ADCinput){if (ADCinput==0u){ADMUX=ADMUX&0b11100000;ADMUX=ADMUX|0b0;DDRA=DDRA&(~(1u<<ADCinput));PORTA=0x00;}if (ADCinput==1u){ADMUX=ADMUX&0b11100000;ADMUX=ADMUX|0b00000001; DDRA=DDRA&(~(1u<<ADCinput));PORTA=0x00;}if (ADCinput==2u){ADMUX=ADMUX&0b11100000;ADMUX=ADMUX|0b00000010; DDRA=DDRA&(~(1u<<ADCinput));PORTA=0x00;}if (ADCinput==3u){ADMUX=ADMUX&0b11100000;ADMUX=ADMUX|0b00000011; DDRA=DDRA&(~(1u<<ADCinput));PORTA=0x00;}if (ADCinput==4u){ADMUX=ADMUX&0b11100000;ADMUX=ADMUX|0b00000100; DDRA=DDRA&(~(1u<<ADCinput));PORTA=0x00;}if (ADCinput==5u){ADMUX=ADMUX&0b11100000;ADMUX=ADMUX|0b00000101; DDRA=DDRA&(~(1u<<ADCinput));PORTA=0x00;}if (ADCinput==6u){ADMUX=ADMUX&0b11100000;ADMUX=ADMUX|0b00000110; DDRA=DDRA&(~(1u<<ADCinput));PORTA=0x00;}if (ADCinput==7u){ADMUX=ADMUX&0b11100000;ADMUX=ADMUX|0b00000111; DDRA=DDRA&(~(1u<<ADCinput));PORTA=0x00;}}
void ADCenable () {ADCSRA=ADCSRA|0b10000000;}
void ADCdisable (){ADCSRA=ADCSRA&0b01111111;}
void ADCstartConvertion (){ADCSRA=ADCSRA|0b01000000;}
void ADCstopConvertion () {ADCSRA=ADCSRA&0b10111111;}
void ADCenableAutoTrigger () {ADCSRA=ADCSRA|0b00100000;}
void ADCdisableAutoTrigger (){ADCSRA=ADCSRA&0b11011111;}
void ActivateInterrupt (){ADCSRA=ADCSRA|0b00001000;}
void DisableInterrupt () {ADCSRA=ADCSRA&0b11110111;}
void PrescallerADC_1u (){ADCSRA=ADCSRA&0b11111000;ADCSRA=ADCSRA|0b00000000;}
void PrescallerADC_2u (){ADCSRA=ADCSRA&0b11111000;ADCSRA=ADCSRA|0b00000001;}
void PrescallerADC_4u (){ADCSRA=ADCSRA&0b11111000;ADCSRA=ADCSRA|0b00000010;}
void PrescallerADC_8u (){ADCSRA=ADCSRA&0b11111000;ADCSRA=ADCSRA|0b00000011;}
void PrescallerADC_16u (){ADCSRA=ADCSRA&0b11111000;ADCSRA=ADCSRA|0b00000100;}
void PrescallerADC_32u (){ADCSRA=ADCSRA&0b11111000;ADCSRA=ADCSRA|0b00000101;}
void PrescallerADC_64u (){ADCSRA=ADCSRA&0b11111000;ADCSRA=ADCSRA|0b00000110;}
void PrescallerADC_128u (){ADCSRA=ADCSRA&0b11111000;ADCSRA=ADCSRA|0b00000111;}
/*S-meter ADC end*/
/*chapter_wch5 DDS=====================================================================================*/
/*VFO control*/
void FREQUENCY_CALCULATION_VFO (){cli();vlrrd=fvfo;makedeltha();DELTAphaseVFO=vlrrd;VFOWORD01=DELTAphaseVFO>>24u;VFOWORD02=DELTAphaseVFO>>16u;VFOWORD03=DELTAphaseVFO>>8u;VFOWORD04=DELTAphaseVFO;}
void VFOinit (){FREQUENCY_CALCULATION_VFO ();WordDDS=0xF800;WordVFO9835 ();WordDDS=0xC000;WordVFO9835 ();WordDDS=(0x33<<8u);WordDDS=WordDDS|VFOWORD01;WordVFO9835 ();WordDDS=(0x22<<8u);WordDDS=WordDDS|VFOWORD02;WordVFO9835 ();WordDDS=(0x31<<8u);WordDDS=WordDDS|VFOWORD03;WordVFO9835 ();WordDDS=(0x20<<8u);WordDDS=WordDDS|VFOWORD04;WordVFO9835 ();WordDDS=0xC000;WordVFO9835 ();}
void VFOwork (){cli();FREQUENCY_CALCULATION_VFO ();WordDDS=0xC000;WordVFO9835 ();WordDDS=(0x33<<8u);WordDDS=WordDDS|VFOWORD01;WordVFO9835 ();WordDDS=(0x22<<8u);WordDDS=WordDDS|VFOWORD02;WordVFO9835 ();WordDDS=(0x31<<8u);WordDDS=WordDDS|VFOWORD03;WordVFO9835 ();WordDDS=(0x20<<8u);WordDDS=WordDDS|VFOWORD04;WordVFO9835 ();WordDDS=0xC000;WordVFO9835 ();}
void VFOFSYNC_HIGH (){DELAY00725;ppvfs=ppvfs|bitraskladkavfofs;DELAY0086;/*FSYNC*/DELAY00725;}
void VFOFSYNC_LOW (){DELAY00725;ppvfs=ppvfs&(~(bitraskladkavfofs));DELAY0086;/*FSYNC*/DELAY00725;}
void VFOSCLKhigh (){DELAY00725;ppvclk=ppvclk|bitraskladkavfoclk;DELAY0086;/*SCLK*/DELAY00725;}
void VFOSCLKlow(){DELAY00725;ppvclk=ppvclk&(~(bitraskladkavfoclk));DELAY0086;/*SCLK*/DELAY00725;}
void WordVFO9835 (){cli();DDStransferBit=0u;VFOFSYNC_HIGH ();DELAY0086;VFOFSYNC_LOW ();DELAY0086;while (DDStransferBit<16u){WordDDStemp=WordDDS;WordDDStemp=WordDDStemp<<DDStransferBit;WordDDStemp=WordDDStemp>>15u;WordDDStemp=WordDDStemp&0b00000001;/*SDATA PORTA_00*/VFOSCLKhigh ();ppvdta=ppvdta&(~(bitraskladkavfodta));if(WordDDStemp==0u){;};if(WordDDStemp!=0u){ppvdta=ppvdta|bitraskladkavfodta;};DELAY0086;VFOSCLKlow();DELAY0086;DDStransferBit++;ppvdta=ppvdta&(~(bitraskladkavfodta));}VFOFSYNC_HIGH ();DELAY0086;VFOFSYNC_LOW ();DELAY0086;}
void tunevfo(){cli();frqww=fqw;fvfo=frqww+fifq;VFOwork ();}
/*end VFO control*/
void initvfobfo (){
bitraskladkavfofs=1u<<paramtrvfs;
bitraskladkavfoclk=1u<<paramtrvclk;
bitraskladkavfodta=1u<<paramtrvdta;
ddrvfs=ddrvfs|bitraskladkavfofs;
ddrvclk=ddrvclk|bitraskladkavfoclk;
ddrvdta=ddrvdta|bitraskladkavfodta;
VFOinit ();}
/*=====end chapter_wch5 DDS*/
/*sfts*/
void sft_a (){dispdata (0x61);}void sft_b (){dispdata (0x62);}void sft_c (){dispdata (0x63);}void sft_d (){dispdata (0x64);}void sft_e (){dispdata (0x65);}
void sft_f (){dispdata (0x66);}void sft_g (){dispdata (0x67);}void sft_h (){dispdata (0x68);}void sft_i (){dispdata (0x69);}void sft_j (){dispdata (0x6A);}
void sft_k (){dispdata (0x6B);}void sft_l (){dispdata (0x6C);}void sft_m (){dispdata (0x6D);}void sft_n (){dispdata (0x6E);}void sft_o (){dispdata (0x6F);}
void sft_p (){dispdata (0x70);}void sft_q (){dispdata (0x71);}void sft_r (){dispdata (0x72);}void sft_s (){dispdata (0x73);}void sft_t (){dispdata (0x74);}
void sft_u (){dispdata (0x75);}void sft_v (){dispdata (0x76);}void sft_w (){dispdata (0x77);}void sft_x (){dispdata (0x78);}
void sft_y (){dispdata (0x79);}void sft_z (){dispdata (0x7A);}
void sft_A (){dispdata (0x41);}void sft_B (){dispdata (0x42);}void sft_C (){dispdata (0x43);}void sft_D (){dispdata (0x44);}void sft_E (){dispdata (0x45);}void sft_F (){dispdata (0x46);}void sft_G (){dispdata (0x47);}void sft_H (){dispdata (0x48);}
void sft_I (){dispdata (0x49);}void sft_J (){dispdata (0x4A);}void sft_K (){dispdata (0x4B);}void sft_L (){dispdata (0x4C);}void sft_M (){dispdata (0x4D);}void sft_N (){dispdata (0x4E);}
void sft_O (){dispdata (0x4F);}void sft_P (){dispdata (0x50);}void sft_Q (){dispdata (0x51);}void sft_R (){dispdata (0x52);}void sft_S (){dispdata (0x53);}void sft_T (){dispdata (0x54);}
void sft_U (){dispdata (0x55);}void sft_V (){dispdata (0x56);}void sft_W (){dispdata (0x57);}void sft_X (){dispdata (0x58);}void sft_Y (){dispdata (0x59);}void sft_Z (){dispdata (0x5A);}
void sft_point (){dispdata (0x2E);}void sft_dvoetochie (){dispdata (0x3A);}void sft_znak_menshe (){dispdata (0x3C);}void sft_znak_bolshe (){dispdata (0x3E);}void sft_udl (){dispdata (0x5F);}void sft_probel (){dispdata (0x20);}
void sft_00 (){dispdata (0x30);}void sft_1 (){dispdata (0x31);}void sft_2 (){dispdata (0x32);}void sft_3 (){dispdata (0x33);}void sft_4 (){dispdata (0x34);}void sft_5 (){dispdata (0x35);}void sft_6 (){dispdata (0x36);}void sft_7 (){dispdata (0x37);}void sft_8 (){dispdata (0x38);}void sft_9 (){dispdata (0x39);}
void sft_s01 (){dispdata (0xFF);}
/*end sfts*/
Schematic and Layout
CAD-Custom parts and enclosures
Sep 06,2022
561 views
R-022 SW Radio Receiver
8-band HAM SSB/CW SW radio receiever with DDs syntheseiser, two 8-xtal filters (for SSB and CW), RF band selector with pin-diode switch
561
0
0
Published: Sep 06,2022
Download Gerber file 3
Purchase
Donation Received ($)
PCBWay Donate 10% cost To Author
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
Copy this HTML into your page to embed a link to order this shared project
Copy
Under the
Attribution-NonCommercial-ShareAlike (CC BY-NC-SA)
License.
Topic
- Comments(0)
- Likes(0)
You can only upload 1 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP
0 / 10000
Remove
It looks like you have not written anything. Please add a comment and try again.
View More
View More
VOTING
0 votes
- 0 USER VOTES
0.00
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Design
1/4
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Usability
2/4
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Creativity
3/4
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Content
4/4
More by Александр Сергеевич Пыхтин
You may also like
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
65 1 1 -
-
-
-
Sega Master System RGB Encoder Switcher Z80 QSB v1.2
65 0 0 -
18650 2S2P Battery Charger, Protection and 5V Output Board
90 0 0 -
High Precision Thermal Imager + Infrared Thermometer | OpenTemp
463 0 7 -
Sony PlayStation Multi Output Frequency Oscillator (MOFO) v1
137 0 2 -