////////////////////////////////////////////////////////// // NEN5_SET.INC // // // // 初期設定・オープニング処理 // // 01/09/07 // ////////////////////////////////////////////////////////// //////// I/O初期設定 //////////////////////////////////////// void init_io() { int i; setup_timer_1( 0x02 ); //1:1 syn ck stop setup_timer_2( T2_DIV_BY_16,122,1 ); //pri16 setup_counters(rtcc_ext_l_to_h,wdt_576ms); setup_adc_ports(no_analogs); //Aすべてデジタル port_b_pullups(TRUE); // Bポートプルアップ set_tris_b(0x83); // 1000_0011 port_b = 0x00; // ポートB set_tris_c(0x01); // 0,1=in port_c = 0x00; // ポートCクリア set_tris_a(TRIS_A); port_a = 0x04; // ポートA出力A2はプルアップ用H //----------- RAM クリア -------------------- check_injs = 0; //起動時チェック用 unit_t_inj[4] = 0; //フラグクリア kilo_h = 0; //区間計数H kilo_l = 0; //区間計数L flag = 0; //区間表示用フラグ msec1_h = 0; //1mSecタイマーH msec1_l = 0; //1mSecタイマーL inj_t[4] = 0; //インジェクタ開時間フラグ inj_t_over = 0; //燃料噴射停止監視用 injl_over = 0; //インジェクタL監視用 sec = 0; //時計 秒 minute = 0; //時計 分 for(i=0;i<=10;i++) //区間燃費 section_lcd[i] = 0x20; //ブランクデータ section_dist[0] = 0; //区間距離 section_dist[1] = 0; section_dist[2] = 0; section_dist[3] = 0; section_gas[0] = 0; //区間燃料 section_gas[1] = 0; section_gas[2] = 0; section_gas[3] = 0; } //////// 全割り込み許可(RB4-7)割り込みを除く //////////////////////////// void enable_interrupts_all() { enable_interrupts(int_timer1); // タイマ1割り込み許可 enable_interrupts(int_timer2); // タイマ2割り込み許可 enable_interrupts(ext_int); // rb0よる割り込み許可 enable_interrupts(rtcc_zero); // タイマ0割り込み許可 enable_interrupts(global); // 全割り込み許可 } //////// データ初期設定 //////////////////////////////////////// void init_data() { restart_wdt(); output_high(den); // 電源ラインON bit_clear(t1con,0); // タイマ1停止 load_settei(); // 初期値,各種設定値のLOAD output_high(red); // 赤LED点灯 output_low(green); // 緑LED消灯 output_low(led_k); // led カソード enable_interrupts_all(); // 全割り込み許可 enable_rb47(); //injがHの時RB4-7割り込み許可 lcd_init(); // LCD初期設定 lcd_clr(); // LCDクリア } /////////////////////////////////////////////////////////////////////////////// #ifndef No_Opening void open_c1() { pri_run(1); //右端に表示 delay_ms(150); restart_wdt(); } void open_c2() { int i; for(i=1;i<=5;i++){ enable_rb47(); //injがHの時RB4-7割り込み許可 delay_ms(100); // 500mSec待ち restart_wdt(); } } ///////////// オープニング処理 ///////////////////////////////// void opening() { int i; for(i=1;i<=3;i++){ //3回上下運動 if(check_skip()) //エンジン始動 or IG OFF break; //パス output_high(red); //赤LED点灯 output_low(green); //緑LED消灯 output_low(led_k); //ledカソード lcd_car_l(); //低車高表示data書き込み// open_c1(); if(check_skip()) //エンジン始動 or IG OFF break; //パス output_high(green); //緑LED点灯 output_low(red); //赤LED消灯 output_low(led_k); //ledカソード lcd_car_h(); //高車高表示data書き込み// open_c1(); } if(!check_skip()){ output_low(green); // LED全消灯 output_low(led_k); //ledカソード lcd_car_l(); //低車高表示データ書き込み pri_run(18); //18回右から移動(アニメ) output_high(red); //赤LED点灯 output_low(led_k); //ledカソード open_c2(); output_low(red); //赤LED消灯 output_high(green); //緑LED点灯 output_low(led_k); //ledカソード open_c2(); } output_low(red); output_low(green); output_low(led_k); restart_wdt(); } #endif ///////////////////////////////////////////////////////////////////////////////