This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

program exec well in simulator but not when loaded in target

Hi All
i have written routines for 8051RD2,after compiling and building target i tried this program with simulator,it was working fine and was giving me the desired o/p,but when hex file for this routine was loaded in target,Execution control was coming out of routines sequence when routines where executed in target.
i tried to reduce the program size,just to conform is it due to large program size,but the response remained same !
i observed routines where coming out of sequence when "printf "statement was getting executing.
Now what step should i follow for debugging this problem ,Help!!
Thanks in advance !

  • Are you sure that your hardware design is correct?

    Are you sure that your hardware is working correctly?

    Are you sure that you have correctly configured all your hardware-related settings?
    In particular, do you have handlers in place for every single possible interrupt source?

  • Hardware had been used previously (for same purpose but routines where in assembly),so there is no doubt regarding its working and design.only change now compared to previous is,routines are in C.
    So i doubt for configuration problem.
    interrupts are all disabled while sys is initialised by EA=0;.

    hardware configuration:
    CPU = 80C51RD2
    clock=12
    optimisation level :4
    Memory model :small variables in data.
    code rom size:compact 2k function,64k program
    operating system :none
    Use on chip rom is not ticked.

    following are routines

     void weigand_data()
       {
        unsigned int loop;
        unsigned long int result_byte;
        unsigned char var_byte1,var_byte2,var_byte3,v_byte1a,v_byte2a,v_byte3a;
        unsigned char wg_bit[26],hxbc[8],v_byte1b,v_byte2b,v_byte3b;
        unsigned char bdata var_byte;  
        .
        .
        for(loop=0;loop<=7;loop++)
         { 
           printf("\n\n value of loop for ps2 data out is %d",loop);
           kb_data_out(hxbc[loop]-0x30);
         } 
        .
        .           
       }
     
    kb_data_out(unsigned char kb_byte)
     {
      unsigned char parity;
      printf("\ncharacter received by kb_data_out is %2.2bxH",kb_byte); //check for char received 
      kb_byte=find_scan_code(kb_byte);         //to find the eqvlt scan code for the char received.   
      parity = kb_parity(kb_byte);             //to find parity for the scan code byte 
      printf("\nparity of character is %2.2bxH",parity);
      scan_code(kb_byte,parity);               //send the scan code byte and its parity in ps2 format   
      parity = kb_parity(0xf0);                //send byte to indicate key is not pressed ie lifted.  
      scan_code(0xf0,parity);
      printf("\n character given to ps2 is %2.2bxH",kb_byte); 
      parity = kb_parity(kb_byte);             //send the same byte to indicate which was the key    
                                               //pressed   
      printf("\nparity of character is %2.2bxH",parity);
      scan_code(kb_byte,parity);
     }        
          
      

    problem i am facing is in kb_data_out()which is called from weigand_out() routine using " for " loop," for" loop is executing well for loop =0,1,2 & 3,all the parameters are displaying properly through serial port,only when loop = 4 system gets hanged.
    following is the o/p .


    value of loop for ps2 data out is 0
    character received by kb_data_out is 00H
    parity of character is 00H
    same character given next time to ps2 is 70H
    parity of character is 00H
    .
    .
    value of loop for ps2 data out is 4
    character received by kb_data_out is 04H
    parity of character is 00H
    same character given nex

    are the hardware configuration correct ?

  • "Hardware had been used previously"

    Did it survive the previous use? - ie is it still working??

  • yes.I tested this hardware (after ISD was giving problem) by loading assembly routines.it was working fine.
    if problem is with hardware which part of it should i look for debug ?
    Is it serial communication part ?
    ISD51 does not require any external hardware.
    i have doubt regarding configuration settings
    are setting given above correct ?

    Even baud rate setting in target option is giving problem.i am using clock 12,11.0592 MHZ crystal,which gives me 57600 baud rate,
    But on setting crystal freq to 11.0592 in target option,Then on entering to debug mode and viewing baud rate IDE shows 115200
    ie double of what i want.
    how can i keep both this freq same without changing harware side ?