MikroC compiler demo problem

Thread Starter

embedtechnology

Joined Dec 25, 2015
35
Hi, I i have written a code for 500 KHz frequency counter . Micro con. I have used is a 89c2051 and the compiler is MikroC 3.6 version. demo. My syntax "value=65535*read+TH1*256+TL1" always load 0 into value. value is a unsigned long, read is a unsigned short which is incremented by 1 for every overflow (interrupt) of timer 1. Because of my code consumes 1990 bytes of hex code(10 bytes below limitation range), I inspect .list and .asm and i found severe mistake in compilation. I don't know why. please help.
 

Attachments

nerdegutta

Joined Dec 15, 2009
2,675
Hi.

If I understand correct, you are using the free version of the MicroC IDE/compiler, with an upper source file limit. (You are 10 bytes below). I don't think the free version is optimizing the code the same way a non-free version would do. Perhaps that is why you find several mistakes in the compilation. Just guessing.

Or, there is something wrong in you code. If so, start with telling the error messages. AFAIK, no one here can read minds. :)
 

Thread Starter

embedtechnology

Joined Dec 25, 2015
35
Hi friends
Thank to all of you. Actually I am not happy with .asm code most of all, line no. 101 to 106. As VALUE a unsigned long constant, it must be 4 byte wide. I do not understand why the compiler loads it's upper two byte with 0 through accumulator !!! apart from that what it meant by 0 (line 101) and 1 (line 102) . Is it R0 and R1
which's values are loaded to first two bytes of VALUE ! With the hex code (which is out put of shown code) my frequency counter always shows " No input " massage although I connect a frequency source into its input.when I load a value to VALUE manually and compile the code, then the display shows the correct frequency value which loaded before compilation.Even debugging I found VALUE to be 0 always, when other variables changes it's value according to .
 

Attachments

spinnaker

Joined Oct 29, 2009
7,837
Hi friends
Thank to all of you. Actually I am not happy with .asm code most of all, line no. 101 to 106. As VALUE a unsigned long constant, it must be 4 byte wide. I do not understand why the compiler loads it's upper two byte with 0 through accumulator !!! apart from that what it meant by 0 (line 101) and 1 (line 102) . Is it R0 and R1
which's values are loaded to first two bytes of VALUE ! With the hex code (which is out put of shown code) my frequency counter always shows " No input " massage although I connect a frequency source into its input.when I load a value to VALUE manually and compile the code, then the display shows the correct frequency value which loaded before compilation.Even debugging I found VALUE to be 0 always, when other variables changes it's value according to .
Before anyone is going to able to help you, you are going to have to make yourself understood. This message makes very little sense.

What error are you getting??? What frequency counter?
 
Last edited:

Thread Starter

embedtechnology

Joined Dec 25, 2015
35
Hi friend
My complete code is given below. I apply frequency(to be measured) to pin 9(p3.5) but it always shows
"No input" massage. please repair my code and I will be really grateful to all of you for ever. thanks in advance.
 

Attachments

spinnaker

Joined Oct 29, 2009
7,837
Hi friend
My complete code is given below. I apply frequency(to be measured) to pin 9(p3.5) but it always shows
"No input" massage. please repair my code and I will be really grateful to all of you for ever. thanks in advance.
I am not your friend I am just someone trying to help, please do not address me as such.

No one is going to fix your code for you. You are going to have to but forth some effort and from the sound of it you have done nothing.

It looks like Timer0InterruptHandler sets update which determines if the "No Input" message is displayed. Turn on your debugger and see if the interrupt handler is being called.

And your code is horrible. There should be no reason to be using so many goto statements. Using goto should be extremely rare in C.
 

Thread Starter

embedtechnology

Joined Dec 25, 2015
35
Many thanks for your kind information but I also know that goto statement is rare in c even compiler vendor already told us that but i want to make an experiment. actually you must not stay but laugh to know the fact that I already made the said project successfully with manually created hex file. i create that file with my own routines. now i am trying to make it with Mikroc on same hardware. it is also to be noted that in my hardware(previously made) I used 8 bit communication mode but i am now using 4 bit mode for lcd. so some syntax may seem to be good for nothing. Also some code should be writen more and more skilfully than that of mine so that it consume less memory space and take less micro seconds to execute. Thank you sir, very much. I am really pleased with your info.
 
Last edited:
Top