/********************************************************************** DDS_AD9834 by PIC18F25K22 v3.3 2016/04/29 By JA3OOK T.nakamura DDS AD9834 (67.108864MHz水晶) 履歴 v1.0 プロトタイプ、DDS制御の確認 v2.0 プッシュSWで周波数のUP/DOWN v3.0 プッシュSWでMemoryCHの選択、長押しでRead/Write Memory rotary encoderで位選択、周波数Up/Down v3.1 周波数UP/DOWNの既定の位を1kHzに統一 v3.2 TS-830とTS-590のIF周波数をイメージが少ない周波数に変更し、TS-590IFを初期値とする v3.3 カーソル移動方向を今までと逆に変更     周波数可変範囲チェックのバグ修正     エンコーダーのチャタリング減少 *********************************************************************** Tools: MPLAB X IDE ver 3.05 MPLAB XC8 C Compiler Free mode v1.34 ------------------------------------------------------------------ CPU: PIC18F25K22 CPU: PIC18F25K22 16MHz 1:MCLR:1 2:RA0:0:LCD ctrl 3:RA1:0:LCD ctrl 4:RA2:0:LCD ctrl 5:RA3:0:LCD ctrl 6:RA4:0:LCD ctrl 7:RA5:0:LCD ctrl 8:VSS 9: RA7:1 10:RA6:0 11:RC0:0:AD9834 FSYNC 12:RC1:0:AD9834 SCLK 13:RC2:0:AD9834 SDATA 14:RC3:0: 15:RC4:0:LED 16:RC5:0: 17:RC6:0: 18:RC7:0: 19:VSS 20:VDD 21:RB0:0: 22:RB1:0:SW2 Disconnect:H: Step UP / Memory-Write/Read Connect:L:frequency UP/DOWN 23:RB2:0: 24:RB3:0: 25:RB4:1:rotary encoder 26:RB5:1:rotary encoder 27:RB6:1:PushSW1 Step UP / Memory-read 28:RB7:1:PushSW0 Step DOWN / Memory-write *****************************************************************/ // refer \c:Program Files\Microchip\xc8\v1.31\docs\chips\18f25k22.html #pragma config BOREN = OFF //BOR disabled #pragma config CP0 = OFF //Code protection off #pragma config CP1 = OFF //Code protection off #pragma config CP2 = OFF //Code protection off #pragma config CP3 = OFF //Code protection off //#pragma config CCP2MX =PORTC1 //CCP2 input/output is multiplexed with RC1 #pragma config DEBUG = OFF //In-Circuit Debugger disabled #pragma config WRT0 =OFF //Write protection off #pragma config WRT1 =OFF //Write protection off #pragma config WRT2 =OFF //Write protection off #pragma config WRT3 =OFF //Write protection off /* Internal OSC 16MHz */ #pragma config PLLCFG = OFF //Oscillator used directly #pragma config FOSC =INTIO67 //Internal oscillator block #pragma config PRICLKEN =OFF //Primary clock can be disabled by software /**/ #pragma config PBADEN =OFF //PORTB<5:0> pins are configured as digital I/O on Reset #pragma config MCLRE =EXTMCLR // MCLR pin enabled, RE3 input pin disabled #pragma config WDTEN =OFF //WDT disabled #pragma config CP0 =OFF //Code protection off #pragma config CP1 =OFF //Code protection off #pragma config CP2 =OFF //Code protection off #pragma config CP3 =OFF //Code protection off #pragma config LVP =OFF //Single-Supply ICSP disabled #pragma config XINST =OFF //Instruction set extension and Indexed Addressing mode disabled (Legacy mode) #pragma config PWRTEN =ON //Power-up Timer Enable #pragma config IESO =OFF //Oscillator Switchover mode disabled #pragma config FCMEN =OFF //Fail-Safe Clock Monitor disabled #pragma config PLLCFG =OFF //Oscillator used directly #pragma config IESO =OFF //Oscillator Switchover mode disabled #pragma config WRTD =OFF //Data EEPROM not write-protected // //#include "pic18f25k22.h" //#include //#include #include #include "lcd.h" #define MHz 000000 #define _XTAL_FREQ 16MHz // OSC_FREQ // aplication port asign map #define DDS_FSYNC LATC0 // AD9834 sync #define DDS_SCLK LATC1 // AD9834 clock #define DDS_SDATA LATC2 // AD9834 data #define LED1 LATC4 // LED #define SW2 PORTBbits.RB1 #define ROTASW_B PORTBbits.RB4 #define ROTASW_A PORTBbits.RB5 #define PUSHSW_WHITE PORTBbits.RB6 #define PUSHSW_RED PORTBbits.RB7 #define dds_reset 0x0100 //AD9834コントロールレジスタ  RESET(DB8):1 他のビット:0 //大意は出力を停止し他を初期設定 #define msg1 "18F25K22 " #define msg2 "9834 JA3OOK v3.3" #define msg_init "Initialized " #define msg_move2vfo " Moved to VFO " #define msg_wrote "Wrote to M" #define msg_wrtwarning " Write OK? " #define max_freq 30000000 // max frequency #define min_freq 100 // min frequency 100Hz #define init_step 1000 // 変更の位の基本位置 1000Hz #define init_csl_pos 9 // 1000Hzの位のカーソル位置 /* EEPRONの最初から80バイトに0を設定(PICにプログラムを書き込むときに書き込まれる)*/ __EEPROM_DATA(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); __EEPROM_DATA(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); __EEPROM_DATA(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); __EEPROM_DATA(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); __EEPROM_DATA(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); __EEPROM_DATA(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); __EEPROM_DATA(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); __EEPROM_DATA(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); __EEPROM_DATA(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); __EEPROM_DATA(0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); // EEPROM addr: 0 (Reserveed)cur freq(No use) // : 4 M00:cur freq // : 8 M01 // :12 M02 // :16 M03 // :20 M04 // :24 M05 // :28 M06 // :32 M07 // :36 M08 // :40 M09 #define cur_freq_addr 4 // current memory ch. address #define min_mch 0 // minimum memory ch #define max_mch 9 // maximum memory ch //ここまでPIC機種に合わせる //宣言文ので添え字は要素数であり、1から数える //参照の添え字は0から数える signed char rotaenc_stats[] = { 0, 1,-1, 0,-1, 0, 0, 1, 1, 0, 0,-1, 0,-1, 1, 0}; // -1が左回転 0は回転なし 1が右回転 unsigned char rotaenc_now; // value of rotary encoder unsigned char rotaenc_old; // value of rotary encoder unsigned char cflag; // frequency change flag signed long vfreq; // VFO frequency signed long mfreq; // readed Memory frequency signed long step; // VFO frequency up down step signed char diff; // VFO frequency +/- unsigned char sw0_state; unsigned char sw1_state; unsigned int tim0; unsigned int tim1; unsigned int csl_pos; // cursor position unsigned char cur_mch; // current memory ch number unsigned char cur_mchaddr; // current memory ch addr unsigned char write_warn; // EEPROM write OK unsigned char sign; // + - unsigned int timer_int; //Wait Counter unsigned char i_char; //temporary work unsigned char j_char; //temporary work unsigned char sw1; //temporary work unsigned long temp1_long; //temporary work unsigned int temp2_int; //temporary work unsigned char str[17]; //temporary work unsigned char hexch[] ="0123456789ABCDEF"; //for debug routine void //for debug unsigned charを16進表示に変換しstrに格納されるので液晶に表示できる Char2hex(unsigned char cha){ unsigned char temp_ch; //local 汎用char temp_ch = (cha >> 4) & 0x000F; str[0] = hexch[temp_ch]; //上位4bit表示 max:03FF temp_ch = cha & 0x000F; str[1] = hexch[temp_ch]; //下位4bit表示 max:03FF str[2] = 0; //set NULL 0x00 } void //for debug int整数を16進表示に変換しstrに格納されるので液晶に表示できる Int2hex(unsigned int int_val){ unsigned char temp_ch; //local 汎用char temp_ch = int_val >> 12; str[0] = hexch[temp_ch]; //上位4bit表示 max:03FF temp_ch = (int_val >> 8) & 0x000F; str[1] = hexch[temp_ch]; //下位4bit表示 max:03FF temp_ch = (int_val >> 4) & 0x000F; str[2] = hexch[temp_ch]; //上位4bit表示 max:03FF temp_ch = int_val & 0x000F; str[3] = hexch[temp_ch]; //下位4bit表示 max:03FF str[4] = 0; //set NULL 0x00 } void //intやchar正数をASCII文字に変換し*bufferに格納されるので文字として送信したり液晶に表示できる Bin2str(unsigned int data, char *buffer, unsigned int digit) { // 引数:intやchar正数データ, 文字データ, 期待する文字データの文字数 char i; buffer += digit; // 最後の数字位置 += : Buffer=Buffer+digit *buffer = 0; // 文字列終端(文字数+1の位置)へ0X00 for(i=digit; i>0; i--) { // 変換は下位から上位へ buffer--; // ポインター1 *buffer = (data % 10) + 0x30;// ASCIIへ  % : 割り算の余り data = data / 10; // 次の桁へ } } unsigned int //ASCII文字をint正数に変換 Str2int(unsigned char *buffer, unsigned digit) { // 引数:文字データ, 文字データの文字数 (戻り値は関数名) char i; unsigned int data; unsigned int base; base = 1; data = 0; buffer += digit; // 最後の数字位置 += : Buffer=Buffer+digit for(i=1; i<=digit; i++) { // 変換は下位から上位へ buffer--; // ポインター1 data = data + (*buffer - 0x30) * base; // 変換 base = base *10; } return data; //戻り値を関数名に返す } void //EEPROMへ1バイト書き込み Write_eeprom1(unsigned char eeaddr,unsigned char value){ eeprom_write(eeaddr, value); __delay_ms(5); //PIC18(L)F2X/4XK22 Data Sheet:438page Wate min4ms } unsigned char //EEPROMから1バイト読み取り Read_eeprom1(unsigned char eeaddr){ unsigned char i; i=eeprom_read(eeaddr); return i; } void //EEPROMへ2バイト書き込み Write_eeprom2(unsigned char eeaddr,unsigned int value){ unsigned char v; v = (value >> 8); eeprom_write(eeaddr, v); __delay_ms(5); //PIC18(L)F2X/4XK22 Data Sheet:438page Wate min4ms v = (value & 0x00FF); eeaddr = eeaddr + 1; eeprom_write(eeaddr, v); __delay_ms(5); //PIC18(L)F2X/4XK22 Data Sheet:438page Wate min4ms } unsigned int //EEPROMから2バイト読み取り Read_eeprom2(unsigned char eeaddr){ unsigned char j; unsigned int temp1_int; j = eeprom_read(eeaddr); temp1_int = j; temp1_int = (temp1_int << 8); eeaddr = eeaddr + 1; j = eeprom_read(eeaddr); temp1_int = temp1_int + j; return temp1_int; } void //EEPROMへ long(4バイト)書き込み アドレスには若い番地を指定 Write_eepromlong(unsigned char eeaddr,unsigned long value){ unsigned long vl; unsigned char v; unsigned char addr; vl = (value >> 24); v = (vl & 0x000000FF); addr = eeaddr; eeprom_write(addr, v); __delay_ms(5); //PIC18(L)F2X/4XK22 Data Sheet:438page Wate min4ms vl = (value >> 16); v = (vl & 0x000000FF); addr = eeaddr + 1; eeprom_write(addr, v); __delay_ms(5); //PIC18(L)F2X/4XK22 Data Sheet:438page Wate min4ms vl = (value >> 8); v = (vl & 0x000000FF); addr = eeaddr + 2; eeprom_write(addr, v); __delay_ms(5); //PIC18(L)F2X/4XK22 Data Sheet:438page Wate min4ms vl = value; v = (vl & 0x000000FF); addr = eeaddr + 3; eeprom_write(addr, v); __delay_ms(5); //PIC18(L)F2X/4XK22 Data Sheet:438page Wate min4ms } unsigned long //EEPROMから long(4バイト)読み取り アドレスには若い番地を指定 Read_eepromlong(unsigned char eeaddr){ unsigned char v; unsigned long vl; unsigned char addr; addr = eeaddr; v = eeprom_read(addr); vl = v; vl = vl << 8; addr = eeaddr + 1; v = eeprom_read(addr); vl = vl + v; vl = vl << 8; addr = eeaddr + 2; v = eeprom_read(addr); vl = vl + v; vl = vl << 8; addr = eeaddr + 3; v = eeprom_read(addr); vl = vl + v; return vl; } void // DDSへ高位から順に1ビットづつ16ビット送信 Send2dds(unsigned long data){ unsigned int i; DDS_FSYNC = 0; for(i = 16; i > 0 ; i--) { DDS_SDATA = (data >> (i - 1)) & 0x00000001; DDS_SCLK = 0; DDS_SCLK = 1; } DDS_FSYNC = 1; } void // 周波数データを組み立てDDSへ送信する Freq2dds(unsigned long f){ unsigned long msb, lsb; unsigned long data; //67.108864MHz水晶搭載により0.25Hzステップなので、2ビットシフト(4倍)し1Hzステップにしている data = f << 2; //AD9834データシートの表II コントロール・レジスタ内のビットの説明 から参照のこと lsb = (data & 0x00003fff) + 0x4000; //FREQ0レジスタ指定(D15:0 D14:1)と周波数データ下位14ビットを合体 msb = (data >> 14) + 0x4000; //FREQ0レジスタ指定(D15:0 D14:1)と周波数データ上位14ビットを合体  Send2dds(0x2000);//制御ワード D15:0 D14:0 であり、 B28(D13):1 その他のビット:0  この行の意味は //    「2つ連続して周波数情報を送り込みます。周波数計算はFREQ0レジスタから行い、 //  正弦波を出力してください」 Send2dds(lsb); //最初に下位14ビット Send2dds(msb); //次に上位14ビット LED1 = 1; } void //signed long をASCII文字に変換し液晶に表示  LCD文字数は符号とカンマ2個を含めて11文字 Long2lcd(unsigned long data){ //引数=longデータ j_char = 8; //最大30000000Hzだから桁数は8 sign = ' '; temp1_long = data; str[j_char] = 0x00; for(i_char=j_char; i_char>0; i_char--) { // 変換は下位から上位へ str[i_char-1] = (data % 10) + 0x30; // ASCIIへ変換  % : 割り算の余り つまり、10で割った余り data = data / 10; // 次の桁へ } // Lcd_puts(str); //debug sw1 = 0; for(i_char=0; i_char max_freq) { vfreq = 11376000; // 11.376MHz (TS-590 IF11.374+0.002) Freq2dds(vfreq); cur_mch = min_mch; // current memory ch }else{ vfreq = mfreq; Freq2dds(vfreq); } i_char = 1; //MCH1 cur_mchaddr = i_char * 4 +4; mfreq = Read_eepromlong(cur_mchaddr); if(mfreq < min_freq || mfreq > max_freq) { Write_eepromlong(cur_mchaddr, 828000); //828kHz NHKラジオ第2 大阪放送局 300kW } i_char = 2; //MCH2 cur_mchaddr = i_char * 4 +4; mfreq = Read_eepromlong(cur_mchaddr); if(mfreq < min_freq || mfreq > max_freq) { Write_eepromlong(cur_mchaddr, 7050000); //7.050MHz } i_char = 3; //MCH3 cur_mchaddr = i_char * 4 +4; mfreq = Read_eepromlong(cur_mchaddr); if(mfreq < min_freq || mfreq > max_freq) { //Write_eepromlong(cur_mchaddr, 8830000); //TS-830 IF 8.830MHz Write_eepromlong(cur_mchaddr, 8832000); //TS-830 IF 8.830+0.002MHz Non Spurious } i_char = 4; //MCH4 cur_mchaddr = i_char * 4 +4; mfreq = Read_eepromlong(cur_mchaddr); if(mfreq < min_freq || mfreq > max_freq) { //Write_eepromlong(cur_mchaddr, 11374000); //TS-590 IF 11.374MHz Write_eepromlong(cur_mchaddr, 11376000); //TS-590 IF 11.374+0.002MHz Non Spurious } i_char = 5; //MCH5 cur_mchaddr = i_char * 4 +4; mfreq = Read_eepromlong(cur_mchaddr); if(mfreq < min_freq || mfreq > max_freq) { Write_eepromlong(cur_mchaddr, 14150000); //14.150Mhz } sw0_state = 0; sw1_state = 0; diff = 0; tim0 = 0; tim1 = 0; cflag = 0; write_warn = 0; } void interrupt PORTB_interrupt( void ){ // if(RBIF) { cflag = 0; //回転方向の検出原理:次のWebsiteの説明が分かりやすい //http://tylercsf.blog123.fc2.com/blog-category-38.html // A B    回転方向の検出ロジック rotaenc_now = (ROTASW_A << 1) | ROTASW_B; // Aを1ビットシフト | B  rotaenc_old = rotaenc_old << 2; // 2ビットシフト rotaenc_old = rotaenc_old | (rotaenc_now & 0x03); // old | now diff = rotaenc_stats[rotaenc_old & 0x0F]; // 下位4ビットを生かし配列から値を取得 if(diff != 0){ // -1が左回転 0は回転なし 1が右回転 cflag = 1; } //__delay_us(500); //Wait エンコーダのチャタリング回避(減少 __delay_ms(5); //Wait エンコーダのチャタリング回避(減少) RBIF = 0; } } void Loop(void){ while(1){ //無限ループ // if rotary changed if(cflag) { //ロータリーエンコーダー cflag = 0; if(!SW2){ //SW2:Connect to grand level つまり周波数の変更 if(diff == 1) { if((vfreq + step) <= max_freq) vfreq += step; } else { if((vfreq - step) >= min_freq) vfreq -= step; } LED1 = 0; if(((vfreq) >= min_freq) && ((vfreq) <= max_freq)) { Freq2dds(vfreq); } Display_vfreq(); }else{ //SW2:Disconnect from grand level  つまり位の変更 if(diff == -1) { if(step == 1) { step = 10; csl_pos = 12; } else if(step == 10) { step = 100; csl_pos = 11; } else if(step == 100) { step = 1000; csl_pos = 9; } else if(step == 1000) { step = 10000; csl_pos = 8; } else if(step == 10000) { step = 100000; csl_pos = 7; } else if(step == 100000) { step = 1000000; csl_pos = 5; } else if(step == 1000000) { step = 10000000; csl_pos = 4; } }else{ if(step == 10) { step = 1; csl_pos = 13; } else if(step == 100) { step = 10; csl_pos = 12; } else if(step == 1000) { step = 100; csl_pos = 11; } else if(step == 10000) { step = 1000; csl_pos = 9; } else if (step == 100000) { step = 10000; csl_pos = 8; } else if (step == 1000000) { step = 100000; csl_pos = 7; } else if (step == 10000000) { step = 1000000; csl_pos = 5; } } Lcd_goto(csl_pos); } } if(PUSHSW_WHITE == 0) { //push sw1 sw1_state = 1; __delay_ms(10); tim1++; } if(PUSHSW_WHITE && sw1_state) { //短時間の Pushu PSW1 つまり EEPROMの読み出し sw1_state = 0; tim1 = 0; if(cur_mch <= min_mch){ cur_mch = max_mch; }else{ cur_mch--; } i_char = cur_mch; cur_mchaddr = i_char * 4 +4; mfreq = Read_eepromlong(cur_mchaddr); Display_mfreq(); if(!SW2 && (mfreq != 0)){ //SW2:Connect to grand level つまりVFO周波数の即時変更 vfreq = mfreq; LED1 = 0; if((vfreq >= min_freq) && (vfreq <= max_freq)) { Freq2dds(vfreq); } Set_step_csl_pos(); Display_vfreq(); } } // Move frequency from EEPROM to VFO if(tim1 > 300) { // 押し続け PUSHSW_白色 PWS1 つまりVFO周波数の変更 sw1_state = 0; tim1 = 0; if((mfreq >= min_freq) && (mfreq <= max_freq)) { vfreq = mfreq; LED1 = 0; Freq2dds(vfreq); Set_step_csl_pos(); Display_vfreq(); Lcd_goto(0x43); Lcd_puts(msg_move2vfo); // msg for Move to VFO timer_int = 300; while(timer_int --){__delay_ms(10);}; //Wait 3sec. Display_mfreq(); } } if(PUSHSW_RED == 0) { //push PSW0 sw0_state = 1; __delay_ms(10); tim0++; } if(PUSHSW_RED && sw0_state) { //短時間の push PSW0 つまり EEPROMの読み出し sw0_state = 0; tim0 = 0; if(cur_mch >= max_mch){ cur_mch = min_mch; }else{ cur_mch++; } i_char = cur_mch; cur_mchaddr = i_char * 4 +4; mfreq = Read_eepromlong(cur_mchaddr); Display_mfreq(); if(!SW2 && (mfreq != 0)){ //SW2:Connect to grand level つまりVFO周波数の即時変更 vfreq = mfreq; LED1 = 0; if((vfreq >= min_freq) && (vfreq <= max_freq)) { Freq2dds(vfreq); } Set_step_csl_pos(); Display_vfreq(); } } // write frequency from VFO to EEPROM if(tim0 > 300) { // 押し続け PUSHSW_赤色 PSW0 sw0_state = 0; tim0 = 0; if((vfreq >= min_freq) && (vfreq <= max_freq)) { if(mfreq == 0 || write_warn >= 1) { write_warn = 0; // permit write cur_Mch } else{ Lcd_goto(0x43); Lcd_puts(msg_wrtwarning); // warning msg write_warn = 1; timer_int = 100; while(timer_int --){__delay_ms(10);}; //Wait 1sec. } if(write_warn == 0){ Lcd_goto(0x40); Lcd_puts(msg_wrote); // msg for Write memory Bin2str(cur_mch,str,2); Lcd_puts(str); Lcd_puts(" "); Write_eepromlong(cur_mchaddr, vfreq); timer_int = 300; while(timer_int --){__delay_ms(10);}; //Wait 3sec. i_char = cur_mch; cur_mchaddr = i_char * 4 +4; mfreq = Read_eepromlong(cur_mchaddr); Set_step_csl_pos(); Display_mfreq(); } } } } } void main(void){ //ここからPICの機種に合わせる //Fosc(発振周波数)に合わせて変更すべき個所 // ・#define _XTAL_FREQ  lcd.c と 本プログラム // ・OSCCON関係 // ・EUSARTシリアル通信関係(UsbInit関数内) // ・割込み関係 // ・__delay_ms()の修正が必要な場合がある(コンパイルエラーまたはデバッグで見つける) //Fosc = internal OSC=16MHz IRCF2 = 1; IRCF1 = 1; IRCF0 = 1; //16Mhz SCS1 = 1; SCS0 = 0; //Internal oscillator block TRISC = 0b00000000; //all output ANSELC = 0b00000000; //all digital port LATC = 0b00000000; PORTC = 0b00000000; //初期化(全てLOWにする) Send2dds(dds_reset); //*** できるだけ早期にDDSをリセットし、スプリアス出力を防ぐ *** TRISA = 0b00000000; //all bits is output RA5~RA0 : for LCD Panel ANSELA = 0b00000000; //all digital port LATA = 0b00000000; PORTA = 0b00000000; //初期化((全てLOWにする) // RB4,5 rotary encoder input RB6,7 sw input = Interrupt TRISB = 0b11110010; // RB4,5 rotary encoder input RB6,7,1 sw input ANSELB = 0b00000000; //all digital port LATB = 0b11110010; PORTB = 0b11110010; //初期化 RBPU = 0; // PORTB Pull-up WPUB = 0b11110010; // RB7,6,5,4,1 pull-up IOCB5 = 1; IOCB4 = 1; IPEN = 0; //割込みプライオリティ機能を使用しない //ここまで機種に合わせる //LCD initialize and cleare Lcd_init(); Lcd_write(0b00001100); //Display on, no cursor Lcd_clear(); Reset_value(); // /* display open message */ Lcd_goto(0x00); //LCDの表示位置を一行目左端 Lcd_puts(msg1); //LCDにメッセージを表示 Lcd_goto(0x40); //LCDの表示位置を二行目左端 Lcd_puts(msg2); //LCDにメッセージを表示 timer_int = 200; while(timer_int --){__delay_ms(10);}; //Wait 2sec. /* End of hello msg on LCD */ // check LED // LED1 = 1; // timer_int = 100; while(timer_int--){__delay_ms(10);}; //Wait 1sec. // LED1 = 0; // end of check LED if((vfreq >= min_freq) && (vfreq <= max_freq)) { Freq2dds(vfreq); } Set_step_csl_pos(); Lcd_write(0b00001110); //Display on, cursor On, blink Off Display_vfreq(); //ここからPICの機種に合わせる RBIE = 1 ; //PORTB割込みつまりロータリーエーコーダー有効 GIE = 1 ; //全割込み処理を有効にする //ここまで機種に合わせる Loop(); }