16f877 Central Unit (page 1/2)
- page last update january 2009 - (página en castellano)
I have written the program for the microcontroller PIC 16F877 in assembly language. The source code, witch has been compiled in HEX format, can be downloaded and used freely for non commercial purposes. With the link "download" witch you can find at the bottom of this page, you can also obtain the schematics and the preliminary drawing to make the fotolito for the PCB (printed circuit board).
photo Holger Strauss


After learning with the PIC 16F84 and 16F628 I decided to carry out the final project with the PIC 16F877. This powerful microcontroller has 8 integrated ADC's (analog to digital converters) , a USART (serial port), and an electrical erasable flash memory of 8 Kbyte, sufficient for several pages of source code. (datasheet at:http://www.microchip.com)

¿Why a microcontrolador from Microchip?

  • In 1999 the Company Microchip Inc. Technology, launched the PIC 16F84. Because of its simplicity and its flash memory, this microcontroller which allows one to electronically write and erase the programme memory thousands of times, quickly became the world-wide choice in microcontrollers for educative use.
  • The chips made by Microchip have excellent backup user information, and the development tools are economical..
  • The assemble and simulation programs can be downloaded for free from Microchip.
  • Thousands of user applications can be found. One good website is: http://www.phanderson.com/ (Embedded Processor Control; Peter H. Anderson).
  • A lot of additional literature and user applications are widely available.



The panel (table 1 y tabel 2)

Midi_Controller Midi_Controller
table 1: panel Level 0
PAD level 0 LED blue; PAD level1 LED red  PORTC RC,3 (16F877 pin18) level
HOLD on/off (note hold) PORTC RC,1 (16F877 pin16)  
MUTE (stops sending note on)  PORTC RC,0 (16F877 pin15)
Velocity to frequenzie PORTC RC,2 (16F877 pin17)) 
Controller message (h 00B07, 0x40) PORTB RB,6 (16F877 pin39)
Controller message (h 00B07, 0x41) PORTB RB,7 (16F877 pin40)
Controller message (h 00B07, 0x00) PORTC RC,5 (16F877 pin24)
nc PORTC RC,4 (16F877 pin23)
NoteValue -12 (12 medio tonos = 1 octava)

PORTB RB,2 (16F877 pin35) octav -

NoteValue +12 PORTB RB,3 (16F877 pin36) octav + 
Note -1 valores de 0-127 PORTB RB,4 (16F877 pin37) note - 
Note +1 valores de 0-127 PORTB RB,5 (16F877 pin38) note +  
canales - (de 8 hasta 1) PORTB RB,0 (16F877 pin33) channel -
canales + (de 1 hasta 8) PORTB RB,1 (16F877 pin34) channel + 
program (0xCX -0xXX) -1 (127-0) PORTC RC,7 (16F877 pin26) prg.- 
program (0xCX -0xXX) +1 (0-127) PORTC RC,6 (16F877 pin25) prg.+ 
tabla 2: panel Level 1
PAD level 0 LED blue; PAD level1 LED redo PORTC RC,3 (16F877 pin18) level
Controller message (h 00B07, 0x12) PORTC RC,1 (16F877 pin16) 
Controller message (h 00B07, 0x06) PORTC RC,0 (16F877 pin15) 
Velocity to frequenzie PORTC RC,2 (16F877 pin17))  
Velocity -5 (0xBX -0x07 0xXX) steps of 5 PORTB RB,6 (16F877 pin39) 
Velocity +5 (0xBX -0x07 0xXX) steps of 5 PORTB RB,7 (16F877 pin40) 
nc PORTC RC,5 (16F877 pin24) 
nc PORTC RC,4 (16F877 pin23) 
Controller message (h 00B07, 0x66) PORTB RB,2 (16F877 pin35)
Controller message (h 00B07, 0x08) PORTB RB,3 (16F877 pin36)
Controller message (h 00B07, 0x09) PORTB RB,4 (16F877 pin37) 
Controller message (h 00B07, 0x62) PORTB RB,5 (16F877 pin38)  
channel - (de 8 to 1) PORTB RB,0 (16F877 pin33) channel - 
channel + (de 1 to 8) PORTB RB,1 (16F877 pin34) channel +  
program (0xCX -0xXX) -1 (127-0) PORTC RC,7 (16F877 pin26) prg.-  
program (0xCX -0xXX) +1 (0-127) PORTC RC,6 (16F877 pin25) prg.+  
tabla 3: initial values
Note Value 0x3C (middle C) 0x90 0x3A XX
MidiCh level 0 & leve l 1 midi channels: 0x00
RC7, RC6 level0 & level 1 (Program change) prg.: 0x0C 0x00
RB6, RB7 level0 (Velocity (trigger vel-, vel+) vel.: value off 0x64


next page 2/2
download código  HEX para el PIC 16F877 download the HEX sourcecode & the schematics etc.