Constant Conditional Branch in HI TECH C Compiler

Programmer, In-Circuit Debugger, PIC Start-Up Kit, Memory Interface...

Constant Conditional Branch in HI TECH C Compiler

Postby khmok » Tue Apr 02, 2013 12:00 am

Does anyone having problem that related to "Constant Conditional Branch" issue in HI TECH C Compiler?

I think my code has fall into this problem:
I set i = 0 and j = 7 and hence n will be 8 based on the formula.
1. However, the display result showed that n will go until 254 and counter show the same number.
2. However also, if I comment out the if statement and left only "counter++", counter = 8 which is same as n.

Does anyone know if HITECH C Compiler has resolved this issue? I found the forum that discuss about this in previous HITECH website. http://forum.htsoft.com/all/showthreaded.php/Cat/0/Number/19441/page//vc/1

CODE: SELECT_ALL_CODE
//two for loops on top with i and j
n = 16*i + j + 1;

read_byte = Read_Memory(n);      // Read data from external eeprom memory
// Check if any mismatch or missing and feedback to user
   if (n != read_byte){
      sprintf(tx_buffer,"RetBinMatch,0,%d\r\n",n);
      uart_send_string(tx_buffer);
                                counter_n++;

   }      
                else{
      counter++;
   }   

khmok
Newbie
 
Posts: 13
Joined: Fri Mar 08, 2013 6:08 pm

Re: Constant Conditional Branch in HI TECH C Compiler

Postby shahrul » Tue Apr 02, 2013 8:38 am

What is function Read_Memory(n)? Read PIC eeprom or SPI/I2C eeprom?

From the code, if data not egual to eeprom address, counter will increments. What purpose you compare this 2?
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: Constant Conditional Branch in HI TECH C Compiler

Postby khmok » Tue Apr 02, 2013 10:14 am

Just give you a brief of my HW configuration:
PIC is connecting to many 1wire eeprom chip through multiplexr. Each chip will store an ID.

Read_Memory(n) is to read the n-th eeprom.
if (n != read_byte) is to check if the ID (read using Read_Memory(n)) is equal to value n.
if they are equal, counter ++ and finally will be displayed . If not equal, display failure message (counter will not increase). At the end, I will know out of all the eeprom, how many having same ID and how many have difference.
khmok
Newbie
 
Posts: 13
Joined: Fri Mar 08, 2013 6:08 pm


Return to PIC Development Tool

Who is online

Users browsing this forum: No registered users and 4 guests

cron