I am using the uVision 3 (demo) with the ULINK debug module on a board which uses the Infineon XC167 microcontroller. We have an external flash as well. I have a small program that increments a value and then uses a printf statement to send it to the serial port. This can then be viewed in hyperterminal. The problem is if I set the board and the flash download utilities to use internal flash memory (on the XC167), the program runs fine. If I change the settings on the board and flash utilities (and other register setups of course) to use external flash, the error message "Error: Flash Download Failed" appears when I try to load the target. Remove the printf statement and everything works fine in external flash. The same is true for the putchar routine (printf uses this). I've checked the generated code size and as far as I can tell we are under the 4K demo limit. This doesn't make any sense to me. It shouldn't make any difference where the code resides. Has anyone seen this? Thanks in advance. -Les
Are you sure that the off-chip flash is actually working correctly?
"It shouldn't make any difference where the code resides." It does with the 8051 Eval tools. Have you checked the Limitations carefully for other restrictions beyond pure code size?
There might be the following problems: - you did not select the correct programming algorithm for off-chip Flash. - the BUS system is incorrectly configured for the off-chip Flash. - your program is located outside of the off-chip Flash addressing space (check the *.M66 linker map file). There is an example provided with the current tools which is configured for off-chip Flash. See: C:\Keil\C166\Boards\Keil MCB-XC167\Blinky_OCDS. The target "External Flash: MCB-XC167" configures ULINK + Tools for off-chip Flash programming.
I guess I didn't make myself clear. I stated in the original post that I can run a program from external flash without any problems until the addition of the printf statement. This means that the EBC is configured correctly and the flash download tools are setup correctly. Add the printf and the download fails, remove the printf and it works great. What other limitations of the demo tools should I look at other than code size? Thanks, Les
I should also clarify that I am only trying to figure out how adding a printf statement can affect the download into external flash. Keep in mind that code WITH the printf statement will function perfectly in internal memory (on chip flash). This means that the code is within the limitations of the demo version of the tools. Also keep in mind that the same code will function in external flash perfectly, if the printf statement is removed. This means that the tools and code have been correctly configured for the external device. As far as my comment that it shouldn't make a difference where code resides, I meant that it should be able to run from internal flash or external flash as long as it was within the proper address space for either device. I hope that helps clear up any confusion about my problem. Thanks again, Les
Check with the help of the linker map file (*.M66) where the application locates program code and constants. What is different when you are using printf. Maybe you have some NCONST sections that are not located within Flash ROM.
Hi Les, we got the same problem with an starterboard for XC16x devices from TQ, if we used a multiplexed bus mode and access to external flash. The problem was that our routines works fine in internal memory, but crashed the debugger session if we accessed the external one. The reason was the dip switch setting on switch 101 and wrong value in EBCMOD1 register. The value for the EBCMOD1 register had to be 0x003F , but was 0x000F. At this time there was a mistake by taking values generated from DAvE into µVision. This should be now solved, so far as I know. Dip 101 -> 2+3 = ON --> Causes an error Dip 101 -> 6+7 = ON --> It works. If you have such a board, I can try to provide you with settings we use. Stefan - Thanks to KEIL support, help us to find this problem -
Hi Stefan, We're actually using a board that we designed. It uses an Atmel AM29F160D which uses a 16 bit demultiplexed address/data scheme therefore the EBCMOD1 is 0x0000. I'm able to run from external flash in general. The only exception is when I add the printf statement, then I get the Flash download failure. I'm hoping this is simply a problem with the demo version. We've purchased the PK166 package and will have it up soon. I appreciate the information though. Thanks, Les
Hi Les, good idea to try the new version. The problem I described was for printf(). All other stuff we were able to run from external memory too. Please leave a message, if your problem is solved ( or even not ). Stefan