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.

mikro C if command..teach me pleas...

Status
Not open for further replies.
In a Harvard architecture, the program and register space is in different memory maps, the program is NOT loaded into general purpose locations !

Quote from the MikroC help file:


Brian.
Can you explain it more clearly dear brian I mean then where does the program get loaded while burning to the controller if its not to the general memory locations?
Regards & thanking you.
Jerin.
 

maybe i need to re-phrase the question...
what's wrong with this?

#define counter 0x20

void main(void) {
asm {
clrf counter;
}
}
 

maybe i need to re-phrase the question...
what's wrong with this?

#define counter 0x20

void main(void) {
asm {
clrf counter;
}
}

Try with this code:

register counter = 0x20;

void main(void)
{
asm {
clrf counter;
}
}

Here register refers to the register storage class where mikroC stores variables within internal micro-controller memory.
So I think here 0x20 signifies that the location 0x20 of the general purpose memory is being accessed.
Regards,
Jerin. ;-)
 
But in HIGH TECH C ,
for(int i=0;i<=200;i++){//function//}
is working without any problem!!
 

In a Harvard architecture, there are at least two independent memories. One holds the program, the other holds the variables. Microchip share the variables space with internal peripherals so they can be read and written as though they were memory addresses. For example, in program memory space you can place instructions at address zero in the program memory but there is also a register zero in the variables memory, it is usually the indirect addressing register.

Quoting from the 16F84A data sheet although the others are the same:
There are two memory blocks in the PIC16F84A.
These are the program memory and the data memory.
Each block has its own bus, so that access to each
block can occur during the same oscillator cycle.
The data memory can further be broken down into the
general purpose RAM and the Special Function
Registers (SFRs). The operation of the SFRs that
control the “core” are described here. The SFRs used
to control the peripheral modules are described in the
section discussing each individual peripheral module.

Brian.
 

Yea, you can code in asm within the asm declaration block. In mikroBasic it's asm....end asm. In mikroC, I think it's like:
Code:
asm {
//.....block of assembly instructions
}
C comments (both single-line and multi-line) are allowed in embedded assembly code. Assembly-style comments starting with semicolon are not allowed.

If you plan to use a certain C variable in embedded assembly only, be sure to at least initialize it in C code; otherwise, linker will issue an error. This does not apply to predefined globals such as PORTB.

For example, the following code will not be compiled, as linker won’t be able to recognize variable myvar:
Code:
unsigned myvar;
void main() {
  asm {
    MOVLW 10  // just a test
    MOVLW test_main_global_myvar_1
  }
}
Adding the following line (or similar) above asm block would let linker know that variable is used:
Code:
myvar := 0;

Hope this helps.
Tahmid.
 
Last edited:

But in HIGH TECH C ,
for(int i=0;i<=200;i++){//function//}
is working without any problem!!

I didn't knew that. Actually it is possible to declare like that in C++ only. In C variable declaration should be either global i.e declared above the main function or local i.e inside a function. While declaring as local variable too,the above function should have been:

int i;
for(i=0;i<200;i++)
{
//code
}

Regards,
Jerin.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top