| Details | Message |
|---|
Read-Only Author Dumitras Damian Posted 24-Apr-2007 23:40 GMT Toolset C166 |  The target doesn't initialize arrays, why? Dumitras Damian 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. |
|
Read-Only Author Chris Wunderlich Posted 25-Apr-2007 00:22 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Chris Wunderlich Could you provide the following information to see what might be your problem? 1) The size of your array? 2) The address of the array from the map file? 3) The declaration of the array in the C file? |
|
Read-Only Author Joost Leeuwesteijn Posted 25-Apr-2007 08:12 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Joost Leeuwesteijn ...and the startup file (startup.a66) that initializes the vars. |
|
Read-Only Author Dumitras Damian Posted 25-Apr-2007 08:25 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Dumitras Damian Hi, Joost Leeuwesteijn. ...and the startup file (startup.a66) that initializes the vars.
But what should I modify in statup.a66 file that could initialize vars? |
|
Read-Only Author Joost Leeuwesteijn Posted 25-Apr-2007 08:40 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Joost Leeuwesteijn > But what should I modify in statup.a66 file that could initialize vars? See: http://www.keil.com/support/docs/2330.htm http://www.keil.com/support/man/docs/c166/c166_ap_start167_a66.htm INIT_VARS and CLR_MEMORY http://www.keil.com/forum/docs/thread8190.asp But your array is not a global so this should not apply... I expect the values to be in the "?tpl?0001" section but I'm not sure. Maybe the compiler optimized it away, if this really is all your code. You could check the assembly file. |
|
Read-Only Author Dumitras Damian Posted 25-Apr-2007 09:28 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Dumitras Damian 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 */
}
|
|
Read-Only Author Joost Leeuwesteijn Posted 25-Apr-2007 11:03 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Joost Leeuwesteijn > In debug mode the target is running well, but in free > running not What do you mean exactly? Debug mode is on a simulator? Or on the target? And free run is on the target? Could there be a problem in the memory map/linker file? Is everything located in RAM? What does the array contain in the incorrect situation? |
|
Read-Only Author Dumitras Damian Posted 25-Apr-2007 12:41 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Dumitras Damian - What do you mean exactly? Debug mode is on a simulator? Or on the target? I mean debug mode is on the target. - And free run is on the target? Yes. Free running I mean the execution of the device after I download the .H86 file to flash of the board. - What does the array contain in the incorrect situation? I think that the length is not defined. When I tryed to determine what the array contains i think is 0xFF... Thank you... |
|
Read-Only Author J L Posted 25-Apr-2007 13:09 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? J L
if(array[cnt] != 1)
putchar('!');
might be wrong. You should better have written
if(array[cnt] != '1')
putchar('!');
|
|
Read-Only Author Dumitras Damian Posted 25-Apr-2007 13:31 GMT Toolset C166 |  No, it was intuitive... Dumitras Damian
if(array[cnt] != 1)
putchar('!');
might be wrong.
No , it was correct. I made just a simple initialization, and tested if it had done... |
|
Read-Only Author Joost Leeuwesteijn Posted 25-Apr-2007 13:35 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Joost Leeuwesteijn No, the array is initialized with 1, not '1', so you should also check using 1 (not the ASCII value). -- Joost |
|
Read-Only Author Dumitras Damian Posted 25-Apr-2007 13:49 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Dumitras Damian Sorry, maybe I didn't understand. the array is initialized with 1, not '1' Yes, it is... you should also check using 1 (not the ASCII value). So , i did. But not this is the problem , the problem is that after the initialization unsigned char array[6]={1,1,1,1,1,1}; the elements of the array are not values of 1 like I expect, so it isn't initialized. And I think the problem is in the project settings or startup file, where I don't know the solution... |
|
Read-Only Author Dumitras Damian Posted 25-Apr-2007 08:21 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Dumitras Damian Thank you for for paying atention, Chris Wunderlich . The information you requested is: My simple code is:
#include <reg161.h>
void main (void) {
unsigned char array[6]={1,2,3,4,5,6};
while (1) {}
}
(1),(3) the size and the declaration - look above; (2) If it'll help you to discover what may be the problem, I pasted the important parts(I think so) from two files(Ithe 'array' word is red as to find it quickly): -> "Phytec KC161.lst"
C166 COMPILER V6.06, PHYTEC_KC161 04/25/2007 09:50:00 PAGE 2
NAME CLASS SPACE TYPE OFFSET SIZE
----------------------------------------------------------------------------
BUSCON1. . . . . . . . . . . . . . . . sfr uint FF14H 2
..
..
main . . . . . . . . . . . . . . . . . public FCODE funct -----
array. . . . . . . . . . . . . . . . auto array 0H 6
?tpl?0001. . . . . . . . . . . . . . . static NCONST array 0H 6
MODULE INFORMATION: INITIALIZED UNINITIALIZED
CODE SIZE = 20 --------
NEAR-CONST SIZE = 6 --------
......
-> "project.m66" :
.......
MEMORY MAP OF MODULE: .\Object\project (PHYTEC_KC161)
START STOP LENGTH TYPE RTYP ALIGN TGR GRP COMB CLASS SECTION NAME
=====================================================================================
000000H 000003H 000004H --- --- --- --- --- --- * INTVECTOR TABLE *
000004H 000005H 000002H XDATA REL WORD --- --- GLOB --- ?C_INITSEC
000008H 00000BH 000004H --- --- --- --- --- --- * RESERVED MEMORY *
00000CH 00001FH 000014H CODE REL WORD --- --- PUBL FCODE ?PR?PHYTEC_KC161
0000ACH 0000AFH 000004H --- --- --- --- --- --- * RESERVED MEMORY *
0000B0H 0001CDH 00011EH CODE REL WORD --- --- PRIV ICODE ?C_STARTUP_CODE
004000H 004005H 000006H DATA REL WORD --- 1 PUBL NCONST ?NC?PHYTEC_KC161
008000H 0080FFH 000100H DATA REL WORD --- 2 PUBL NDATA ?C_USERSTACK
00D900H 00DFFFH 000700H --- --- --- --- --- --- * RESERVED MEMORY *
00FA00H 00FBFFH 000200H --- --- --- --- --- --- * SYSTEM STACK *
00FC00H 00FC1FH 000020H DATA --- BYTE --- --- --- *REG* ?C_MAINREGISTERS
..........
SYMBOL TABLE OF MODULE: .\Object\project (PHYTEC_KC161)
VALUE TYPE REP LENGTH TGR SYMBOL NAME
=========================================================
00000CH GLOBAL LABEL --- --- main
004000H SYMBOL VAR --- --- ?tpl?0001
00000CH BLOCK LVL=0 0014H --- main
00000EH BLOCK LVL=1 0012H ---
000000H SYMBOL AUTO --- --- array
--- BLOCKEND LVL=1 --- ---
........
|
|
Read-Only Author Chris Wunderlich Posted 25-Apr-2007 13:15 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Chris Wunderlich I though Phytec gives you a START167.A66 file with the correct settings of the memory. But it looks like you are using a standard one and as Joost implied you most likely have a problem with this setup. I believe you have the data set to Flash this is your problem. You need the data in RAM. I would suggest that you look for this *.a66 file from Phytec or make sure you have the correct settings for SYSCON and only use the RAM on-chip for now. Your memory settings should look something like this: From the *.lnp file
"START167.obj",
"main.obj"
TO "test"
IXREF
CLASSES (ICODE (0x0-0xBFFF), NCODE (0x0-0xBFFF),
FCONST (0x0-0xBFFF), HCONST (0x0-0xBFFF),
XCONST (0x0-0xBFFF), NCONST (0x4000-0x7FFF),
NDATA (0xC000-0xD7FF, 0xF600-0xFDFF), NDATA0 (0xC000-0xD7FF, 0xF600-0xFDFF),
SDATA (0xC000-0xD7FF, 0xF600-0xFDFF), SDATA0 (0xC000-0xD7FF, 0xF600-0xFDFF),
IDATA (0xF600-0xFDFF), IDATA0 (0xF600-0xFDFF),
FDATA (0xC000-0xD7FF, 0xF600-0xFDFF), FDATA0 (0xC000-0xD7FF, 0xF600-0xFDFF),
HDATA (0xC000-0xD7FF, 0xF600-0xFDFF), HDATA0 (0xC000-0xD7FF, 0xF600-0xFDFF),
XDATA (0xC000-0xD7FF, 0xF600-0xFDFF), XDATA0 (0xC000-0xD7FF, 0xF600-0xFDFF))
CINITTAB (0x0-0xBFFF)
Then you will get something like this which should work.
C166 COMPILER V6.06, MAIN
NAME CLASS SPACE TYPE OFFSET SIZE
----------------------------------------------------------------------------
main . . . . . . . . . . . . . . . . . public NCODE funct -----
array. . . . . . . . . . . . . . . . auto array 0H 6
?tpl?0001. . . . . . . . . . . . . . . static NCONST array 0H 6
START STOP LENGTH TYPE RTYP ALIGN TGR GRP COMB CLASS SECTION NAME
=====================================================================================
000000H 000003H 000004H --- --- --- --- --- --- * INTVECTOR TABLE *
000004H 000005H 000002H XDATA REL WORD --- --- GLOB --- ?C_INITSEC
000006H 000125H 000120H CODE REL WORD --- --- PRIV ICODE ?C_STARTUP_CODE
000126H 000139H 000014H CODE REL WORD --- 2 PUBL NCODE ?PR?MAIN
004000H 004005H 000006H DATA REL WORD --- 3 PUBL NCONST ?NC?MAIN
00C000H 00C1FFH 000200H DATA REL WORD --- 1 PUBL NDATA ?C_USERSTACK
00FA00H 00FBFFH 000200H --- --- --- --- --- --- * SYSTEM STACK *
00FC00H 00FC1FH 000020H DATA --- BYTE --- --- --- *REG* ?C_MAINREGISTERS
If you are a student then you can post your email and I will send you a project. -Chris |
|
Read-Only Author Dumitras Damian Posted 25-Apr-2007 13:27 GMT Toolset C166 |  I'm student...My email... Dumitras Damian Thank you , Chris Wunderlich. Yes , I'm a student and I have to do a project to take my degree. My profesor gave me an eval board and have problems at the begining of the project. Well, if you can give a project with proper settings , my email is damian_dumitras@yahoo.com (or, if it is restricted: damian_dumitras @.. yahoo dot com) Thank you very much. |
|
Read-Only Author Dumitras Damian Posted 25-Apr-2007 14:30 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Dumitras Damian I modified the project, except the startup file, and no changes have made... What and how can I modify in the startup file? |
|
Read-Only Author Chris Wunderlich Posted 25-Apr-2007 14:42 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Chris Wunderlich I'll send you an example program in a few minutes. But again check the value of the SYSCON0 register. You need to enable the XPEN bit. -Chris |
|
Read-Only Author Dumitras Damian Posted 25-Apr-2007 15:31 GMT Toolset C166 |  RE: The target doesn't initialize arrays, why? Dumitras Damian Thanks for the project, and sorry for disturbance. But no changes. I replyed to your mail the results... Is it posible chat anywhere ? Damian. |
|
Read-Only Author Dumitras Damian Posted 25-Apr-2007 19:54 GMT Toolset C166 |  Now the target is working... Dumitras Damian Thanks for Chris Wunderlich. The problem was at the project settings. Also the modifications in the startup file solved this problem. Good luck to every body. |
|