Warning possible loss of data MC9S08GB60

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Warning possible loss of data MC9S08GB60

跳至解决方案
1,684 次查看
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,021 次查看
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,022 次查看
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,021 次查看
CrasyCat
Specialist III

Hello

 

How did you define count?

 

CrasyCat

0 项奖励
回复