前提・実現したいこと
h8/3664マイコンのPWM周期と各FTIOB~FTIODのDuty比を
計算させてprintf("%",);で表示させたい。
各、計算に必要な要素はscanf("%",&);を使って入力する。
以下のエラーメッセージが表示されて、コンパイルが成功しません。
(linkingに問題が発生しているのでは?と考えていますが、原因がわかりません。)
醜い、コードですみません、どなたか助けて頂けない
でしょうか?
発生している問題・エラーメッセージ
PWM_DutyCycle.c:5:40: warning: variable 'Duty_Cycle_D'set but not use [-Wunused-but-set-variable]
PWM_DutyCycle.c:5:26: warning: variable 'Duty_Cycle_C'set but not use [-Wunused-but-set-variable]
PWM_DutyCycle.c:5:12: warning: variable 'Duty_Cycle_B'set but not use [-Wunused-but-set-variable]
PWM_DutyCycle.c:66:1⚠️ control reches end of non-void function[-Wunused-type]
collect2.exe:error: ld returned 1 exit status
該当のソースコード
ソースコード(C言語)は以下のように記述しました。
#include <stdio.h>
int main(void){
double CLOCK, IN_side_CLOCK, PWM;
double GRA, GRB, GRC, GRD;
double Duty_Cycle_B, Duty_Cycle_C, Duty_Cycle_D;
int CKS, TOB, TOC, TOD, i;
IN_side_CLOCK= 0.0; printf("Please CLOCK \n"); scanf("%lf", &CLOCK); printf("CLOCK is %lf.\n", CLOCK); printf("Please CKS \n"); scanf("%d", &CKS); printf("CKS is %d.\n", CKS); printf("Please TOB. If don't exist TOB, please integer bigger than 1.\n"); scanf ("%d", &TOB); printf("TOB is %d.\n", TOB); printf("Please TOC. If don't exist TOC, please integer bigger than 1. \n"); scanf ("%d", &TOC); printf("TOC is %d.\n", TOC); printf("Please TOD. If don't exist TOD, please integer bigger than 1. \n"); scanf ("%d", &TOD); printf("TOD is %d.\n", TOD); printf("Please GRA \n"); scanf("%lf", &GRA); printf("GRA is %lf.\n", GRA); printf("Please GRB. If don't exist GRB, please 0. \n"); scanf("%lf", &GRB); printf("GRB is %lf.\n", GRB); printf("Please GRC. If don't exist GRC, please 0. \n"); scanf("%lf", &GRC); printf("GRC is %lf.\n", GRC); printf("Please GRD. If don't exist GRD, please 0. \n"); scanf("%lf", &GRD); printf("GRD is %lf.\n", GRD); for(i=0; i<4; i++){ if(CKS == 0)IN_side_CLOCK = i+1.0; else if(CKS == i)IN_side_CLOCK = 2.0*i; else printf("Did not write about CKS.\n"); } PWM =1.0/CLOCK*IN_side_CLOCK*GRA; printf("PWM is %lf.\n", PWM); if(TOB == 1) Duty_Cycle_B = GRB/GRA*100.0; else if(TOB ==0) Duty_Cycle_B = (GRA-GRB)/GRA*100.0; else printf("Don't exist Duty_Cycle_B.\n"); if(TOC == 1) Duty_Cycle_C = GRC/GRA*100.0; else if(TOC ==0) Duty_Cycle_C = (GRA-GRC)/GRA*100.0; else printf("Don't exist Duty_Cycle_C.\n"); if(TOD == 1) Duty_Cycle_D = GRD/GRA*100.0; else if(TOD ==0) Duty_Cycle_D = (GRA-GRD)/GRA*100.0; else printf("Don't exist Duty_Cycle_D.\n");
}
試したこと
変数名を大文字にした:宣言した変数名に、gccではインストールされていない関数と同じ綴りのものがあったのではと思ったので。
補足情報(FW/ツールのバージョンなど)
GCC Developer Lite (Ver.2.5.0.0 Copyright(C)BestTechnology CO.,LTD 1999-2012)
コンパイルのコマンドは、上記の環境で用意されている、ビルドというアイコンもしくは、コンパイルの項目の中のビルドを選択するかのどちらかです。
Linux系やコマンドプロンプトのようにコマンドを打ち込んでコンパイルを行っていません。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー