MikroC Basic Learning


 

manual from MikroC

INTRODUCTION

PIC SUPPORTED

BASIC CIRCUIT

PROGRAMMING

EXAMPLE OF PROJECT

SOFTWARE

SURATKHABAR

CHATROOM

 

Project

HMC Wheelchair

Electronic Circuit

 

Other Link

Jazarie Enterprize

Jazarie Forum

MicroC Learning

Deen Web

Microchip

 

PROGRAMMING

BASIC TO USE MikroC

TRIS

Use as command to tell PIC which pin for input or output. 1 indicates for input and 0 for output.

 

TRISB=0b00000000;       // in binary symbol

TRISB=0x00;                   // in hex symbol

 

RB0 to RB7 is an output pin.

 ----------------------------------------------------

TRISB=0b11111111;      // in binary symbol

TRISB=0xFF;                 // in hex symbol

 

RB0 to RB7 is an input pin.

 ----------------------------------------------------

TRISB=0b01101001;     // in binary symbol

TRISB=0x69;                 // in hex symbol

 

RB0, RB3, RB5, RB6 is an input pin.

RB1, RB2, RB4, RB7 is an output pin.

PORT

PORT is use to generate current to the pin. For ‘1’ is given 5V(20mA) and ‘0’ is given 0V. Before using port, tris must be declared first. For example, when we want to use PORTB so we have to declared TRISB


PORTB=0b00000000;  // in binary symbol

PORTB=0x00;              // in hex symbol

RB0 to RB7 is given 0V (0mA).

------------------------------------------------------------ 

PORTB=0b11111111;     // in binary symbol

PORTB=0xFF;                 // in hex symbol

RB0 to RB7 is given 5V (20mA).

------------------------------------------------------------ 

PORTB=0b01101001;    // in binary symbol

PORTB=0x69;                 // in hex symbol

RB0, RB3, RB5, RB6 is given 5V (20mA).

RB1, RB2, RB4, RB7 is given 0V (0mA).

 

TIME DELAY

In MikroC, for time delay it has specialist. MikroC have already made a special library for time delay. It can be used easily and simple to calculate.

 

delay_ms(500);  // delay for 500ms or 0.5s

delay_us(500);  // delay for 500us or 0.0005s

 

EXAMPLE OF PROGRAM THAT USED TRIS, PORT AND TIME DELAY

SIMPLE LED BLINKING PROJECT

TIMER 0