UIC00B stepping: Enter for loop and go haywire

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

UIC00B stepping: Enter for loop and go haywire

Postby khmok » Fri Mar 29, 2013 3:44 pm

Hi,

I am using UIC00B to step through my code. I am using PIC16F873A and MPLAB IDE v8.9 (HI TECH PICC v9.0).
During stepping, I found out that the stepping go haywire when enter for loop.
Basically, this code is just to read scratchpad of DS2431 (1-Wire). The problem happen when enterring the for loop.
Refer the attachment and look at the variable that I watch:
1. Count is more than 8 now (where for loop suppose to exit for count<8)
2. TA1, TA2, ES are start changing value after each for loop (where not supposed to be, these 3 variables has nothing to do with the for loop.

Can anyone advice if the problem is due to UIC00B or MPLAB IDE or HI TECH PICC compiler or ?

CODE: SELECT_ALL_CODE
int Read_SP(void)
{
   unsigned short data_crc16;
   unsigned char OW_Data_Rx[8], TA1, TA2, ES;
   int count;
   
   if(!OWReset())
   {
      no_device_flag = 0;
      return 0;            // No device found
   }   
   OWWriteByte(0xCC);         // Issue 'Skip ROM' Command   
   OWWriteByte(0xAA);         // Issue 'Read Scratchpad' Command
   TA1 = OWReadByte();   // Expect 20h
   TA2 = OWReadByte();   // Expect 00h
   ES = OWReadByte();   // Expect 07h

   if(TA1 != 0x20)
      return 0;
   else if (TA2 != 0x00)
      return 0;
   else if (ES != 0x07)
      return 0;
   else{   
   
      for (count = 0; count < 8; count ++)
      {   
         OW_Data_Rx[count] = OWReadByte();
      }
      data_crc16 = OWReadByte();
      data_crc16 |= (OWReadByte() << 8);
   }
   // Check CRC16
   return 1;
}
Attachments
OW_Data_Rx_0.JPG
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 2 guests