Objectives: Lab 8 Introduction To Mikroc Language
Objectives: Lab 8 Introduction To Mikroc Language
Objectives: Lab 8 Introduction To Mikroc Language
Objectives
17. To know what is the MikroC Language. 18. To know how to write your first program in MikroC Language. 19. To know the advantages and disadvantages of this language over Assembly Language.
Tools
PIC16F84A microcontroller, MikroC software, PROTEUS software, USB Programmer.
Theory
MikroC is a powerful, feature rich development tool for PICmicros. It is designed to provide the programmer with the easiest possible solution for developing applications for embedded systems, without compromising performance or control. PIC and C fit together well: PIC is the most popular 8-bit chip in the world, used in a wide variety of applications, and C, prized for its efficiency, is the natural choice for developing embedded systems. MikroC provides a successful match featuring highly advanced IDE, ANSI compliant compiler, broad set of hardware libraries, comprehensive documentation, and plenty of ready-to-run examples.
Features of MikroC
MikroC allows you to quickly develop and deploy complex applications: Write your C source code using the built-in Code Editor (Code and Parameter Assistants, Syntax Highlighting, Auto Correct, Code Templates, and more) Use the included MikroC libraries to dramatically speed up the development: data acquisition, memory, displays, conversions, communications Practically all P12, P16, and P18 chips are supported. Monitor your program structure, variables, and functions in the Code Explorer. Generate commented, human-readable assembly, and standard HEX compatible with all programmers. Inspect program flow and debug executable logic with the integrated Debugger. Get detailed reports and graphs: RAM and ROM map, code statistics, assembly listing, calling tree, and more There are plenty of examples for you to expand, develop, and use as building bricks in your projects. Copy them entirely if you deem fit thats why we included them with the compiler. 26
As shown MikroC code needs two steps to be transformed to Machine code, the first step is to transform the C code to Assembly code, which is called Compilation. The second step is to transform the Assembly code to Machine Code, and this process is called Assembling. So, In spite of being easy to write your code in C Language, MikroC Language is slower than the Assembly language because it needs two steps to be transformed to machine language.
Since this sentence is always true. To a delay you can use the following built in functions: Delay_ms(const int) delay_ms(1000) 1 sec Vdelay_ms(int) vdelay_ms(1000) 1 sec To make inverting use ~. To access an individual bit, use the following:
Or
Procedure
Part1:
Write a C code program to make a counter counts from (0 9). Hint // Use for loop and delay function delay_ms. Simulate the program using the circuit shown in figure via Proteus software. Verify it operates properly when simulated. Program a PIC 16F84A using the QL2006 programmer. Build the circuit using the programmed PIC 16F84A and then observe its operation. Demonstrate the circuits operation to the instructor
28
Part2:
Write a C code program to make a flashing wave on PORT B, and then control the direction, and the speed of the flashing wave, through PORT A. Simulate the program using the circuit shown in figure via Proteus software. Verify it operates properly when simulated. Program a PIC 16F84A using the QL2006 programmer. Build the circuit using the programmed PIC 16F84A and then observe its operation. Demonstrate the circuits operation to the instructor
29