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

issueMDK4.10 compile problem....hple me

hi,i used MDK4.10 compile LPC1768 test code,and used jlink to debug,but i discovered global variables not initialize(did not i give value), it are Random value.Local variables are correct.
do i setting wrong? this issue let me can't debug,someone can solve this problem? or it is normal?

example:
uart.c
volatile uint32_t UART0Count = 0;


iotest.c
extern volatile uint32_t UART0Count;

//in the debugger,Teststring are not below,are 0xda,0xfc.....why
uint8_t  Teststring[LENGTH] = {'1','2','3','4','5','6','7','8','9','0'};

while (1)
{
  //in the debugger,UART0Count is not 0,is 0x24865414why
  if ( UART0Count != 0 )
  {
    LPC_UART0->IER = IER_THRE | IER_RLS;                     /* Disable RBR */
    UARTSend( 0, (uint8_t *)UART0Buffer, UART0Count );
    UARTSend( 0, (uint8_t *)string, 10 );

    UART0Count = 0;
    LPC_UART0->IER = IER_THRE | IER_RLS | IER_RBR;   /* Re-enable RBR */
  }
}


my english is bad, hope you don't mind......^^
please help me this question...very thank you...

Parents
  • hi everyone,
    i will to see compile file uart.txt and iotest.txt,the result are blow:

    uart.txt
    
     AREA ||.data||, DATA, ALIGN=2
    
                      UART0TxEmpty
    000000  03                DCB      0x01
                      UART1TxEmpty
    000001  010000            DCB      0x01,0x00,0x00
                      UART0Count
                              DCD      0x00000000
                      UART1Count
                              DCD      0x00000000
                      UART0Status
                              DCD      0x00000000
                      UART1Status
                              DCD      0x00000000
    
    iotest.txt
    
    000042  0000              DCW      0x0000
                      |L1.68|
                              DCD      UART0Count
                      |L1.72|
                              DCD      0x4000c000
                      |L1.76|
                              DCD      UART0Buffer
                      |L1.80|
                              DCD      Teststring
    
                              AREA ||.data||, DATA, ALIGN=0
    
                      Teststring
    000000  01020304          DCB      0x31,0x32,0x33,0x34
    000004  35363738          DCB      0x35,0x36,0x37,0x38
    000008  3930              DCB      0x39,0x30
    


    the compiler seem to initialize global variables, but in the debugger did not.in the debugger i to saw symbols,that shown UART0Count value was 0x20485231 and Teststring was 0xd0,0x42,...this value was memory(ram) value,and then i used memset to clean ram(start:0x10000000 size:512byte data:0x0),i to saw UART0Count and Teststring value were 0x00000000,so compiler did not initial,but compile file shown the value were correct.did i setting wrong?

Reply
  • hi everyone,
    i will to see compile file uart.txt and iotest.txt,the result are blow:

    uart.txt
    
     AREA ||.data||, DATA, ALIGN=2
    
                      UART0TxEmpty
    000000  03                DCB      0x01
                      UART1TxEmpty
    000001  010000            DCB      0x01,0x00,0x00
                      UART0Count
                              DCD      0x00000000
                      UART1Count
                              DCD      0x00000000
                      UART0Status
                              DCD      0x00000000
                      UART1Status
                              DCD      0x00000000
    
    iotest.txt
    
    000042  0000              DCW      0x0000
                      |L1.68|
                              DCD      UART0Count
                      |L1.72|
                              DCD      0x4000c000
                      |L1.76|
                              DCD      UART0Buffer
                      |L1.80|
                              DCD      Teststring
    
                              AREA ||.data||, DATA, ALIGN=0
    
                      Teststring
    000000  01020304          DCB      0x31,0x32,0x33,0x34
    000004  35363738          DCB      0x35,0x36,0x37,0x38
    000008  3930              DCB      0x39,0x30
    


    the compiler seem to initialize global variables, but in the debugger did not.in the debugger i to saw symbols,that shown UART0Count value was 0x20485231 and Teststring was 0xd0,0x42,...this value was memory(ram) value,and then i used memset to clean ram(start:0x10000000 size:512byte data:0x0),i to saw UART0Count and Teststring value were 0x00000000,so compiler did not initial,but compile file shown the value were correct.did i setting wrong?

Children