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

The target doesn't initialize arrays, why?

Hi, my eval board is Phytec KC-161 (with 64k ext RAM, and 256k ext FLASH). Why the target doesn't initialize arrays in free running?
Thank you.

Parents
  • Thanks for those links, I'll see what can I do.
    Maybe the compiler optimized it away, if this really is all your code. You could check the assembly file.
    No. That code was just where I discovered the problem. I also tryed the follow code using Hyper Terminal. In debug mode the target is running well, but in free running not:

    #include <reg161.h>
    #include <stdio.h>
    void setup_serial();
    
    void main (void)  {
            unsigned char cnt,array[6]={1,1,1,1,1,1};
            setup_serial();
    
            for(cnt=0; cnt<6; cnt++){
                    if(array[cnt] != 1)
                            putchar('!');
                    else
                            putchar('1');
    //in hyper terminal is displaying six of '!', WHY?
    //it must be six of '1'!
            }
    
            while (1) {
            }
    }
    
    void setup_serial(){
      P3  |= 0x0400;        /* SET PORT 3.10 OUTPUT LATCH (TXD)              */
      DP3 |= 0x0400;        /* SET PORT 3.10 DIRECTION CONTROL (TXD OUTPUT)  */
      DP3 &= 0xF7FF;        /* RESET PORT 3.11 DIRECTION CONTROL (RXD INPUT) */
      S0TIC = 0x80;         /* SET TRANSMIT INTERRUPT FLAG                   */
      S0RIC = 0x00;         /* DELETE RECEIVE INTERRUPT FLAG                 */
      S0BG  = 0x19;                 /* SET BAUDRATE TO 19200 BAUD AT 16MHZ           */
      S0CON = 0x8011;       /* SET SERIAL MODE                               */
    }
    

Reply
  • Thanks for those links, I'll see what can I do.
    Maybe the compiler optimized it away, if this really is all your code. You could check the assembly file.
    No. That code was just where I discovered the problem. I also tryed the follow code using Hyper Terminal. In debug mode the target is running well, but in free running not:

    #include <reg161.h>
    #include <stdio.h>
    void setup_serial();
    
    void main (void)  {
            unsigned char cnt,array[6]={1,1,1,1,1,1};
            setup_serial();
    
            for(cnt=0; cnt<6; cnt++){
                    if(array[cnt] != 1)
                            putchar('!');
                    else
                            putchar('1');
    //in hyper terminal is displaying six of '!', WHY?
    //it must be six of '1'!
            }
    
            while (1) {
            }
    }
    
    void setup_serial(){
      P3  |= 0x0400;        /* SET PORT 3.10 OUTPUT LATCH (TXD)              */
      DP3 |= 0x0400;        /* SET PORT 3.10 DIRECTION CONTROL (TXD OUTPUT)  */
      DP3 &= 0xF7FF;        /* RESET PORT 3.11 DIRECTION CONTROL (RXD INPUT) */
      S0TIC = 0x80;         /* SET TRANSMIT INTERRUPT FLAG                   */
      S0RIC = 0x00;         /* DELETE RECEIVE INTERRUPT FLAG                 */
      S0BG  = 0x19;                 /* SET BAUDRATE TO 19200 BAUD AT 16MHZ           */
      S0CON = 0x8011;       /* SET SERIAL MODE                               */
    }
    

Children