Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

MikroC programming problem

Status
Not open for further replies.

jameschia

New Member
I am using PIC16F877A to build a Ultra Sonic Sensor. i fail to compile my program due to some error.
can anyone tell me the function of MOVF because i cant find any relevant info from the mikroC manual.
i have uploaded my program and the error during compile. any idea about whats going wrong?
 

Attachments

  • MyProject.c
    5.3 KB · Views: 200
  • Untitled.png
    Untitled.png
    194.3 KB · Views: 208
thanks for that info.
there are some more question here.
coz i m trying to modified the program written by others and i do not know "STACK" is a register in PIC or it is a variable that created by by ourself.
do you know about it?
 
Actually, I used mikroC to escape asm... I believe it will be allocated on a register (GPR) but I'm not sure.
The moment I saw your program, I knew it had to be copy-paste. :)

Anyway, my advice is that you'd better start on MikroC with basic projects first. Have you tried lighting up your LCD on the most basic commands? Or have you even tried blinking LEDs via MikroC's walkthroughs?
 
ya. i have tried the LED blinking program.
as you say, i will try to light up my LCD with a basic command and i will leave my msg here if i got faced any problem. thanks a lot..
 
hi jameschia, use the
code
asm MOVF STACK_2,W
asm MOVWF _tlong+2
asm MOVF STACK_3,W
asm MOVWF _tlong+3

use like this...
 
magnatro, i tried the code already, but the error still there when i compile the program.
it stated there "undeclared identifier 'STACK_2' in expression" and "undeclared identifier 'STACK_3' in expression"
so i think it might be something wrong on the variable, not asm command.
 
There is no way your program knows what STACK_2 is... Its not defined anywhere.
I take it you are messing with the parameters passed in the function..ie int val !!

Code:
#define STACK_2  FSR+1
#define STACK_3  FSR+2
 
Last edited:
i have tried most of the possible code that i can modify, but the error still occur.
is there any setting that need to be done before using the "asm" function?
 
actually i jz to a program and it state that i need to transfer the data of "val"(unsigned int) into "tlong"(long variable).
but some bug occur during the process, so i need to fill the upper 2 byte of tlong manually.
 
In C we use a cast... you can't just transfer in int into a long (data mat still be in there )

Use this statement

Code:
   tlong = (long) val;   // (long) casts the val to a new variable.

This should work.
 
okok. i will try it as soon as possible cause i m currently busy with other stuff.
anyway, thanks for ur help. appreciate!!!!!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top