AN INTEGRATED DEVELOPMENT ENVIRONMENT (IDE) FOR THE PIC 16F84 MICRO CONTROLLER IN GNU SYSTEMS

The IDE package

The IDE package includes a compiler, assembler, simulator and a GUI editor. The code was written using Python programming language.

Why PIC ?

Microchip and many other companies have developed free/commercial tools for micro-control based development - but all these tools work only on the Windows platform. There is a real need for a nice development environment on GNU systems. This Integrated Development Environment (IDE) for the Microchip Peripheral Interface Controller (PIC) family of micro-controllers aims to provide extensive support to real time enthusiasts, who want to use a microprocessor, but does not want to be bogged on by its complex instructions. They can write programs in a high-level language provided by the IDE. Our compiler and assembler would generate the equivalent optimized machine code for the PIC 16F84, which can then be readily incorporated into the PIC memory and executed.

COMPONENTS OF THE IDE

GNU PIC COMPILER

The Compiler produces PIC assembly instructions as output. The grammar of the language is made similiar to C. The Python Lex and Yacc tools have been used. Simple optimization techniques have also been employed. A sample program for calculating the factorial of 5 using the language defined by the IDE is given below. (The input filename should end in '.pc')


main()
begin
	count = 1
	a = 1
	while (1)
		count = count + 1
		a = a * count
		if(count > 4)
			break
		endif
	endwhile
end

The Compiler would generate the assembly code as output. (The output file will have the name with the 'pc' extension replaced by 's' extension.)

GNU PIC ASSEMBLER

The assembler reads input from a single source file. The output of the assembler is the machine code in Intel Hex Format. The assembler uses lex.py (of the PLY tool-kit ) to do its pattern matching. When the assembler sees a valid instruction in the input program, it searches the dictionary of instruction:opcode pairs using the instruction as the key, thus retrieving the binary value corresponding to the instruction. (The input filename should end in '.s') The output machine code for the assembly instructions

			

movlw      0xfe
movwf      PORTA
movlw      0x1
andwf      PORTA,1

would be in the Intel Hex Format (in the file with 's' extension replaced by 'hex'), as shown below :

                                    
:08000000fe30850001308505b5
:00000001ff

GNU PIC SIMULATOR

The simulator provides a software environment for testing and debugging machine instructions. Given a program in Intel Hex Format, the simulator simulates the actions of the PIC micro-controller. The result is shown by printing the contents of the working register(accumulator) and other file registers. (For simulation, just run the executable from command prompt and type 'h' for help.)

GUI EDITOR

The Graphical User Interface has been implemented using the tk-inter tool. It provides many simple functions such a opening a new or existing file, writing to it and finally closing it. Also it has provisions for searching a list of directories. Along with this are buttons for compiling and assembling the the file opened. The output of compilation (assembling) is also displayed. For using the editor, just run the script after starting the X server.

Summary

The IDE developed for PIC 16F84 provides extensive real time support for programmers. The programmer can code in the high level language and compile it using the GNU PIC Compiler. The output assembly instructions are then given as input to the GNU PIC Assembler which produces the machine code. The machine code can be written to the PIC's program memory using a programmer. The simulator provides a software platform to test and debug the program. The editor presents a user friendly interface to the IDE.

Authors

The IDE was developed by Neel Mahesh and Dinil Mon Divakaran, both (formerly) students of B.tech (1998-2002 batch) Computer Science and Engineering, Govt. Engg. College, Thrissur, Kerala, India.

Acknowledgement

We are grateful to our advisor, Pramode C. E, who was a constant source of help and inspiration to us.