Warning possible loss of data MC9S08GB60

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Warning possible loss of data MC9S08GB60

ソリューションへジャンプ
1,705件の閲覧回数
Cn
Contributor I

Hello forum, i'm new programming this devices. Well when i debug my program a warning appear.. Possible loss of data(see the bold text), could you indicate what is my error? and how can i fix? because i want to transmit data who is storage in a variable thanks

 

byte SCI1_Transmit(byte Chr){
  if(!SCI2S1_TDRE) {           // Is the transmitter empty?
    return -1;                 // If no then error
  }
  SCI2D = (byte)Chr;
  return 0;                    // OK
}


void main(void) {
  byte TransmitStatus;
 
  SOPT = initSOPT; 
  ICGC2 = initICGC2;
  ICGC1 = initICGC1;     //32kHz -> 18.874368MHz bus rate
  while(!ICGS1_LOCK);    //loop until FLL locks
  ICGC2_LOCRE = 1;       //enable reset if ref clock fails
 
  InitSCI1();
 
  EnableInterrupts; /* enable interrupts */
    count=0;
  /* include your code here */
  for(;:smileywink: {
    // __RESET_WATCHDOG(); /* feeds the dog */
    count++;
    TransmitStatus = SCI1_Transmit(count);
    delay();
    //TransmitStatus = SCI1_Transmit('A');
   // delay();
  } /* loop forever */
  /* please make sure that you never leave this function */
}

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,042件の閲覧回数
Lundin
Senior Contributor IV

If count is an integer type larger than 8 bits, then you should typecast it to "byte".

 

If not, CW is being silly. The "possible loss of data warning" seems to contain compiler bugs, as it is given randomly, without any logic. In some cases it is valid and points out defects in your program, and in some cases it is just nonsense.

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,043件の閲覧回数
Lundin
Senior Contributor IV

If count is an integer type larger than 8 bits, then you should typecast it to "byte".

 

If not, CW is being silly. The "possible loss of data warning" seems to contain compiler bugs, as it is given randomly, without any logic. In some cases it is valid and points out defects in your program, and in some cases it is just nonsense.

0 件の賞賛
返信
1,042件の閲覧回数
CrasyCat
Specialist III

Hello

 

How did you define count?

 

CrasyCat

0 件の賞賛
返信