 | Discussion Forum |  |
|
|
Debug ok but hexfile not.Next Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Thomas Krampe Posted 24-Nov-2001 16:29 GMT Toolset C166 |  Debug ok but hexfile not. Thomas Krampe Hi,
I am playing with demo version of the Keil µVersion 2.03 and the Infineon SK-167SR. Also , I am not very familair with in C, which makes thinks not easier for me. For me the problem is rather strange. During a debug session almost every thing is runining fine, but if i let the same programm run from the flash of the board it does not.
here is (not) working code
void main(void) { unsigned char num_str[6];
... do soemthing ...
write_string(num_str,1); }
void write_string(char * s, unsigned char line) { unsigned int i; if (line == 1) LCD_CNTL = 0x80; wait(30000); for (i=0; i<strlen(s); i++) { LCD_DATA = s[i]; wait(300); } }
During debuging this is working perfectly. It shows some data on a LCD, but the same program running from flash, writes "only" black squares on the LCD (the complete fist line on my 20*2 LCD).
For me it is quite hard to find the reason for this behavior.
thanks in advance, Thomas | | Read-Only Author Jon Ward Posted 25-Nov-2001 00:41 GMT Toolset C166 |  RE: Debug ok but hexfile not. Jon Ward
void main(void)
{
unsigned char num_str[6];
... do soemthing ...
write_string(num_str,1);
}
What happens after write_string returns?
If your program returns from main, then it's no surprise that it doesn't work when you run it from FLASH.
Add a while (1) before the final curly brace in the main function. (Embedded programs never exit).
Jon
| | Read-Only Author Thomas Krampe Posted 25-Nov-2001 17:50 GMT Toolset C166 |  RE: Debug ok but hexfile not. Thomas Krampe Hi Jon and all other,
sorry Jon, the problem is not this simple. I did'nt want to post all my rocky code here, the while(1) code is already include there.
The problem is a little bit more complicated. I try to explain:
--- this is my theory ---
unsigned char xhuge num_str[6];
The compiler should create a array field of 6 chars somewhere in the memory. The memory on the starterkit starts @ adress 0 with 128 kb Flash and continued with 64 kb RAM.
It is likely the compiler will put this field somewhere in the ram area.
write_string(num_str,1); The pointer of this field should be passed to the function write_string. This happens ONLY if the programm runs an the debug modus but it does not if the program runs from flash. During debuging, programm and data code have to be together in the 64 KB RAM area but, but if it run from flash there are likely to be apart by around 128 KB. Then the function write_string does not get the right postion of the char field, and this is could be the reason why it is not working.
I tryed some memory models added xhuge, but still no effect. So, i still need some help, how i could be overcome this problem.
Thomas | | Read-Only Author Mike Kleshov Posted 25-Nov-2001 19:07 GMT Toolset C166 |  RE: Debug ok but hexfile not. Mike Kleshov Obviously, your program must have two different configurations: one for debugger mode (running from RAM) and the other for normal mode (running from flash). For that I use the multiple targets feature of uVision. You should specify the correct memory mapping for both configurations in the target options window (carefully check ROM and RAM ranges). Another important thing is that C startup file (start167.a66 or whatever it's called) is most probably different for the two configurations, so you need to check that too (external bus settings: BUSCONx and ADDRSELx - it is VERY IMPORTANT). For your first C166 project small memory model is the best choice as long as your code fits in 64K because you don't have to worry about xhuge modifiers and stuff like that. The small memory model allows you to have your code and data separated as far as you want in the address space (see C166 compiler manual). Good luck! Mike
| | Read-Only Author Support Intl Keil Posted 26-Nov-2001 08:40 GMT Toolset C166 |  RE: Debug ok but hexfile not. Support Intl Keil The following answer book entry provides information on how to do this:
http://www.keil.com/support/docs/2076.htm
| | Read-Only Author Krampe Thomas Posted 26-Nov-2001 21:53 GMT Toolset C166 |  RE: Debug ok but hexfile not. Krampe Thomas Hi Support Intl Keil,
first i have to say thank you for your help, but currently i have the feeling, sitting in the middle of nowhere. I could endless read all help files and so on, but i am not good, in inventing the wheel again. I have to go back to learn very basic thinks. For me it is much easier to learn new knowledge by example(s).
I will searching the net for µV2 projects, which are well set up for my existing hardware.
Thomas | | Read-Only Author Mike Kleshov Posted 26-Nov-2001 23:56 GMT Toolset C166 |  RE: Debug ok but hexfile not. Mike Kleshov You don't have to invent the wheel: the manuals describe in detail how it's done :-)) Look into the microcontroller manal as well as Keil's PDFs and you will find the answers to all your questions. Reading the manuals takes some time but sooner or later you'll have to do it. Regards, Mike
| |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|