hello,
I started learning with pic microcontroller 16f84A with mikroC Software.but i don't know any language.Very basic knowledge in c only.
how to start using mikroC.there is no tutorial about how to start with mikroc.
To read switch from PORTA and RB0 as input and RB1-RB7 as outputs
If switch is connected to PORTA.F0 then
Code:
void main() {
TRISA = 0b00000001; // set PORTA pin RA0 as input all others as output
PORTA = 0x00; // clear PORTA
TRISB = 0b00000001; // set RB0 as input, RB1 - RB7 as outputs
PORTB = 0x00; // clear PORTB
while(1) {
if (PORTA.F0 = 1) {
// do something
}
}
}
Check this tutorial for learning C language. https://www.cprogramming.com/tutorial/c/lesson6.html
The single "&" sign before a variable indicates that you try to the "Address Of" the value in the memory, not the value stored in this variable.
Code:
For example:
Suppose we have an integer variable called "X" carrying the value "0xAA" and its location in the memory is "0xFE"
printf("Value of X = %d", X); ---> Prints the "0xAA"
printf("Location of X = %d", &X); ---> Prints the "0xFE"