Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Keil uvision4 mdk- arm compiler can't create proper hex file

Status
Not open for further replies.

jjeevan007

Full Member level 5
Full Member level 5
Joined
Apr 13, 2012
Messages
310
Helped
44
Reputation
88
Reaction score
43
Trophy points
1,308
Location
bangalore
Visit site
Activity points
2,782
hi to all,

i have download the evaluation keil uvision 4 for mdk-arm compiler.

but its not creating the proper hex. i mean i written the code for io toggle which works in simulation but not in hardware. my hardware is working fine.

can anyone tell me why the keil uvision 4 is not creating the properly.


regards
jeevan
 

hi to all,

i have download the evaluation keil uvision 4 for mdk-arm compiler.

but its not creating the proper hex. i mean i written the code for io toggle which works in simulation but not in hardware. my hardware is working fine.

can anyone tell me why the keil uvision 4 is not creating the properly.


regards
jeevan

Greetings,
Post your code here. There may be delay problem.

Good Luck :)
 

here is the code.
Code:
#include<lpc21xx.h>

int n,m;

void delay()
{
unsigned int i,j;
for(i=0;i<50;i++)
	for(j=0;j<12750;j++);
   
}
main()
{
	PINSEL0=0x00000000;
	PINSEL1=0x00000000;
	IODIR0=0xffffffff;
	IODIR1=0xffff0000;

		
	
	delay();
	delay();
	delay();
	IOPIN0=0XFFFFFFFF;
	IOPIN1=0XFFFF0000;	
	while(1)
	{
		IOSET0=0xffffffff;
		IOSET1=0xffff0000;
		
		delay();
		delay();
		IOCLR0=0xffffffff;
		IOCLR1=0xffff0000;
			
		
	}

there is no problem in the code or hardware.

the problem is in keil compiler...........
 

Greetings,
Have you tried test programs? Test program like
First program for Turning Led on.
Second Program Led off ??
If not try it.
Simulation world is very different from real time World, it usually happens with people things working in simulation doesn't work in real world most of the time.

Good luck :)
 

hex is getting created, but hex which is created is not proper............

means hex file is not created according to programs...........
 

If you intend "blinking" outputs, you may want to rearrange the delay() statements. As commanded by the code, the ouputs are set most of the time and cleared for a few 100 nanoseconds only. You need an oscilloscope to see it toggle.
 

ya i agree the program is not fully right, if i rearrange the delay() then also its not working,

i tried the below code in with my older version of the keil which is version 3 and with the new version of keil which is version 4 this is downloaded from the keil.com

the version hex file is executing according to code, but when its come to newer version it not.

the keil uvision 3 producing hex file of size around 4kb.

where as keil u vision 4 producing hex file of size around 2kb.

code
Code:
#include<lpc21xx.h>

int n,m;

void delay()
{
unsigned int i,j;
for(i=0;i<50;i++)
	for(j=0;j<12750;j++);
   
}
main()
{
	PINSEL0=0x00000000;
	PINSEL1=0x00000000;
	IODIR0=0xffffffff;
	IODIR1=0xffff0000;

		
	
	delay();
	delay();
	delay();
	IOPIN0=0XFFFFFFFF;
	IOPIN1=0XFFFF0000;	
	while(1)
	{
		IOSET0=0xffffffff;
		IOSET1=0xffff0000;
		
		delay();
		delay();
		IOCLR0=0xffffffff;
		IOCLR1=0xffff0000;
		delay();
		delay();
		
	}

please help.
 

From your description, the issue maybe linked to your delay routine and compiler optimization.

Implementing delays using loop structures in C such as your example:

Code:
void delay()
{
	unsigned int i,j;
	for(i=0;i<50;i++)
	for(j=0;j<12750;j++); 
}

Are precarious at best. Delay routines such as these may compile fine in one version of the compiler and then maybe suddenly "optimized," in whole or in part, out of exist in the next revision.

If you examine your delay routine, you will notice the affected variables are only those with local scope to that routine.

In essence, as far as the compiler is concerned, the delay routine accomplishes nothing and therefore maybe subject to modification/deletion during the optimization phase, which could account for the difference in the sizes of the compiled code that you have indicated.

I would suggest examining the compiled codes in a disassembly windows to determine what exactly has been modified or deleted to reduce the size from 4kB to 2kB.

If the issue is due to optimization, you maybe able to remedy the situation by the use of the keyword volatile during the declaration of both variables i and j within the delay routine or declaring another volatile variable which is incremented or decremented within each for loop.

However, it should be noted the keyword volatile and its impact during compilation process is heavily compiler dependent, which once again puts you at the mercy of the compiler version.

A more optimal solution would be to utilize the devices timers or if a software coded delay is absolutely necessary, code such delays in Assembly language.

The vast majority of delay routines offer by embedded compiler libraries are in fact written in Assembly language for this reason as well as being deterministic concerning the actual delay time interval, which cannot be said for those delay routines written in C or another high level language (HLL).

BigDog
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
What type of problem you are facing in Hardware.
Try Keil simulator and see the delay you are getting when your pins toggle.
Or Post your complete code here.
There might me a problem in setting crystal frequency.

- - - Updated - - -


Code C - [expand]
1
2
3
4
5
6
7
8
/****************Delay Function***************/
void Delay_ms(unsigned long times)
{
    unsigned long i,j;
    for(j=0;j<times;j++)
        for(i=0;i<7500;i++);
}
/*********************************************/



Try this function, I am using this for my LPC2138 and with Keil 4.71a without any problem.

- - - Updated - - -

If you want to generate the delays using Timer Interrupt, then have a look at this link:-

https://sites.google.com/site/coolembeddedlaboratory/home/arm/arm---step-by-step/timer-and-it-s-interrupt
 

the code is fine, i am saying the keil 4.71a compiler is not generating the hex of properly according to the code which i have rewritten................

i have downloaded the evaluation vision recently from keil site.

regards
jeevan
 

please some buddy help me, why my keil uvision 4 is not working is it because evaluation version or some thing else..........
 

Greetings,
Have you selected "create hex file" option in keil? Right click Simulator and go to options for target simulator then tick create hex file option under output tab.
keil 4 hex.jpg
 

ya i have done that.

hex file is getting created, but its not properly means not according to code which i have return..........
 

Turn OFF the optimisation. Compilers may remove some loops as a part of optimisation. So may be your delay loop is being removed inorder to optimise the program. Check that out and let us know.
 

the setting are same but still its not creating the hex file properly, but in debugging session its working correctly .............

i am using the windows xp operating system.............
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top