0% found this document useful (0 votes)
3K views2,505 pages

LCD RS232 Interface

LCD RS232 Interface

Uploaded by

Juan Gil Roca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views2,505 pages

LCD RS232 Interface

LCD RS232 Interface

Uploaded by

Juan Gil Roca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2505

Simple RS232 Interface for Microchip PIC16F84

Simple RS232 Interface


fully software controlled RS232 transmission and reception for PIC16F84

Table of Contents [Toc]

Concept
Project Resources
Available Microchip PIC Assembler Source Code
Schematic, Data Sheets, Pinout

Concept [Toc] [Top]

Fully software controlled RS232 reception and transmission for PIC16F8x. The microcontroller echoes every received RS232 character back to the
RS232 terminal window on the host (i.e. the computer). The HyperTerminal program (Win9x, WinXP) is configured to use the standard settings as
shown below.

PCB test board for PIC16F84 PIC16F84 test board with MAX232
using a dot matrix LCD display and a MAX232 for RS232 Test setup using asynchronous RS232 connection (RX on PortB0, TX on
transmission. PortA0). RS232 to USB1.1 connector in the back.

http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.html (1 of 3)12/02/2008 17:12:28


Simple RS232 Interface for Microchip PIC16F84

Screen shot of the HyperTerminal Program


showing the start-up message of this RS232 test routine. Standard RS232 ComPort settings
(9600-8-N-1)

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Source Code [Toc] [Top]

Main File HEX Files

Download assembler source code: Download Hex File:


rs_test.asm rs_test.hex

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_rs096.
asm

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Schematic, Data Sheets and Pinout [Toc] [Top]

RS232 terminology about DTE and DCE: DTE_DCE_FAQ.pdf

Download ASCII Character Map: ASCII-Map.pdf

You can get the pinout and a description of the various keyboard connectors <here>.

Last updated: 16.01.2005

[Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.html (2 of 3)12/02/2008 17:12:28


Simple RS232 Interface for Microchip PIC16F84

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.html (3 of 3)12/02/2008 17:12:28


http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm

;***************************************************************************
;
; RS232 Test Interface V1.02
; ==========================
;
; written by Peter Luethi, 26.03.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 16.01.2005
;
; V1.02: Fixed copy/paste issue of ISR context store/restore
; (nobody is perfect): Erroneously erased INTCON,INTF
; clearing, resulting in endless ISR calling...
; Re-structured entire ISR and RS232 echo sub-routines
; (11.04.2004)
;
; V1.01: ISR context restore improvements (21.11.1999)
;
; V1.00: Initial release (26.3.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16F84A
; Clock Frequency: 4.00 MHz XT
; Throughput: 1 MIPS
; Baud Rate: depends on the module included
; Code Size of entire Program: approx. 235 instruction words
; Required Hardware: MAX 232
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16F84A, executeable on all interrupt

http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm (1 of 7)12/02/2008 17:12:29


http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm

; featured PICs.
; Program handles all aspects of RS232
; Transmission (Register TXD) and
; Reception (register RXD) through interrupts (PortB0 IRQ).
; The microcontroller sends feedback of received characters back to
; the terminal window.
;
; Program shows the implementation and function of the modules
; m_bank.asm, m_wait.asm, and m_rs096.asm on the PIC16F84A.
;
;***************************************************************************

;***** COMPILATION MESSAGES & WARNINGS *****

ERRORLEVEL -207 ; found label after column 1


ERRORLEVEL -302 ; register in operand not in bank 0

;***** PROCESSOR DECLARATION & CONFIGURATION *****

PROCESSOR 16F84A
#include "p16f84a.inc"

; embed Configuration Data within .asm File.


__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** MEMORY STRUCTURE *****

ORG 0x00 ; processor reset vector


goto MAIN

ORG 0x04 ; interrupt vector


goto ISR ; Interrupt Service Routine (ISR)

;***** PORT DECLARATION *****

#define TXport PORTA,0x00 ; RS232 output port, could be


#define TXtris TRISA,0x00 ; any active push/pull port

;***** CONSTANT DECLARATION *****

CONSTANT BASE = 0x0C ; base address of user file registers

;***** REGISTER DECLARATION *****

http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm (2 of 7)12/02/2008 17:12:29


http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm

FLAGreg equ BASE+d'7'


#define RSflag FLAGreg,0x00 ; RS232 data reception flag

TXD equ BASE+d'8' ; TX-Data register


RXD equ BASE+d'9' ; RX-Data register

W_TEMP equ BASE+d'10' ; context register (ISR)


STATUS_TEMP equ BASE+d'11' ; context register (ISR)
PCLATH_TEMP equ BASE+d'12' ; context register (ISR)
FSR_TEMP equ BASE+d'13' ; context register (ISR)

;***** INCLUDE FILES *****

#include "..\..\m_bank.asm"
#include "..\..\m_wait.asm"
#include "..\..\m_rs096.asm" ; specify desired RS232 module

;***** MACROS *****

;***** SUB-ROUTINES *****

RSservice
SEND TAB
SEND 'E'
SEND 'c'
SEND 'h'
SEND 'o'
SEND ':'
SEND TAB
movfw RXD ; get RS232 data
SENDw ; transmit across RS232
SEND CR ; Carriage Return
SEND LF ; Line Feed
; end of RS232 service (echo & display)
bcf RSflag ; reset RS232 data reception flag
bsf INTCON,INTE ; re-enable RB0/INT interrupt
RETURN

;***** INTERRUPT SERVICE ROUTINE *****

ISR ;************************
;*** ISR CONTEXT SAVE ***

http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm (3 of 7)12/02/2008 17:12:29


http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm

;************************

bcf INTCON,GIE ; disable all interrupts


btfsc INTCON,GIE ; assure interrupts are disabled
goto ISR
movwf W_TEMP ; context save: W
swapf STATUS,W ; context save: STATUS
movwf STATUS_TEMP ; context save
clrf STATUS ; bank 0, regardless of current bank
movfw PCLATH ; context save: PCLATH
movwf PCLATH_TEMP ; context save
clrf PCLATH ; page zero, regardless of current page
bcf STATUS,IRP ; return to bank 0
movfw FSR ; context save: FSR
movwf FSR_TEMP ; context save
;*** context save done ***

;**************************
;*** ISR MAIN EXECUTION ***
;**************************

;*** check origin of interrupt ***


btfsc INTCON,INTF ; check for RB0/INT interrupt
goto _ISR_RS232 ; if set, there was a keypad stroke

; catch-all
goto ISRend ; unexpected IRQ, terminate execution of ISR

;******************************
;*** RS232 DATA ACQUISITION ***
;******************************
_ISR_RS232
; first, disable interrupt source
bcf INTCON,INTE ; disable RB0/INT interrupt
; second, acquire RS232 data
RECEIVE ; macro of RS232 software reception
bsf RSflag ; enable RS232 data reception flag
goto _ISR_RS232end ; terminate RS232 ISR properly

;***********************************
;*** CLEARING OF INTERRUPT FLAGS ***
;***********************************
; NOTE: Below, I only clear the interrupt flags! This does not

http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm (4 of 7)12/02/2008 17:12:29


http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm

; necessarily mean, that the interrupts are already re-enabled.


; Basically, interrupt re-enabling is carried out at the end of
; the corresponding service routine in normal operation mode.
; The flag responsible for the current ISR call has to be cleared
; to prevent recursive ISR calls. Other interrupt flags, activated
; during execution of this ISR, will immediately be served upon
; termination of the current ISR run.
_ISR_RS232error
bsf INTCON,INTE ; after error, re-enable IRQ already here
_ISR_RS232end
bcf INTCON,INTF ; clear RB0/INT interrupt flag
;goto ISRend ; terminate execution of ISR

;*****************************************
;*** ISR TERMINATION (CONTEXT RESTORE) ***
;*****************************************

ISRend movfw FSR_TEMP ; context restore


movwf FSR ; context restore
movfw PCLATH_TEMP ; context restore
movwf PCLATH ; context restore
swapf STATUS_TEMP,W ; context restore
movwf STATUS ; context restore
swapf W_TEMP,F ; context restore
swapf W_TEMP,W ; context restore
RETFIE ; enable global interrupt (INTCON,GIE)

;***** END OF INTERRUPT SERVICE ROUTINE *****

;************** MAIN **************

MAIN
clrf INTCON ; reset interrupts (disable all)
RS232init ; RS232 initialization
clrf FLAGreg ; initialize all flags

SEND CR ; Carriage Return


SEND LF ; Line Feed
SEND 'R'
SEND 'S'
SEND '2'
SEND '3'

http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm (5 of 7)12/02/2008 17:12:29


http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm

SEND '2'
SEND ''
SEND 'T'
SEND 'e'
SEND 's'
SEND 't'
SEND ''
SEND 'I'
SEND 'n'
SEND 't'
SEND 'e'
SEND 'r'
SEND 'f'
SEND 'a'
SEND 'c'
SEND 'e'
SEND ':'
SEND ''
SEND 'P'
SEND 'I'
SEND 'C'
SEND '1'
SEND '6'
SEND 'F'
SEND '8'
SEND '4'
SEND ''
SEND 'c'
SEND 'o'
SEND 'n'
SEND 'n'
SEND 'e'
SEND 'c'
SEND 't'
SEND 'e'
SEND 'd'
SEND '.'
SEND '.'
SEND '.'
SEND CR ; Carriage Return
SEND LF ; Line Feed
SEND LF ; Line Feed

http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm (6 of 7)12/02/2008 17:12:29


http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm

LOOP btfsc RSflag ; check RS232 data reception flag


call RSservice ; if set, call RS232 echo & LCD display routine
goto LOOP

END

http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm (7 of 7)12/02/2008 17:12:29


http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.hex

:020000040000FA
:020000007E2858
:080008004F288C0081018316D2
:100010000313C030810508008C008101831603138F
:10002000C030810501308104831203130B110B1DB5
:1000300017288C0B162808009400051008308C0037
:100040002D2014180514141C0510940C2D208C0B55
:10005000212805142D202D2008001D308D00332867
:1000600008308D0033288D0B332808009501732844
:1000700009301C2045301C2063301C2068301C20B7
:100080006F301C203A301C2009301C2015081C2021
:100090000D301C200A301C2013100B1608008B1387
:1000A0008B1B4F289600030E970083010A089800C7
:1000B0008A018313040899008B185F2875280B1296
:1000C00030200618362808308C002D200618951789
:1000D000061C95130C0B950C8C0B65282D20061C0B
:1000E0003628131474280B168B101908840018086E
:1000F0008A00170E8300960E160E09008B018316D8
:1001000003130510061401138312031305148B1037
:100110000B168B1793010D301C200A301C20523017
:100120001C2053301C2032301C2033301C20323035
:100130001C2020301C2054301C2065301C207330C3
:100140001C2074301C2020301C2049301C206E30B4
:100150001C2074301C2065301C2072301C2066303E
:100160001C2061301C2063301C2065301C203A307C
:100170001C2020301C2050301C2049301C204330D3
:100180001C2031301C2036301C2046301C203830DA
:100190001C2034301C2020301C2063301C206F3089
:1001A0001C206E301C206E301C2065301C206330FB
:1001B0001C2074301C2065301C2064301C202E3024
:1001C0001C202E301C202E301C200D301C200A300C
:0C01D0001C200A301C2013183820EB28DB
:02400E00F13F80
:00000001FF

http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.hex12/02/2008 17:12:29
Microchip PIC microcontroller assembler modules

PIC Assembler Modules


For Non-Commercial Use Only

I would appreciate to be credited within your project, if you use any of the source code below. If you have an interesting project going on, I'll be glad about
feedback.

The software below comes with no guarantee or warranty except for my good intentions. Further the use of this code implies that the user has a fundamental
understanding of electronics and its risks. I'm not responsible for any harm or damage, caused by inproper use of any of the code below.
Any commercial use of parts or all of this code requires the permission of the author.

Table of Contents [Toc]

General
Standard Modules
Dot Matrix LCD Modules
LCD Display Driver Routines
LCD Display Conversion Routines
RS232 Modules
Notes on Modules
General Recommendations
Known Limitations of MPLAB IDE
Technical Hints

General [Toc] [Top]

Modules are source code blocks, which can be included in the MAIN PROGRAM by simply adding the command line:
#include "C:/ (...) m_bank.asm"
The code will be inline expanded. All you need is to specify the necessary registers in front of the include statement in the main program, e.g.

http://www.trash.net/~luethi/microchip/modules/modules.html (1 of 16)12/02/2008 17:12:31


Microchip PIC microcontroller assembler modules

LCDtris equ TRISB


LCDport equ PORTB

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers

#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd.asm"

Standard Modules [Toc] [Top]

Assembler include files: General macros to ease assembler handling, e.g. macros BANK0, BANK1

V2.00 (17.08.2004)
Bank & page handling: Bank0, Bank1,...

Branch macros (to simplify 'IF THEN ELSE' queries):


m_bank.asm BEQ val: branch on equal w and val
BNE val: branch on not equal w and val
BREG val: branch on equal or greater w than val
...

V1.02 (20.08.2004)
Parameterizable wait function, which performs a "busy" wait.
Implemented standard delay (@ 4 MHz):
WAIT 0x01 is equal to 1 unit == 1.02 ms
The assigned standard prescaler for TMR0 is PRESCstd = b'00000001'

Relationship between TMR0 prescaler and unit delay (WAIT 0x01):


b'00000000' == 1:2 ==> 0.512 ms
b'00000001' == 1:4 ==> 1.02 ms (standard)
b'00000111' == 1:256 ==> 65.3 ms

m_wait.asm Declarations needed in main program:


http://www.trash.net/~luethi/microchip/modules/modules.html (2 of 16)12/02/2008 17:12:31
Microchip PIC microcontroller assembler modules

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers

#include "..\m_bank.asm"
#include "..\m_wait.asm"

; Call of implemented procedures with:


; WAIT 0x01 ; standard delay, 1.02 ms
; WAITX d'16',d'7' ; 1.045 s @ 4 MHz, extended with specific prescaler

V1.00 (16.02.2003)
Beep function on parameterizable output port.

Declarations needed in main program:

#define BEEPport PORTA,0x00


#define BEEPtris TRISA,0x00

m_beep.asm CONSTANT BASE = 0x0C ; 16F84 base address of user file registers

#include "..\m_bank.asm"
#include "..\m_beep.asm"

; Call of implemented procedures with:


; BEEPinit ; initialization to set output port
; BEEP 0xFF,0x02

For demo-programs or complete applications, refer to 'Projects' [click here]

Dot Matrix LCD Modules [Toc] [Top]

Assembler include files: Display drivers for dot matrix LCD displays. (Hitachi HD44780 compatibles)

http://www.trash.net/~luethi/microchip/modules/modules.html (3 of 16)12/02/2008 17:12:31


Microchip PIC microcontroller assembler modules

Dot Matrix LCD Display


2 lines x 40 characters
Dot Matrix LCD Display
4 lines x 20 characters

LCD Display Driver Routines [Toc] [Top]

Download the PDF schematic to illustrate the connectivity of both 'classes' of LCD driver routines:

Modules m_lcd.asm, m_lcdx.asm, m_lcd_bf.asm, m_lcdxbf.asm: working only on entire ports ([1..7], without [0]),
e.g. PortB[1..7] on PIC16F84,
or PortB[1..7], PortC[1..7], PortD[1..7] on PIC16F77
Modules m_lcde.asm, m_lcde_bf.asm, m_lcdexbf.asm: working on separate, customizable ports,
e.g. PortB[0..2] for control lines & PortA[0..3] for data lines on PIC16F84, PIC16F7x,
or PortC[5..7] for control lines & PortD[0..3] for data lines on PIC16F77, or ...
Note that the data lines have to be on the low nibble of the port.

http://www.trash.net/~luethi/microchip/modules/modules.html (4 of 16)12/02/2008 17:12:31


Microchip PIC microcontroller assembler modules

V2.06 (26.12.2004)
7 wires, 4 bit LCD interface
Based on timing constraints, no busy flag check. So if LCD fails, system is still running stable. Higher reliability, because less
critical system components.
No portable code for higher clock frequencies.
R/W connection to LCD supported for compatibility to m_lcd_bf.asm, but can be put to GND at LCD side => You'll get one
interrupt pin more on the processor side.

Schematic of LCD connection (PDF)

Declarations needed in main program:

m_lcd.asm LCDtris equ TRISB ; could also be PORTC, PORTD on 16F77


LCDport equ PORTB
; LCD data ports D4-D7 are on LCDport,0x1-0x4
; LCD_EN is on LCDport,0x05 ; Enable
; LCD_RW is on LCDport,0x06 ; Read/Write
; LCD_RS is on LCDport,0x07 ; Register Select

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers

#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd.asm"

V2.26 (26.12.2004)
7 wires, 4 bit LCD interface
Extended m_lcd.asm with the ability to define your own characters (max. 8) in macro LCDspecialChars. Based on timing
constraints, specifications as m_lcd.asm.

Schematic of LCD connection (PDF)

Declarations needed in main program:

m_lcdx.asm
http://www.trash.net/~luethi/microchip/modules/modules.html (5 of 16)12/02/2008 17:12:31
Microchip PIC microcontroller assembler modules

LCDtris equ TRISB ; could also be PORTC, PORTD on 16F77


LCDport equ PORTB
; LCD data ports D4-D7 are on LCDport,0x1-0x4
; LCD_EN is on LCDport,0x05 ; Enable
; LCD_RW is on LCDport,0x06 ; Read/Write
; LCD_RS is on LCDport,0x07 ; Register Select

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers

; complete/replace macro LCDspecialChars to define your own characters


#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcdx.asm"

V3.09 (26.12.2004)
7 wires, 4 bit LCD interface
Extended m_lcd.asm which reads busy flag of LCD (bi-directional communication between controller and LCD)
R/W connection to LCD needed for hand shaking.
Clock independent program code, successfully tested up to 10 MHz on PIC 16F84 and up to 20 MHz on PIC 16C74A!
Gives the best performance, but system fails, if LCD (-connection) fails, because processor is waiting for ready signal from LCD
to send next character. => Deadlock, but should not occur under normal circumstances!
Solution:
Connect an auxilliary 10k resistor from DB7 to GND, so if the LCD is disconnected, the microprocessor will read an inactive
busy flag. (That's needed because of the internal weak pull ups of the microprocessor ports. Maybe also needed if you switch
them off.)

Schematic of LCD connection (PDF)

Declarations needed in main program:

m_lcd_bf.asm

http://www.trash.net/~luethi/microchip/modules/modules.html (6 of 16)12/02/2008 17:12:31


Microchip PIC microcontroller assembler modules

LCDtris equ TRISB ; could also be PORTC, PORTD on 16F77


LCDport equ PORTB
; LCD data ports D4-D7 are on LCDport,0x1-0x4
; LCD_EN is on LCDport,0x05 ; Enable
; LCD_RW is on LCDport,0x06 ; Read/Write
; LCD_RS is on LCDport,0x07 ; Register Select

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers


FLAGreg equ BASE+d'7' ; general flag register
#define LCDbusy FLAGreg,0x00 ; LCD busy flag declared within flag register
#define LCDcflag FLAGreg,0x01

#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd_bf.asm"

V3.29 (26.12.2004)
7 wires, 4 bit LCD interface
Basically the same as m_lcd_bf.asm, but with the ability to define your own characters (max. 8) in macro LCDspecialChars. Bi-
m_lcdxbf.asm directional communication, reads busy flag of LCD.

Schematic of LCD connection (PDF)

V2.12e (17.08.2004)
7 wires, 4 bit LCD interface
Basically as m_lcd.asm, but with the ability to independently configure LCD control and data lines, i.e. LCD data on low nibble
of any port, LCD command lines on any port bits (even different port).

Schematic of LCD connection (PDF)

Declarations needed in main program:

m_lcde.asm

http://www.trash.net/~luethi/microchip/modules/modules.html (7 of 16)12/02/2008 17:12:31


Microchip PIC microcontroller assembler modules

LCDtris equ TRISA ; LCD data on low nibble of portA


LCDport equ PORTA
#define LCD_ENtris TRISB,0x01 ; EN on portB,1
#define LCD_EN PORTB,0x01
#define LCD_RStris TRISB,0x02 ; RS on portB,2
#define LCD_RS PORTB,0x02
#define LCD_RWtris TRISB,0x03 ; RW on portB,3
#define LCD_RW PORTB,0x03

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers

#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcde.asm"

V4.03e (17.08.2004)
7 wires, 4 bit LCD interface
Extended m_lcde.asm which reads busy flag of LCD (bi-directional communication between controller and LCD)

Schematic of LCD connection (PDF)

Declarations needed in main program:

LCDtris equ TRISA ; LCD data on low nibble of portA


LCDport equ PORTA
#define LCD_ENtris TRISB,0x01 ; EN on portB,1
#define LCD_EN PORTB,0x01
m_lcde_bf.asm #define LCD_RStris TRISB,0x02 ; RS on portB,2
#define LCD_RS PORTB,0x02
#define LCD_RWtris TRISB,0x03 ; RW on portB,3
#define LCD_RW PORTB,0x03

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers


FLAGreg equ BASE+d'7' ; general flag register
#define LCDbusy FLAGreg,0x06 ; LCD busy flag declared within flag register
#define LCDcflag FLAGreg,0x07 ; LCD command/data flag

#include "..\m_bank.asm"
http://www.trash.net/~luethi/microchip/modules/modules.html (8 of 16)12/02/2008 17:12:31
Microchip PIC microcontroller assembler modules

#include "..\m_wait.asm"
#include "..\m_lcde_bf.asm"

V4.23e (17.08.2004)
7 wires, 4 bit LCD interface
Basically the same as m_lcde_bf.asm, but with the ability to define your own characters (max. 8) in macro LCDspecialChars. Bi-
m_lcdexbf.asm directional communication, reads busy flag of LCD.

Schematic of LCD connection (PDF)

For demo-programs or complete applications, refer to 'Projects' [click here]

LCD Display Conversion Routines [Toc] [Top]

V1.02 (20.08.2004)
8 bit binary to decimal conversion routine for LCD output, stringent for any numeric display output or
interaction.

Declarations needed in main program:

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers


FLAGreg equ BASE+d'4' ; general flag register
LO equ BASE+d'5'
m_lcdv08.asm LO_TEMP set BASE+d'6'
#define BCflag FLAGreg,0x00 ; blank checker for preceding zeros

#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd.asm"
#include "..\m_lcdv08.asm"

; Call of implemented procedure with:


LCDval_08 ; result is stored in register LO

http://www.trash.net/~luethi/microchip/modules/modules.html (9 of 16)12/02/2008 17:12:31


Microchip PIC microcontroller assembler modules

V1.02 (20.08.2004)
16 bit binary to decimal conversion routine for LCD output, stringent for any numeric display output or
interaction.

Declarations needed in main program:

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers


FLAGreg equ BASE+d'4' ; general flag register
LO equ BASE+d'5'
HI equ BASE+d'6'
m_lcdv16.asm LO_TEMP set BASE+d'7'
HI_TEMP set BASE+d'8'
#define BCflag FLAGreg,0x00 ; blank checker for preceding zeros

#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd.asm"
#include "..\m_lcdv16.asm"

; Call of implemented procedure with:


LCDval_16 ; result is stored in registers HI, LO

V1.00 (20.08.2004)
8 bit binary LCD output routine for debugging of registers and bitstreams, e.g. to visualize the binary output of
an A/D converter to check the magnitude of its LSB toggling due to digital quantization and/or noise.

Declarations needed in main program:

m_lcdb08.asm

http://www.trash.net/~luethi/microchip/modules/modules.html (10 of 16)12/02/2008 17:12:31


Microchip PIC microcontroller assembler modules

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers


b08_cnt equ BASE+d'4' ; counter
LO equ BASE+d'5'
LO_TEMP set BASE+d'6'

#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd.asm"
#include "..\m_lcdb08.asm"

; Call of implemented procedure with:


LCDbin_08 ; value in register LO, output to LCD

V1.00 (20.08.2004)
16 bit binary LCD output routine for debugging of registers and bitstreams, e.g. to visualize the binary output of
an A/D converter to check the magnitude of its LSB toggling due to digital quantization and/or noise.

Declarations needed in main program:

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers


b16_cnt equ BASE+d'4' ; counter
LO equ BASE+d'5'
HI equ BASE+d'6'
m_lcdb16.asm LO_TEMP set BASE+d'7'
HI_TEMP set BASE+d'8'

#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd.asm"
#include "..\m_lcdb16.asm"

; Call of implemented procedure with:


LCDbin_16 ; values in register HI, LO, output to LCD

For demo-programs or complete applications, refer to 'Projects' [click here]

http://www.trash.net/~luethi/microchip/modules/modules.html (11 of 16)12/02/2008 17:12:31


Microchip PIC microcontroller assembler modules

RS232 Modules [Toc] [Top]

For external interrupts, such as the RB0/INT pin or PORTB change interrupt, the latency will be three to four instruction cycles. The exact latency depends
on when the interrupt occurs. The latency is the same for both one and two cycle instructions.
(=> see Microchip PIC16/17 Microcontroller Databook.)

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232 : RS232-Interface.pdf (9.7 kB)

V1.02 (11.04.2004)
Completely software handled RS232 Interface for interrupt featured PICs (PIC16C84, PIC16F84,...).
Specifications: 2400 baud, 8 bit, no parity, 1 stopbit (@ 4 MHz / 1 MIPS)

Declarations needed in main program:

#define TXport PORTA,0x00 ; RS232 output port, could be


#define TXtris TRISA,0x00 ; any active push/pull port
; RS232 input port is RB0, because of its own interrupt flag

CONSTANT BASE = 0x0C ; 16F84 base address of user file registers


m_rs024.asm TXD equ BASE+d'7' ; TX data register, for transmission
RXD equ BASE+d'8' ; RX data register, for storage

#include "..\m_bank.asm"
#include "..\m_rs024.asm"

; Call of implemented procedures with:


; RS232init ; initialization
; SEND 'c' ; sends character 'c'
; SENDw ; sends content of working register
; RECEIVE ; macro in ISR: receive from RS232,
; store in register RXD

http://www.trash.net/~luethi/microchip/modules/modules.html (12 of 16)12/02/2008 17:12:31


Microchip PIC microcontroller assembler modules

V1.02 (11.04.2004)
m_rs048.asm Functionality as m_rs024.asm
Specifications: 4800 baud, 8 bit, no parity, 1 stopbit (@ 4 MHz / 1 MIPS)

V1.02 (11.04.2004)
m_rs096.asm Functionality as m_rs024.asm
Specifications: 9600 baud, 8 bit, no parity, 1 stopbit (@ 4 MHz / 1 MIPS)

V1.02 (11.04.2004)
m_rs192.asm Functionality as m_rs024.asm
Specifications: 19200 baud, 8 bit, no parity, 1 stopbit (@ 4 MHz / 1 MIPS)

V1.02 (11.04.2004)
Functionality as m_rs024.asm
m_rs7n1.asm
Developed for an old and heavy matrix needle printer with RS232 Interface.
Specifications: 9600 baud, 7 bit, no parity, 1 stopbit (@ 4 MHz / 1 MIPS)

For demo-programs or complete applications, refer to 'Projects' [click here]

Notes on Modules [Toc] [Top]

Code is optimized for 1. small memory, and 2. optimal execution time.


If extern sources are called from within modules, set absolute pathes. Please refer to Known Limitations of MPLAB IDE below.
Declare and define the required registers and statements in the MAIN.
Declarations of constants and registers need to be listed in the MAIN before the '#include' statement of the modules, since most modules are
referencing specific constants and registers (therefore they need to be defined at that time).

General Recommendations [Toc] [Top]

Manage the used registers in a clear structured way.


For prototyping, it is recommended to introduce temporarily dedicated registers for each new code segment. At the end, when everything runs
properly, you can start to optimize the design in order to share as much registers as possible to save memory space. Otherwise, you run the risk of
getting data consistency problems - bugs, which are really hard to solve!
Provide dedicated registers for interrupt handling! Do not call subroutines from the interrupt service routine (ISR), which are executed during normal
operation. If so, ensure to perform a complete context save of all registers being used within this subroutine.
Interrupt flags have to be cleared by software before re-enabling the 'global interrupt enable bit' (GIE) and exiting the ISR. Otherwise, recursive ISR
http://www.trash.net/~luethi/microchip/modules/modules.html (13 of 16)12/02/2008 17:12:31
Microchip PIC microcontroller assembler modules

calling occurs.
At the beginning of the ISR, disable the 'global interrupt enable bit' (GIE). In case different interrupt sources have to be served, it may be necessary
to disable also the related 'interrupt source enable bit' (e.g. INTF of RB0/INT pin). See next recommendation
On ISR exit, make sure to reset the interrupt flag of the source, which triggered the interrupt. But perform re-enabling of the corresponding 'interrupt
source enable bit' at the end of the corresponding service routine:
- If the interrupt service is entirely completed within the ISR, re-enabling is suitable at the end of the ISR. This applies only, if disabling of the
interrupt source has been carried out at the beginning of the ISR.
- If parts of the interrupt service are carried out during normal operation, re-enabling the interrupt source is most suitable at the end of the external
code part. In this case, disabling the specific interrupt source at the beginning of the ISR is stringent, otherwise we face lost of data or a system crash
due to return address stack overflow. This method owns a further advantage: A subsequent interrupt already having been triggered before re-
activation and originating from the same source is not omitted and will immediately be served. (This is because the interrupt flag bit gets still set,
when the interrupt is temporarily disabled. When unmasking this interrupt source, the interrupt is immediately triggered.)

Known Limitations of MPLAB IDE [Toc] [Top]

Previously MPLAB worked with the old MS DOS 8.3 name convention (so set paths with old notation).
With the recent MPLAB versions beyond 6.30 (I use currently 6.40 and PICstart Plus), it seems they accept also longer file names. That's while my
include files sometimes have strange names. There is also an upper limitation on the amount of characters in an absolute file name including path.
'#include' - commands in the MAIN could be relative (..\..\xyz.asm) or absolute paths (C:\abc\xyz.asm).
'#include' - commands in extern source have to be absolute paths (if extern source is called with relative path).

Technical Hints [Toc] [Top]

If you use 'set' instead of 'equ', you can assign different labels to the same register. This is very useful, if you need temporary registers in different
modules. But be careful that you do not write and access the same register alternating in 2 different procedures. This results in nice bugs or possibly
endless loops.
'equ' is exclusive, i.e. it accepts only one label for each register.
If you want to create a 16 bit assembler look-up table very quickly, have a look at the
Automatic Table Generator for MPLAB Assembler.
To specify exact periods (e.g. with busy wait module m_wait.asm), I use quite often the MPLAB stopwatch. This is a very convenient cycle-accurate
timer, which takes both 1 cycle (e.g. incf) and 2 cycle instructions (e.g. goto) as well as special instruction mnemonics (e.g. bnc, subcf) into account.
I just let the simulator run to the wait statement or loop to be measured, reset the stopwatch, and let it again simulate until after the wait statement:

http://www.trash.net/~luethi/microchip/modules/modules.html (14 of 16)12/02/2008 17:12:31


Microchip PIC microcontroller assembler modules

The Stopwatch
having been reset at 'bsf TXport' and run to the 'nop' statement. The latency of the 'WAITX d73,d2'
statement within this setup (4 MHz clock, PIC16F84) turns out to be approximately 150 ms.

Last updated: 15.01.2006

[Toc] [Top]

If you see only this page in your browser window,


click here
http://www.trash.net/~luethi/microchip/modules/modules.html (15 of 16)12/02/2008 17:12:31
Microchip PIC microcontroller assembler modules

to get the entire site.

http://www.trash.net/~luethi/microchip/modules/modules.html (16 of 16)12/02/2008 17:12:31


1 2 3 4

PIC16F84 MAX232
D (Direction seen from controller) D
VDD
VDD
R1 XT1 VSS
C4
16k C3
4.000 MHz 10u
C1 C2 10u
S1 10p VDD 10p

16
2
6
SW-PB VSS VSS

14
U1
C5 13 12

V+

VCC
V-
IC_PIC1 RS232 TXD R1 IN R1 OUT PIC RXD
RS232 8 9 5V
16 15 RS232 DTR R2 IN R2 OUT 5V DTR

VDD
VSS 4n7 OSC1/CLKIN OSC2/CLKOUT 11 14
4 7 PIC TXD T1 IN T1 OUT RS232 RXD
MCLR RB1 5V 10 7 RS232
17 8 5V DSR T2 IN T2 OUT RS232 DSR
C PIC TXD RA0 RB2 1 4 C

GND
18 9 C1+ C2+
RA1 RB3 3 5
5V DSR 1 10 C1 - C2 -
RA2 RB4
2 11
RA3 RB5 C6 MAX232CPE(16) C7
5V DTR 3 12
RA4/T0CKI RB6 10u 10u
VSS

15
6 13
PIC RXD RB0/INT RB7
PIC16F84-04/P(18)
5

VSS
VDD
VDD VSS
VDD
C8
DSR and DTR signals are not used in
100n
B VSS RS232 my RS232 routines, but are drawn for
completion. These signals are necessary C9
B
VSS
(Direction seen from host) for hardware handshaking, whilst my 100n
routines perform no handshaking. The
RS232 DTR MAX232 has two output and two input VSS
RS232 TXD VSS channels, specified to transmit up to 120
kbps depending on the type used.
RS232 RXD
RS232 DSR
1
6
2
7
3
8
4
9
5

Title
PIC-RS232 Interface using MAX232
A A
Written by Date
SUB1 20-Aug-2003
Peter Luethi
DB9 Revision Page
Dietikon, Switzerland 1.01 1 of 1

1 2 3 4
RS-232 CONNECTIONS THAT WORK!
DTE & DCE FAQ
PAGE 1 OF 5

RS-232 CONNECTIONS THAT WORK! - Connecting Devices or Converters


Connecting two devices using RS-232 sounds simple, but nearly every day we help a customer
get a converter, isolator or other RS-232 device working by helping correct the RS-232 cabling
connections. This FAQ will help you troubleshoot and correct such problems.

Usually inputs are connected to inputs and outputs to outputs. People don't realize that there are
two types of RS-232 ports, DTE and DCE type, and that the signal names and pin numbers are
the same, but signal flow is opposite! The pin labeled Tx can be input, and Rx the output.

The two ports types are complementary, the Output signals on a DTE port are Inputs to a DCE
port, and Output signals on a DCE port are Inputs to a DTE port. The signal names match each
other and connect pin for pin. Signal flow is in the direction of the arrows. (see figures below)

How Can I Identify DTE or DCE Type Connections?

What devices have DTE type RS-232 ports? A DTE device is "Data Terminal Equipment", this
includes Computers, Serial Printers, PLC's, Video Cameras, Video Recorders, Video Editors, and
most devices which are not used to extend communications. Think COMPUTER for DTE.

What devices have DCE type RS-232 ports? A DCE device is "Data Communications
Equipment", this includes devices intended to plug directly into a DTE port, PDA cables, Modems
and devices that extend communications like a modem, such as RS-422, RS-485, or Fiber Optic
converters or Radio Modems. Think MODEM for DCE

B&B Electronics Mfg. Co. http://www.bb-elec.com 29Apr03


RS-232 CONNECTIONS THAT WORK!
DTE & DCE FAQ
PAGE 2 OF 5

Rule of Thumb: When connecting a DTE device to a DCE device, match the signal names. When
connecting two DTE or two DCE devices together, use a Crossover cable. (TD crosses to RD,
RTS to CTS, DTR to DSR as shown in Modem to Modem connections. (see 9PMMNM) The
cable for two computers (DTE) also simulates modem connections to CD/DSR, so it is commonly
called a "Null Modem" cable. (see 232DTE or 232NM9)

B&B Electronics Mfg. Co. http://www.bb-elec.com 29Apr03


RS-232 CONNECTIONS THAT WORK!
DTE & DCE FAQ
PAGE 3 OF 5

Are My Devices Wired As DTE or DCE? - How to Check

1. Use Rule of Thumb - If the device plugs into the computer serial port and works normally, the
device is wired as DCE (or the connection cable is a crossover type that makes it work as a
DCE). If the device connects to the computer port using a "null modem" crossover cable, it is
wired as DTE.

2. Use RS-232 Line Tester - A quick and easy way to determine the DTE/DCE port type is to
use a RS-232 line tester such as the 9PMTT. The tester can show the signal state of any
active RS-232 data lines using LED's lighting Red or Green. Active data lines are output from
a device, they may be either High or Low.

Continued next page

B&B Electronics Mfg. Co. http://www.bb-elec.com 29Apr03


RS-232 CONNECTIONS THAT WORK!
DTE & DCE FAQ
PAGE 4 OF 5

Just plug the tester into either of the two devices, see which lines are lit, unplug it, then plug it in
to the other device, see which lines are lit. (see figures).

If the same light (TD or RD) is lit, use a crossover cable or null modem connector that swaps the
connections for pins #2 and #3 and other pins as needed.

If the device is "port powered" check the active side, then plug in the port powered device and
see if other (TD or RD) LED is lit. If not, try swapping the leads with a null modem cable, see if
the other LED now lights. If not, you may not have enough voltage on the handshaking lines of
the port to steal power from.

B&B Electronics Mfg. Co. http://www.bb-elec.com 29Apr03


RS-232 CONNECTIONS THAT WORK!
DTE & DCE FAQ
PAGE 5 OF 5

3. Use a DC Voltmeter Technicians with a DC voltmeter can use it to measure the DC level
from signal ground (pin#5 on DB9, pin#7 on DB25) on the connector to pin #2 or pin #3.
When the unit is powered and not sending data, the output line will have a DC voltage of
minus polarity, 3 volts to 11 volts will be typical. The other pin will have little or no voltage.
For example, we measure -11 volts on pin#2 of a DB9 connector and the line is labeled RD
or Rx, then the device is wired as DCE. If we measure the voltage on pin#3, it is DTE.

Measure pin #2 and pin #3 to ground (pin # 5 - DB9) (pin #7 -- DB25) on the on the cable
from the first device, the on the device you want to connect. If the cable and device have
voltage on the same pin, you need to use a crossover or null modem connector that swaps
pins #2 & #3 and the other pins. (For DB9 see model 9PMMNM, for DB25 see 232DTE)

Electrically active handshaking lines will be negative when not asserted or positive when
asserted. (for reference, see line tester figures). Active handshaking lines can be found by
measuring each pin for voltage. Output lines will have voltage. On a DTE, DTR and RTS will
have voltage if used. On a DCE, DSR and CTS will have voltage, and if a modem with CD
(Carrier Detect) and RI (Ring Indicator) these last two will be low until Ring is detected or a
Carrier connection is made. If handshaking lines don't have voltage when the device is
powered on and ready, the device doesn't output them, they may be looped back, RTS to
CTS and DTR to DSR. You can turn off the device power and measure for continuity (zero
ohms) between pins to confirm if they are looped back.

Other RS-232 Connection Problems

1. Handshaking lines RTS and CTS not interconnected, DTR and DSR not interconnected.
Swap as needed.

2. Programs may use the RTS/CTS connection to check that a device is ready to receive data
and respond. If there is No CTS connection, the program will never send data, but wait a
long time or timeout with an error. The RTS line may need to be looped back to the CTS
input. Data errors can occur if the device actually requires handshaking.

3. Programs may also use the DTR/DSR line connection to check that a cable is connected or
that the device is turned on. If there is No DSR signal, the DTR line may need to be looped
back to the DSR input. Some devices use DTR handshaking.

4. Each signal required for unit operation must be carried through by the isolator, modem or RS-
422 or fiber optic converter. The primary "2 Channels" for RS-232 are Receive & Transmit.
There are 2 data flow control channels, RTS and CTS. If these are missing, data is lost,
characters missing, or files scrambled.

5. Connections to Telephone Modem/FAX modem - Make sure CD & RI lines are connected.

Recommended Accessories for Connections


232CAM - DB9F to DB25M conversion cable - 6 ft. (1.8 m)
232CAMS - DB9F to DB25M conversion/strain relief cable - 6 inches (15 cm)
232CAMR - DB9M to DB25F conversion/stain relief cable - 12 inches (30 cm)
RS232 Null Modem Connectors
232DTE - DB25F to DB25M - 25 pin female/male
PMMNM - DB9M to DB9M - 9 pin male/male
RS232 Line Testers
9PMTT - DB9F to DB9M - 9 pin female/male
232BOB1 - Breakout Box DB25F to DB25M with switches & jumpers
Jumper Boxes
Please refer to our catalog or website for jumper boxes for DB9, DB25, DB9/25, M/F, F/F, & M/M and
DB9 or DB25 to RJ11/RJ12 or RJ45 connectors.
-twr

B&B Electronics Mfg. Co. http://www.bb-elec.com 29Apr03


ASCII Character Map
32 00100000 20 90 Z 01011010 5A
33 ! 00100001 21 91 [ 01011011 5B
34 " 00100010 22 92 \ 01011100 5C
35 # 00100011 23 93 ] 01011101 5D
36 $ 00100100 24 94 ^ 01011110 5E
37 % 00100101 25 95 _ 01011111 5F
38 & 00100110 26 96 ` 01100000 60
39 ' 00100111 27 97 a 01100001 61
40 ( 00101000 28 98 b 01100010 62
41 ) 00101001 29 99 c 01100011 63
42 * 00101010 2A 100 d 01100100 64
43 + 00101011 2B 101 e 01100101 65
44 , 00101100 2C 102 f 01100110 66
45 - 00101101 2D 103 g 01100111 67
46 . 00101110 2E 104 h 01101000 68
47 / 00101111 2F 105 i 01101001 69
48 0 00110000 30 106 j 01101010 6A
49 1 00110001 31 107 k 01101011 6B
50 2 00110010 32 108 l 01101100 6C
51 3 00110011 33 109 m 01101101 6D
52 4 00110100 34 110 n 01101110 6E
53 5 00110101 35 111 o 01101111 6F
54 6 00110110 36 112 p 01110000 70
55 7 00110111 37 113 q 01110001 71
56 8 00111000 38 114 r 01110010 72
57 9 00111001 39 115 s 01110011 73
58 : 00111010 3A 116 t 01110100 74
59 ; 00111011 3B 117 u 01110101 75
60 < 00111100 3C 118 v 01110110 76
61 = 00111101 3D 119 w 01110111 77
62 > 00111110 3E 120 x 01111000 78
63 ? 00111111 3F 121 y 01111001 79
64 @ 01000000 40 122 z 01111010 7A
65 A 01000001 41 123 { 01111011 7B
66 B 01000010 42 124 | 01111100 7C
67 C 01000011 43 125 } 01111101 7D
68 D 01000100 44 126 ~ 01111110 7E
69 E 01000101 45 127 01111111 7F
70 F 01000110 46 128 10000000 80
71 G 01000111 47 129 10000001 81
72 H 01001000 48 130 10000010 82
73 I 01001001 49 131 10000011 83
74 J 01001010 4A 132 10000100 84
75 K 01001011 4B 133 10000101 85
76 L 01001100 4C 134 10000110 86
77 M 01001101 4D 135 10000111 87
78 N 01001110 4E 136 10001000 88
79 O 01001111 4F 137 10001001 89
80 P 01010000 50 138 10001010 8A
81 Q 01010001 51 139 10001011 8B
82 R 01010010 52 140 10001100 8C
83 S 01010011 53 141 10001101 8D
84 T 01010100 54 142 10001110 8E
85 U 01010101 55 143 10001111 8F
86 V 01010110 56 144 10010000 90
87 W 01010111 57 145 10010001 91
88 X 01011000 58 146 10010010 92
89 Y 01011001 59 147 10010011 93
148 10010100 94 202 11001010 CA
149 10010101 95 203 11001011 CB
150 10010110 96 204 11001100 CC
151 10010111 97 205 11001101 CD
152 10011000 98 206 11001110 CE
153 10011001 99 207 11001111 CF
154 10011010 9A 208 11010000 D0
155 10011011 9B 209 11010001 D1
156 10011100 9C 210 11010010 D2
157 10011101 9D 211 11010011 D3
158 10011110 9E 212 11010100 D4
159 10011111 9F 213 11010101 D5
160 10100000 A0 214 11010110 D6
161 10100001 A1 215 11010111 D7
162 10100010 A2 216 11011000 D8
163 10100011 A3 217 11011001 D9
164 10100100 A4 218 11011010 DA
165 10100101 A5 219 11011011 DB
166 10100110 A6 220 11011100 DC
167 10100111 A7 221 11011101 DD
168 10101000 A8 222 11011110 DE
169 10101001 A9 223 11011111 DF
170 10101010 AA 224 11100000 E0
171 10101011 AB 225 11100001 E1
172 10101100 AC 226 11100010 E2
173 - 10101101 AD 227 11100011 E3
174 10101110 AE 228 11100100 E4
175 10101111 AF 229 11100101 E5
176 10110000 B0 230 11100110 E6
177 10110001 B1 231 11100111 E7
178 10110010 B2 232 11101000 E8
179 10110011 B3 233 11101001 E9
180 10110100 B4 234 11101010 EA
181 10110101 B5 235 11101011 EB
182 10110110 B6 236 11101100 EC
183 10110111 B7 237 11101101 ED
184 10111000 B8 238 11101110 EE
185 10111001 B9 239 11101111 EF
186 10111010 BA 240 11110000 F0
187 10111011 BB 241 11110001 F1
188 10111100 BC 242 11110010 F2
189 10111101 BD 243 11110011 F3
190 10111110 BE 244 11110100 F4
191 10111111 BF 245 11110101 F5
192 11000000 C0 246 11110110 F6
193 11000001 C1 247 11110111 F7
194 11000010 C2 248 11111000 F8
195 11000011 C3 249 11111001 F9
196 11000100 C4 250 11111010 FA
197 11000101 C5 251 11111011 FB
198 11000110 C6 252 11111100 FC
199 11000111 C7 253 11111101 FD
200 11001000 C8 254 11111110 FE
201 11001001 C9 255 11111111 FF
Pinouts of various connectors

Pinout of most common Connectors


originally written by Deceed, adopted and translated by P. Luethi with permission

Serial 9 Pin (PC)


Serial 25 Pin (PC)
Parallel (PC)
Centronics (Printer)
PC Gameport / MIDI
Keyboard 5 Pin (PC)
Keyboard 6 Pin (PS/2)
VGA
SCART

Serial 9 Pin (PC)


Back to Contents

(9p D-SUB male at PC (DTE))

(9p D-SUB female at cable / mouse (DCE))

Pin Name Dir Description


1 CD Carrier Detect
2 RXD Receive Data
3 TXD Transmit Data
4 DTR Data Terminal Ready
5 GND System Ground

http://www.trash.net/~luethi/microchip/datasheets/pinout/pinout.html (1 of 11)12/02/2008 17:12:37


Pinouts of various connectors

6 DSR Data Set Ready


7 RTS Request to Send
8 CTS Clear to Send
9 RI Ring Indicator

Direction seen from PC (TX/RX)

Serial 25 Pin (PC)


Back to Contents

(25p D-SUB male at PC (DTE))

(25p D-SUB female at cable / modem (DCE))

Pin Name Dir Description


1 SHIELD Shield Ground
2 TXD Transmit Data
3 RXD Receive Data
4 RTS Request to Send
5 CTS Clear to Send
6 DSR Data Set Ready
7 GND System Ground
8 CD Carrier Detect
9 n/c
10 n/c

http://www.trash.net/~luethi/microchip/datasheets/pinout/pinout.html (2 of 11)12/02/2008 17:12:37


Pinouts of various connectors

11 n/c
12 n/c
13 n/c
14 n/c
15 n/c
16 n/c
17 n/c
18 n/c
19 n/c
20 DTR Data Terminal Ready
21 n/c
22 RI Ring Indicator
23 n/c
24 n/c
25 n/c

Direction seen from PC (TX/RX)


DO NOT connect SHIELD (1) with GND (7) !

Parallel (PC)
Back to Contents

(25p D-SUB female at PC)

(25p D-SUB male at parallel-cable)

http://www.trash.net/~luethi/microchip/datasheets/pinout/pinout.html (3 of 11)12/02/2008 17:12:37


Pinouts of various connectors

Pin Name Dir Description Register Bit in Register (7=MSB, 0=LSB)


1 STR Strobe BASE+2 0 (inverted)
2 D0 Data Bit 0 BASE 0
3 D1 Data Bit 1 BASE 1
4 D2 Data Bit 2 BASE 2
5 D3 Data Bit 3 BASE 3
6 D4 Data Bit 4 BASE 4
7 D5 Data Bit 5 BASE 5
8 D6 Data Bit 6 BASE 6
9 D7 Data Bit 7 BASE 7
10 ACK Acknowledge BASE+1 6
11 BUSY Busy BASE+1 7 (inverted)
12 PE Paper Empty BASE+1 5
13 SEL Select BASE+1 4
14 AUTFD Autofeed BASE+2 1 (inverted)
15 ERR Error BASE+1 3
16 INIT Initialize / Reset BASE+2 2
17 SEL IN Select Input BASE+2 3
18 GND Signal Ground
19 GND Signal Ground
20 GND Signal Ground
21 GND Signal Ground
22 GND Signal Ground
23 GND Signal Ground
24 GND Signal Ground
25 GND Signal Ground

Direction seen from PC (TX/RX)

http://www.trash.net/~luethi/microchip/datasheets/pinout/pinout.html (4 of 11)12/02/2008 17:12:37


Pinouts of various connectors

BASE means the base-address of the connection ( normally 378h for LPT1 and 278h for LPT2 ).
BASE+1 is known as status-register, BASE+2 as control-register.
Above address 0000:0408h there is a WORD-value for each installed parallel-port.

Centronics (Printer)
Back to Contents

(36p Centronics female at printer)

(36p Centronics male at printer cable)

Pin Name Dir Description


1 STR Strobe
2 D0 Data Bit 0
3 D1 Data Bit 1
4 D2 Data Bit 2
5 D3 Data Bit 3
6 D4 Data Bit 4
7 D5 Data Bit 5
8 D6 Data Bit 6
9 D7 Data Bit 7
10 ACK Acknowledge
11 BUSY Busy
12 PE Paper Empty
13 SEL Select

http://www.trash.net/~luethi/microchip/datasheets/pinout/pinout.html (5 of 11)12/02/2008 17:12:37


Pinouts of various connectors

14 AUTFD ? Autofeed
15 n/c
16 0V
17 CHASSIS GND
18 +5 V PULL UP +5 V DC (50 mA max)
19 GND Signal Ground
20 GND Signal Ground
21 GND Signal Ground
22 GND Signal Ground
23 GND Signal Ground
24 GND Signal Ground
25 GND Signal Ground
26 GND Signal Ground
27 GND Signal Ground
28 GND Signal Ground
29 GND Signal Ground
30 GNDRESET Reset Ground
31 RESET Reset
32 ERROR Low when offline
33 0V Signal Ground
34 n/c
35 +5 V +5 V DC
Select In (Taking low or high sets printer on line or off line
36 SEL IN
respectively)

Direction seen form Printer.

PC Gameport / MIDI

http://www.trash.net/~luethi/microchip/datasheets/pinout/pinout.html (6 of 11)12/02/2008 17:12:37


Pinouts of various connectors

Back to Contents

(15p D-SUB female at PC)

(15p D-SUB male at cable / joystick)

Pin Name Dir Description


1 +5V +5 VDC
2 B1 Button 1
3 X1 Joystick 1 - X
4 GND Ground
5 GND Ground
6 Y1 Joystick 1 - Y
7 B2 Button 2
8 +5V +5 VDC
9 +5V +5 VDC
10 B4 Button 4
11 X2 Joystick 2 - X
12 MIDI_TXD MIDI Transmit
13 Y2 Joystick 2 - Y
14 B3 Button 3
15 MIDI_RXD MIDI Receive

Direction seen from PC (TX/RX)

http://www.trash.net/~luethi/microchip/datasheets/pinout/pinout.html (7 of 11)12/02/2008 17:12:37


Pinouts of various connectors

Keyboard 5 Pin (PC)


Back to Contents

(5p DIN 41524 female at PC)

(5p DIN 41524 male at cable / keyboard)

Pin Name Description Comment


1 CLOCK Clock CLK/CTS, Open-collector
2 DATA Data RxD/TxD/RTS, Open-collector
3 n/c Not connected Reset on some very old keyboards.
4 GND Ground
5 VCC +5 VDC

Keyboard 6 Pin (PS/2)


Back to Contents

(6p Mini-DIN female (PS/2) at PC)

(6p Mini-DIN male at cable / keyboard)

Pin Name Dir Description


1 DATA Key Data

http://www.trash.net/~luethi/microchip/datasheets/pinout/pinout.html (8 of 11)12/02/2008 17:12:37


Pinouts of various connectors

2 n/c Not connected


3 GND Gnd
4 VCC Power , +5 VDC
5 CLK Clock
6 n/c Not connected

Direction seen from PC (TX/RX)

VGA
Back to Contents

(15p HIGH DENSITY D-SUB female at videocard)

(15p HIGH DENSITY D-SUB male at cable / monitor)

Pin Name Dir Description


1 RED Red Video (75 Ohm, 0.7 V p-p)
2 GREEN Green Video (75 Ohm, 0.7 V p-p)
3 BLUE Blue Video (75 Ohm, 0.7 V p-p)
4 ID2 Monitor ID Bit 2
5 GND Ground
6 RGND Red Ground
7 GGND Green Ground
8 BGND Blue Ground
9 KEY Key (No pin)

http://www.trash.net/~luethi/microchip/datasheets/pinout/pinout.html (9 of 11)12/02/2008 17:12:37


Pinouts of various connectors

10 SGND Sync Ground


11 ID0 Monitor ID Bit 0
12 ID1 or SDA Monitor ID Bit 1
13 HSYNC or CSYNC Horizontal Sync (or Composite Sync)
14 VSYNC Vertical Sync
15 ID3 or SCL Monitor ID Bit 3

Direction seen from PC / Videocard (TX/RX)

SCART
Back to Contents

(21p SCART female at TV / Video)

(21p SCART male at cable)

Pin Name Description Signal Level Impedanz


1 AOR Audio Out Right 0.5 V RMS <1k Ohm
2 AIR Audio In Right 0.5 V RMS >10k Ohm
3 AOL Audio Out Left + Mono 0.5 V RMS <1k Ohm
4 AGND Audio Ground
5 B GND RGB Blue Ground
6 AIL Audio In Left + Mono 0.5 V RMS >10k Ohm
7 B RGB Blue In 0.7 V 75 Ohm
8 SWTCH Audio/RGB switch / 16:9
9 G GND RGB Green Ground

http://www.trash.net/~luethi/microchip/datasheets/pinout/pinout.html (10 of 11)12/02/2008 17:12:37


Pinouts of various connectors

10 CLKOUT Data 2: Clockpulse Out (Unavailable ??)


11 G RGB Green In 0.7 V 75 Ohm
12 DATA Data 1: Data Out (Unavailable ??)
13 R GND RGB Red Ground
14 DATAGND Data Ground
15 R RGB Red In / Chrominance 0.7 V (Chrom.: 0.3 V burst) 75 Ohm
1-3 V = RGB, 0-0.4 V =
16 BLNK Blanking Signal 75 Ohm
Composite
17 VGND Composite Video Ground
18 BLNKGND Blanking Signal Ground
19 VOUT Composite Video Out 1V 75 Ohm
20 VIN Composite Video In / Luminance 1V 75 Ohm
21 SHIELD Ground/Shield (Chassis)

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/datasheets/pinout/pinout.html (11 of 11)12/02/2008 17:12:37


Microchip PIC

This website provides you helpful information about Microchip PIC 8 Bit
RISC microcontrollers. Several assembler source code listings are
available for non-commercial use. There are also tools for using your PC
for measuring or regulating electronic applications. I'm working on
several projects, e.g. a precision digital altimeter to use in my radio
controlled airplanes.
I have been working at the AMD Dresden Design Center, Germany on
RTL-based block- and system-level verification and performance analysis
for next-generation HyperTransport chipsets for AMDs x86-64 CPUs.
After having been abroad for nearly 3 years, I am now back in
Switzerland to pursue my Ph.D. thesis in the area of fourth generation
(4G) wireless communication with multi-user MIMO systems at the
Integrated Systems Laboratory of the Swiss Federal Institute of
Technology (ETH Zrich).
Webmaster
no abuse by spam
last updated
02.02.2008 This website is a member of the

since 1.7.1998

http://www.electronic-engineering.ch/microchip/index.html (1 of 2)12/02/2008 17:12:40


Microchip PIC

[ Previous 5 Sites | Previous | Next | Next 5 Sites | Random Site | List Sites ]

and the

[ Previous 5 Sites | Previous | Next | Next 5 Sites | Random Site | List Sites ]

and the

[ Previous 5 Sites | Previous | Next | Next 5 Sites | Random Site | List Sites ]

http://www.electronic-engineering.ch/microchip/index.html (2 of 2)12/02/2008 17:12:40


http://www.trash.net/~luethi/microchip/modules/source/m_bank.asm

;***************************************************************************
;
; Standard Macros for PIC 16XXX V2.00
; ====================================
;
; written by Peter Luethi, 08.01.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 20.08.2004
;
;***************************************************************************
#DEFINE M_BANK_ID dummy

BANK0 macro ; select register bank 0


bcf STATUS,RP0
bcf STATUS,RP1
endm

BANK1 macro ; select register bank 1


bsf STATUS,RP0
bcf STATUS,RP1
endm

BANK2 macro ; select register bank 2


bcf STATUS,RP0
bsf STATUS,RP1
endm

BANK3 macro ; select register bank 3


bsf STATUS,RP0
bsf STATUS,RP1
endm

;*** Conditional branching ***


; Macros to simplify 'IF THEN ELSE' queries
; Pre: valid w
; Post: compare w vs. m_val, branch to m_target or not

;branch on equal w and m_val


BEQ macro m_val, m_target
sublw m_val
bz m_target ; zero bit set, branch

http://www.trash.net/~luethi/microchip/modules/source/m_bank.asm (1 of 3)12/02/2008 17:12:41


http://www.trash.net/~luethi/microchip/modules/source/m_bank.asm

endm

;branch on 0 value in register m_file, jump to m_target


BZF macro m_file, m_target
tstf m_file ; check register (Z)
bz m_target ; zero bit set, branch
endm

;branch on not equal w and m_val


BNEQ macro m_val, m_target
sublw m_val
bnz m_target ; zero bit not set, branch
endm

;branch on not 0 value in register m_file, jump to m_target


BNZF macro m_file, m_target
tstf m_file ; check register (Z)
bnz m_target ; zero bit set, branch
endm

;branch on greater w than m_val


BRG macro m_val, m_target
sublw m_val ; result = m_val - w
bnc m_target ; no carry if result negative, branch
endm

;branch on equal or greater w than m_val


BREG macro m_val, m_target
sublw m_val-0x1 ; result = (m_val-1) - w
bnc m_target ; no carry if result negative, branch
endm

;branch on smaller w than m_val


BRS macro m_val, m_target
sublw m_val-0x1 ; result = (m_val-1) - w
bc m_target ; carry if result zero or positive, branch
endm

;branch on equal or smaller w than m_val


BRES macro m_val, m_target
sublw m_val ; result = m_val - w
bc m_target ; carry if result zero or positive, branch
endm

http://www.trash.net/~luethi/microchip/modules/source/m_bank.asm (2 of 3)12/02/2008 17:12:41


http://www.trash.net/~luethi/microchip/modules/source/m_bank.asm

;*** Microchip Tips'n Tricks ***


; swaps the contents of W and REG without using a second register
; from 'Microchip Tips'n Tricks'

SWAPWF macro REG


XORWF REG,F
XORWF REG,W
XORWF REG,F
endm

http://www.trash.net/~luethi/microchip/modules/source/m_bank.asm (3 of 3)12/02/2008 17:12:41


http://www.trash.net/~luethi/microchip/modules/source/m_wait.asm

;***************************************************************************
;
; Wait Routine for PIC 16XXX V1.02
; =================================
;
; written by Peter Luethi, 18.01.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 20.08.2004
;
; V1.02: In case of 'WAIT 0x00' or 'WAITX 0x00, 0x0F', the wait
; statement (macro) is ignored, no delay is executed
; (05.06.2004)
; V1.01: Correction of a severe mistake: Programming of the prescaler
; affected the entire OPTION_reg including PORTB pullups and
; INTEDGE configuration. Now only the least significant 6 bits
; of OPTION_reg are configured, the upper 2 bits are preserved.
; (16.02.2003)
; V1.00: Initial release (18.01.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16X84, 16F7X, 16F87X
; Clock: 4.00 MHz XT
; Throughput: 1 MIPS
;
;
; DESCRIPTION:
; ============
; Developed on PIC 16C84, but executeable on all PIC 16X84, 16C7X, etc.
;
; Routine performs a "busy" wait.
; Implemented standard delay (@ 4 MHz):

http://www.trash.net/~luethi/microchip/modules/source/m_wait.asm (1 of 3)12/02/2008 17:12:41


http://www.trash.net/~luethi/microchip/modules/source/m_wait.asm

; "WAIT 0x01" is equal to 1 Unit == 1.02 ms


; The assigned standard prescaler for TMR0 is "PRESCstd = b'00000001'"
; The prescaler is activated by clearing bit 3 of the OPTION register
;
; Prescalers:
; b'00000000' == 1:2 ==> 0.512 ms
; b'00000001' == 1:4 ==> 1.02 ms (standard)
; b'00000111' == 1:256 ==> 65.3 ms
; Waittime = WCYCLE (= timeconst) * prescaler
;
; Call of implemented procedures with:
; "WAIT xxx" ; standard
; "WAITX xxx, yyy" ; extended with specific prescaler
; ; WAITX d'16',d'7' = 1.045 s @ 4 MHz
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; "CONSTANT BASE = 0x0C" Base address of user file registers
;
;
; REQUIRED MEMORY:
; ================
; 1 register: @ BASE+0
; needs itself 1 stack level
;
;***************************************************************************
#DEFINE M_WAIT_ID dummy

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF

;***** CONSTANT DECLARATION *****

CONSTANT PRESCstd = b'00000001' ; standard prescaler for TMR0

;***** REGISTER DECLARATION *****

WCYCLE set BASE+d'0' ; wait cycle counter

http://www.trash.net/~luethi/microchip/modules/source/m_wait.asm (2 of 3)12/02/2008 17:12:41


http://www.trash.net/~luethi/microchip/modules/source/m_wait.asm

;***** MACROS *****

WAIT macro timeconst_1


IF (timeconst_1 != 0)
movlw timeconst_1
call WAITstd
ENDIF
endm

WAITX macro timeconst_2, prescaler


IF (timeconst_2 != 0)
movlw timeconst_2
call _Xsetup
movlw prescaler ; assign prescaler for TMR0
call _Xwait
ENDIF
endm

;***** SUBROUTINES *****

_Xsetup movwf WCYCLE ; assign wait cycle duration


clrf TMR0
BANK1
movlw b'11000000' ; set up mask
andwf OPTION_REG,f ; clear corresponding bits
RETURN

WAITstd movwf WCYCLE ; assign wait cycle duration


clrf TMR0
BANK1
movlw b'11000000' ; set up mask
andwf OPTION_REG,f ; clear corresponding bits
movlw PRESCstd ; load standard prescaler
_Xwait iorwf OPTION_REG,f ; assign prescaler to TMR0
BANK0

_WAITa bcf INTCON,T0IF ; clears TMR0 overflow flag


_WAITb btfss INTCON,T0IF ; checks TMR0 overflow flag, skip if set
goto _WAITb ; this is the wait-loop
decfsz WCYCLE,f ; repeats the loop according to the
goto _WAITa ; assigned wait cycles
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_wait.asm (3 of 3)12/02/2008 17:12:41


http://www.trash.net/~luethi/microchip/modules/source/m_beep.asm

;***************************************************************************
;
; Beep Routine for PIC 16XXX V1.00
; =================================
;
; written by Peter Luethi, 18.01.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 16.02.2003
;
; V1.00: Initial release (18.01.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16XXX
; Clock: 4.00 MHz XT
; Throughput: 1 MIPS
; Required Hardware: Piezo beeper with decoupling capacitor
;
;
; DESCRIPTION:
; ============
; Developed on PIC 16C84, but executeable on all PIC 16X84, 16C7X, ...
;
; Call of implemented procedures with:
; "BEEPinit" initialization to set output port
; "BEEP xxx yyy" normal usage
; "BEEPX xxx yyy zzz" extended usage
; xxx is frequency-related
; yyy is duration according to PRESCbeeb, TMR0
; zzz is user-defined TMR0 prescaler setting
;
; i.e. 3-Tone-Melody: BEEP 0xFF, 0x02

http://www.trash.net/~luethi/microchip/modules/source/m_beep.asm (1 of 4)12/02/2008 17:12:42


http://www.trash.net/~luethi/microchip/modules/source/m_beep.asm

; BEEP 0x90, 0x05


; BEEP 0xC0, 0x03
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; CONSTANT BASE = 0x0C Base address of user file registers
; #define BEEPport PORTA,0x00
; #define BEEPtris TRISA,0x00
;
;
; REQUIRED MEMORY:
; ================
; 3 registers: @ BASE+0 - BASE+2
;
;***************************************************************************
#DEFINE M_BEEP_ID dummy

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF BEEPport
ERROR "Define BEEPport in MAIN PROGRAM"
ENDIF
IFNDEF BEEPtris
ERROR "Define BEEPtris in MAIN PROGRAM"
ENDIF

;***** PARAMETERIZATION *****

IFNDEF PRESCbeep
#define PRESCbeep b'00000111' ; 65,3 ms per Cycle
ENDIF

;***** REGISTER DECLARATION *****

TEMP1 set BASE ; universal temporary register


TEMP2 set BASE+1

http://www.trash.net/~luethi/microchip/modules/source/m_beep.asm (2 of 4)12/02/2008 17:12:42


http://www.trash.net/~luethi/microchip/modules/source/m_beep.asm

TEMP3 set BASE+2

;***** MACROS *****

BEEP macro freq, duration


movlw freq ; assign frequency
movwf TEMP1
movlw duration ; assign duration
call BEEPsub
endm

BEEPX macro freq, duration, prescaler


movlw freq ; assign frequency
movwf TEMP1
movlw duration ; assign duration
movwf TEMP2
clrf TMR0
BANK1
movlw prescaler ; assign prescaler for TMR0
call BEEPsub2
endm

BEEPinit macro
bcf BEEPport
BANK1
bcf BEEPtris
BANK0
endm

;***** SUBROUTINES *****

BEEPsub movwf TEMP2 ; assign duration


clrf TMR0
BANK1
movlw PRESCbeep ; assign prescaler for TMR0
BEEPsub2 movwf OPTION_REG ; assign W to OPTION
BANK0
BEEPa bcf INTCON,T0IF ; clear TMR0 Overflow Flag
BEEPb bsf BEEPport
call B_Wait
bcf BEEPport
call B_Wait
btfss INTCON,T0IF ; check TMR0 Overflow Flag, skip if set

http://www.trash.net/~luethi/microchip/modules/source/m_beep.asm (3 of 4)12/02/2008 17:12:42


http://www.trash.net/~luethi/microchip/modules/source/m_beep.asm

goto BEEPb
decfsz TEMP2,1 ; repeat subroutine
goto BEEPa
RETURN

B_Wait movfw TEMP1


movwf TEMP3
B_Waita decfsz TEMP3,1
goto B_Waita
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_beep.asm (4 of 4)12/02/2008 17:12:42


Microchip PIC microcontroller projects

PIC Microcontroller Projects


For Non-Commercial Use Only

I would appreciate to be credited within your project, if you use any of the source code below. If you have an interesting
project going on, I'll be glad about feedback.

The software below comes with no guarantee or warranty except for my good intentions. Further the use of this code implies
that the user has a fundamental understanding of electronics and its risks. I'm not responsible for any harm or damage,
caused by inproper use of any of the code below.
Any commercial use of parts or all of this code requires the permission of the author.

"Design and test of electronic circuits are 1% inspiration and 99% perspiration."

(Freely derived from Thomas Alva Edison's famous phrase: "Genius is 1% inspiration and 99% perspiration.")

Table of Contents [Toc]

PIC Projects
Precision Digital Altimeter
AT Keyboard Interface V1.xx
AT Keyboard Interface V2.xx
AT Keyboard Interface V3.xx
AT Keyboard Box V2.xx
AT Keyboard Interface with Morse Code Support V1.xx
AT Keyboard Interface with Morse Code Support V2.xx

PIC Test Routines


RS232 Test Programs
Simple RS232 Interface
RS232 Communication Test Routine with LCD (1)
RS232 Communication Test Routine with LCD (2)
Dual RS232 Communication Routine with LCD
RS232 Scope V1.02 Test Interface
LCD Test Programs
LCDx Test Routine
Binary to Decimal Test Routine
Debugging Routine / Bitstream Visualization
AT Keyboard Test Programs
AT Keyboard Scan Code Debug Routine
Numeric Foil-Keypad Calibration Routine
ADC Test Programs
NSC ADC12130 Test Interface
DCF77 Test Programs
DCF77 Test Interface

http://www.trash.net/~luethi/microchip/projects/projects.html (1 of 6)12/02/2008 17:12:43


Microchip PIC microcontroller projects

PIC Projects [Toc] [Top]

Precision Digital Altimeter [Toc] [Top]


MPXS4100 absolute pressure sensor, PIC16F84 and wireless transmitter & receiver
Altimeter for my radio controlled modelplanes, but can also be used for hiking, climbing, mountaineering and other outdoor
activities. Has an excellent resolution of 1 meter and a range of 4100 meters. I still work on it.

AT Keyboard Interface V1.04 [Toc] [Top]


AT keyboard interface with RS232 link using PIC16F84
AT keyboard to RS232 interface for the personal computer or RS232 compatible devices. This routine converts AT
keyboard scan patterns to ASCII characters and sends them afterwards to the target device by using the RS232 transmission
protocol. Support of english (QWERTY) and modified swiss-german (QWERTZ) 'codepages'. There is no visual interface at
the terminal like a LCD display. Unidirectional data flow: keyboard to RS232 target device.

AT Keyboard Interface V2.04 [Toc] [Top]


RS232 terminal with LCD display using PIC16F84
AT keyboard to RS232 interface for the personal computer or RS232 compatible devices. This routine converts AT
keyboard scan patterns to ASCII characters and transmits them afterwards to the target device by using the RS232
transmission protocol. Support of english (QWERTY) and modified swiss-german (QWERTZ) 'codepages'. This
implementation features a LCD display as visual interface, but only for transmitted characters typed on the local keyboard
(unidirectional data flow). RS232 data transmission is carried out using a software routine. No reception of characters sent
from RS232 target device, because no RS232 modules with preemptive data reception available yet.

http://www.trash.net/~luethi/microchip/projects/projects.html (2 of 6)12/02/2008 17:12:43


Microchip PIC microcontroller projects

AT Keyboard Interface V3.05 [Toc] [Top]


Fully operating RS232 terminal with LCD display using PIC 16C74A
AT keyboard to RS232 interface for the personal computer or RS232 compatible devices. This routine converts AT
keyboard scan patterns to ASCII characters and transmits them afterwards to the target device by using the RS232
transmission protocol. Support of english (QWERTY) and modified swiss-german (QWERTZ) 'codepages'. This
microcontroller application features a dot matrix LCD display, and makes best use of the microcontroller-internal USART, i.
e. completely hardware-based RS232 data transmission and reception. Reception of external serial data is done using an
interrupt-based acquisition scheme. Visualization of received data on the first line, user-entered data on the second line of
the dot matrix LCD display. This application is best used with a 2 line by 20 or 40 characters LCD display.

AT Keyboard Box V2.05 [Toc] [Top]


Fully operating RS232 terminal with LCD display and numeric foil-keypad using PIC16F77
AT keyboard to RS232 interface with completely bi-directional communication capabilities. Multiple input devices are
attached, such as an AT keyboard and a small numeric foil-keypad. The application features a dot matrix LCD display to
visualize the data received from the RS232 client on the first line, and the characters typed on the locally attached keyboard
on the second line. There is also a piezo-beeper for acoustic feedback. This program converts AT keyboard scan patterns to
ASCII characters and transmits them afterwards to the target device by using the RS232 transmission protocol. RS232
communication is carried out by the microcontroller-internal USART, i.e. completely hardware-based RS232 data
transmission and reception.
Dynamic configuration of RS232 baud rate setting at start-up (user-customization with 1200 baud - 115200 baud), with
12 seconds inactivity time-out. In case the time-out applies, the user-customization process terminates with the current
setting. Default setting after power-up is 9600 baud.
Support of english (QWERTY) and modified swiss-german (QWERTZ) 'codepages'. This application is best used with a 2
line by 20 or 40 characters LCD display.

AT Keyboard Interface with Morse Code Support V1.02 [Toc] [Top]


AT keyboard interface with RS232 link and Morse code PWM output using PIC16F84
Technical data as AT Keyboard Interface V1.03 above. Additional pulse-width modulated (PWM) Morse code output.
Further parameterizable acoustic Morse code feedback through Piezo beeper.

AT Keyboard Interface with Morse Code Support V2.02 [Toc] [Top]


AT keyboard interface with LCD display, RS232 link and Morse code PWM output using PIC16F84
Technical data basically as AT Keyboard Interface V2.03 above (except direct Ctrl-Hex and Alt-Dec entry). Additional pulse-
width modulated (PWM) Morse code output. Further parameterizable acoustic Morse code feedback through Piezo beeper.

PIC Test Routines [Toc] [Top]

RS232 Test Programs [Toc] [Top]

Simple RS232 Interface [Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/projects.html (3 of 6)12/02/2008 17:12:43


Microchip PIC microcontroller projects

Shows briefly the use of the various RS232 modules (m_rs048, m_rs096, m_rs192). It is more or less the same as the RS232
Communication Test Routine (1), without LCD display. The controller sends approximately every 10 seconds a stand-by
statement to the terminal screen and echoes to every character the device gets. RS232 reception is based on PortB0 interrupt.

RS232 Communication Test Routine with LCD (1) [Toc] [Top]


Fully software controlled reception & transmission on interrupt featured PICs
Complete RS232 communication routine for PIC16F84, which allows to display sent characters from the PC on a dot matrix
LCD Display and send an acknowledge back to the PC. RS232 reception is based on PortB0 interrupt.
Shows the implementation and function of the modules m_rs232.asm, m_wait.asm, m_lcd.asm and m_lcdv08.asm on the
PIC16F84.

RS232 Communication Test Routine with LCD (2) [Toc] [Top]


Fully hardware controlled reception & transmission on PIC16F77 (PIC16C74A)
Complete RS232 communication routine using hardware USART of PIC16F7x, which allows to display sent characters from
the PC on a dot matrix LCD Display and sends an acknowledge back to the PC.
Shows the implementation and function of the modules m_wait.asm, m_lcd.asm and m_lcdv08.asm on the PIC16F77
(PIC16C74A).

Dual RS232 Communication Routine with LCD [Toc] [Top]


Dual RS232 reception & transmission on PIC16F77
Microcontroller terminal featuring two independent RS232 interfaces: One RS232 link uses the hardware USART and
interrupts, the other one is software-based using only interrupts on PortB0. Display of received ASCII characters and
corresponding decimal values on LCD. ASCII values entered on one terminal window are transmitted by RS232 to the
controller, displayed on the LCD, and further transmitted to the other terminal window.
Shows the simultaneous use of both hardware- and software-based RS232 communication on the PIC16F77.

RS232 Scope V1.02 Test Interface [Toc] [Top]


This is the test routine for the serial 16 bit data capture from an Excel 97 worksheet.
It shows the implementation of a 16 bit table read in both directions (top-down and bottom-up) to save space. The Excel
worksheet visualizes the received data using graphs.
This test program implements one building block of the digital altimeter.

LCD Test Programs [Toc] [Top]

LCDx Test Routine [Toc] [Top]


Demonstrates the implementation of self-defined characters on a dot matrix LCD display with the module m_lcdx.asm.

http://www.trash.net/~luethi/microchip/projects/projects.html (4 of 6)12/02/2008 17:12:43


Microchip PIC microcontroller projects

Binary to Decimal Test Routine [Toc] [Top]


A counter from 0 to 65'535 on a dot matrix LCD display demonstrates the function of the m_lcdv16.asm module on the
PIC16C84.

Debugging Routine / Bitstream Visualization [Toc] [Top]


Demonstrates the 16 bit binary debugging routine with the module m_lcdb16.asm. Requires a dot matrix LCD display.
I've written it to debug the SSP (Synchronous Serial Port) interface to the NSC ADC12130 for my altimeter.

AT Keyboard Test Programs [Toc] [Top]

AT Keyboard Scan Code Debug Routine [Toc] [Top]


RS232 based scan pattern debug routine for PIC16F84
AT keyboard test routine to visualize and verify scan patterns sent by the keyboard. The scan patterns are fetched by the
controller and afterwards sent to the RS232 target device, in this case the PC and an Excel 97 worksheet programmed with
Visual Basic to visualize the scan patterns.

Numeric Foil-Keypad Calibration Routine [Toc] [Top]


RS232 based debug and calibration routine for PIC16F77
AT keyboard test routine to visualize and verify the analog values acquired by the PIC microcontroller to convert the
numeric foil-keypad entries to decimal values. The setup is basically the same as the AT Keyboard Box V2.05 above.

ADC Test Programs [Toc] [Top]

NSC ADC12130 Test Interface [Toc] [Top]


Serial interface to 12 bit A/D Converter
Shows the implementation of the synchronous serial connection to the A/D Converter. Auto-Calibration, Auto-Zero and
Status Read are made as initial procedures, afterwards the unsigned 12 bit data will be fetched and displayed on the LCD
display in binary format.

DCF77 Test Programs [Toc] [Top]

DCF77 Test Interface [Toc] [Top]


Software-based PWM decoding on PIC16F84 of DCF77 time information.
Incorporates standard DCF77 RF to PWM decoder unit based on Temic 4224. Visualization and translation of DCF77 data
is done using an Excel 97 work sheet with the ability to acquire and log RS232 data.

Last updated: 17.04.2006

[Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/projects.html (5 of 6)12/02/2008 17:12:43


Microchip PIC microcontroller projects

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/projects.html (6 of 6)12/02/2008 17:12:43


1 2 3 4

LCD connection for: LCD connection for:


VDD VDD m_lcde.asm (std. char set, delay-based) m_lcd.asm (std. char set, delay-based)
VSS VSS m_lcdebf.asm (std. char set, busy-flag based) m_lcdx.asm (ext. char set, delay-based)
D m_lcdexbf.asm (ext. char set, busy-flag based) m_lcd_bf.asm (std. char set, busy-flag based) D
m_lcdxbf.asm (ext. char set, busy-flag based)

CON1_3 CON2_3
LCD_CON14 LCD_CON14
Dot Matrix LCD Display
(HD44780 compatible)
VDD

Contrast

Contrast
VDD

VDD
R1_3

R/W

R/W
VSS

VSS
RS

RS
D0
D1
D2
D3
D4
D5
D6
D7

D0
D1
D2
D3
D4
D5
D6
D7
10k

E
C C

1
2
3

4
5
6

7
8
9

1
2
3

4
5
6

7
8
9
10
11
12
13
14

10
11
12
13
14
VSS VSS
1

VDD VDD RD4


POT1_3
Contrast Contrast
RD3
RB1 RA3
2
Contrast
RD2
RB2 RA2
5k RD1
RB3 RA1
3

Example for customized connectivity,


RD5
RA0
B e.g. PortA & PortB on PIC16F84 or similar, B
or PortA, PortB, PortC, PortD on PIC16F77, PIC16F877 or similar RD6
VSS Separate control lines
RB[3..1]
RB[7..0] RD7

Data lines on low nibble


RA[3..0]
RA[5..0]

Data & control lines on


RD[7..1]
RD[7..0]
a single port
Title
Example connectivity for a single port,
e.g. PortB on PIC16F84 or similar, HD44780 Dot Matrix LCD Connectivity
A or PortB, PortC, PortD on PIC16F77, PIC16F877 or similar A
Written by Date
Peter Lthi 5-Jun-2005
www.electronic-engineering.ch Revision Page
Urdorf, Switzerland 1.00 1 of 1

1 2 3 4
http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm

;***************************************************************************
;
; LCD INTERFACE V2.06 for PIC 16XXX
; =================================
;
; written by Peter Luethi, 10.01.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 26.12.2004
;
; V2.06: Added new parameters: (26.12.2004)
; - LCDLINENUM: (default: 0x2) # of LCD lines (affects LCDL2/3)
; - LCDTYPE: type of LCD/controller:
; - 0x0: (default) standard LCD (w/ HD44780)
; - 0x1: EA DIP204-4 (w/ KS0073, white chars, blue bg)
; V2.05: Changed LCDinit and constants (24.06.2004)
; V2.04: Clean-up and general improvements, added
; parameter LCDSPEED (10.04.2004)
; V2.03: Improved masking of LCD data outputs,
; reduced code size, added parameter LCDWAIT
; (16.02.2003)
; V2.02: LCDinit coded as macro instead of procedure
; V2.01: LCDinit with "andwf" instead of "movwf"
; V2.00: With constant timing delays (No busy flag check)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16X84, 16F7X, 16F87X
; Clock: 4.00 MHz XT - 10.00 MHz HS Mode (tested)
; Throughput: 1 - 2.5 MIPS
; LCD Transmission Mode: 4 bit on high nibble of LCD port
; (MSB D7-D4)
; LCD Connections: 7 wires (4 data, 3 command),

http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm (1 of 9)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm

; LCD data on low nibble of any port,


; LCD command on any port bits
; Total: 10 wires
; (4 data, 3 command, 1 Vdd, 1 GND, 1 contrast)
;
;
; DESCRIPTION:
; ============
; Developed on PIC 16F84, but executeable on all PIC 16XXX.
; Program handles all aspects of setup and display on a dot matrix LCD
; display. Routines are provided to allow display of characters,
; display shifting and clearing, cursor setup, cursor positioning and
; line change.
;
; Program calls module m_wait.asm with implemented standard delay:
; "WAIT 0x01" is equal to 1 Unit == 1.04 ms
; The assigned standard prescaler for TMR0 is "PRESCstd = b'00000001'"
;
; Call of implemented procedures with:
; "LCDinit" (macro)
; "LCDchar 'c'" display ascii character
; "LCDw" display char in working register
; "LCDcmd xxx" e.g. "LCDcmd LCDCLR"
; "LCD_DDAdr xxx" set cursor to explicit address
; --> REFER TO LCD DOCUMENTATION
; "LCDline x" set cursor to the beginning of line 1/2
;
; To display decimal-values, please include the following binary to
; decimal conversion modules:
; for 8 Bit: m_lcdv08.asm
; for 16 Bit: m_lcdv16.asm
;
;
; DEFAULT TIMING PARAMETERS:
; ==========================
; CONSTANT LCDLINENUM = 0x02 ; LCD display has two lines (e.g. 2x20)
; CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
; CONSTANT LCDSPEED = 0x01 ; affecting LCD_EN 'clock': high speed PIC clock
; CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
; CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
;
; To maintain proper timing (setup time, wait time, LCD initialization),
; adjust the parameter LCDWAIT as follows:

http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm (2 of 9)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm

; if Tosc <= 5 MHz: LCDWAIT = 0x01


; else LCDWAIT = floor(0.25 * clock frequency[MHz])
; To comply with manufacturer specifications (Enable High Time >= 450 ns),
; add a "nop" to the procedure LCDclk, if using this module with clock
; rates higher than 9 MHz. Therefore, define in your main program:
; CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
; CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; CONSTANT BASE = 0x0C Base address of user file registers
; LCDtris equ TRISB
; LCDport equ PORTB
;
; LCD port connections: B0: not used, still available for INTB
; B1: D4
; B2: D5
; B3: D6
; B4: D7
; B5: E
; B6: R/W
; B7: RS
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+2 - BASE+3
;
;***************************************************************************
#DEFINE M_LCD_ID dummy

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF

;***** CONSTANT DECLARATION *****

IFNDEF LCDLINENUM ; use default value, if unspecified

http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm (3 of 9)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm

CONSTANT LCDLINENUM = 0x02 ; by default, 2 lines


ENDIF
IFNDEF LCDTYPE ; use default value, if unspecified
CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
;CONSTANT LCDTYPE = 0x01 ; EADIP204-4 (w/ KS0073)
ENDIF
IFNDEF LCDSPEED ; use default value, if unspecified
;CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
ENDIF
IFNDEF LCDWAIT ; use default value, if unspecified
CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
ENDIF
IFNDEF LCDCLRWAIT ; use default value, if unspecified
CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF LCDtris
ERROR "Declare LCDtris in MAIN PROGRAM"
ENDIF
IFNDEF LCDport
ERROR "Declare LCDport in MAIN PROGRAM"
ENDIF

; LCD data ports D4 - D7 == 0x01 - 0x04


#define LCD_EN LCDport,0x05 ; Enable Output / "CLK"
#define LCD_RW LCDport,0x06 ; Read/Write
#define LCD_RS LCDport,0x07 ; Register Select

;***** REGISTER DECLARATION *****

IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

LCDbuf set BASE+d'2' ; LCD data buffer


LCDtemp set BASE+d'3' ; LCD temporary register

;***** LCD COMMANDS *****

;*** Standard LCD COMMANDS for INIT *** ( HI-NIBBLE only )

http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm (4 of 9)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm

; for 4 bit mode: send only one nibble as high-nibble [DB7:DB4]


CONSTANT LCDEM8 = b'0011' ; entry mode set: 8 bit mode, 2 lines
CONSTANT LCDEM4 = b'0010' ; entry mode set: 4 bit mode, 2 lines
CONSTANT LCDDZ = b'1000' ; set Display Data Ram Address to zero

;*** Standard LCD COMMANDS *** ( HI- / LO-NIBBLE )


; USE THESE COMMANDS BELOW AS FOLLOW: "LCDcmd LCDCLR"
CONSTANT LCDCLR = b'00000001' ; clear display: resets address counter & cursor
CONSTANT LCDCH = b'00000010' ; cursor home
CONSTANT LCDCR = b'00000110' ; entry mode set: cursor moves right, display auto-shift off
CONSTANT LCDCL = b'00000100' ; entry mode set: cursor moves left, display auto-shift off
CONSTANT LCDCONT = b'00001100' ; display control: display on, cursor off, blinking off
CONSTANT LCDMCL = b'00010000' ; cursor/disp control: move cursor left
CONSTANT LCDMCR = b'00010100' ; cursor/disp control: move cursor right
CONSTANT LCDSL = b'00011000' ; cursor/disp control: shift display content left
CONSTANT LCDSR = b'00011100' ; cursor/disp control: shift display content right
CONSTANT LCD2L = b'00101000' ; function set: 4 bit mode, 2 lines, 5x7 dots
IF (LCDLINENUM == 0x2)
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (2xXX LCD)
CONSTANT LCDL2 = b'11000000' ; DDRAM address: 0x40, selects line 2 (2xXX LCD)
CONSTANT LCDL3 = b'10010100' ; (DDRAM address: 0x14, fallback)
CONSTANT LCDL4 = b'11010100' ; (DDRAM address: 0x54, fallback)
ELSE
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (4xXX LCD)
CONSTANT LCDL2 = b'10010100' ; DDRAM address: 0x14, selects line 2 (4xXX LCD)
CONSTANT LCDL3 = b'11000000' ; DDRAM address: 0x40, selects line 3 (4xXX LCD)
CONSTANT LCDL4 = b'11010100' ; DDRAM address: 0x54, selects line 4 (4xXX LCD)
ENDIF
; special configuration for EA DIP204-4
CONSTANT LCDEXT = b'00001001' ; extended function set EA DIP204-4
CONSTANT LCD2L_A = b'00101100' ; enter ext. function set: 4 bit mode, 2 lines, 5x7 dots
CONSTANT LCD2L_B = b'00101000' ; exit ext. function set: 4 bit mode, 2 lines, 5x7 dots

;***** MACROS *****

LCDinit macro
BANK1
movlw b'0000001' ; set to output
andwf LCDtris,f
BANK0
bcf LCD_EN ; clear LCD clock line
bcf LCD_RW ; set write direction
bcf LCD_RS ; clear command/data line

http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm (5 of 9)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm

clrLCDport ; reset LCD data lines


WAIT 4*LCDWAIT ; >= 4 ms @ 4 MHz

; LCD INITIALIZATION STARTS HERE


; start in 8 bit mode
movlw LCDEM8 ; send b'0011' on [DB7:DB4]
call LCDxmit ; start in 8 bit mode
call LCDclk ; That's while:
WAIT LCDWAIT ; On POWER UP, the LCD will initialize itself,
; but after a RESET of the microcontroller without
; POWER OFF, the 8 bit function mode will reboot
; the LCD to 4 bit mode safely.

movlw LCDDZ ; set DDRAM to zero


call LCDxmit
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

movlw LCDEM4 ; send b'0010' on [DB7:DB4]


call LCDxmit ; change to 4 bit mode
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

; now in 4 bit mode, sending two nibbles


IF LCDTYPE == 0x00
LCDcmd LCD2L ; function set: 4 bit mode, 2 lines, 5x7 dots
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
IF LCDTYPE == 0x01
; for LCD EA DIP204-4 (white chars, blue backlight)
LCDcmd LCD2L_A ; switch on extended function set
LCDcmd LCDEXT ; 4 lines
LCDcmd LCD2L_B ; switch off extended function set
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
ERROR "Unsupported parameter"
ENDIF
ENDIF
endm

http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm (6 of 9)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm

LCDchar macro LCDarg ; write ASCII argument to LCD


movlw LCDarg
call LCDdata
endm

LCDw macro ; write content of w to LCD


call LCDdata
endm

LCDcmd macro LCDcommand ; write command to LCD


movlw LCDcommand
call LCDcomd
endm

LCDline macro line_num


IF (line_num == 1)
LCDcmd LCDL1 ; first line
ELSE
IF (line_num == 2)
LCDcmd LCDL2 ; second line
ELSE
IF (line_num == 3)
LCDcmd LCDL3 ; third line
ELSE
IF (line_num == 4)
LCDcmd LCDL4 ; fourth line
ELSE
ERROR "Wrong line number specified in LCDline"
ENDIF
ENDIF
ENDIF
ENDIF
endm

LCD_DDAdr macro DDRamAddress


Local value = DDRamAddress | b'10000000' ; mask command
IF (DDRamAddress > 0x67)
ERROR "Wrong DD-RAM-Address specified in LCD_DDAdr"
ELSE
movlw value
call LCDcomd
ENDIF

http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm (7 of 9)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm

endm

LCD_CGAdr macro CGRamAddress


Local value = CGRamAddress | b'01000000' ; mask command
IF (CGRamAddress > b'00111111')
ERROR "Wrong CG-RAM-Address specified in LCD_CGAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

clrLCDport macro ; clear/reset LCD data lines


movlw b'11100001' ; get mask
andwf LCDport,f ; clear data lines only
endm

;***** SUBROUTINES *****

; transmit only lower nibble of w


LCDxmit movwf LCDbuf ; store command/data nibble
; first, clear LCD data lines
clrLCDport
; second, move data out to LCD data lines
rlf LCDbuf,w ; get data
andlw b'00011110' ; extract only valid part
iorwf LCDport,f ; put to LCD data lines
RETURN

; transmit command to LCD


LCDcomd bcf LCD_RS ; select command registers
goto _LCD_wr

; transmit data to LCD


LCDdata bsf LCD_RS ; select data registers
_LCD_wr bcf LCD_RW ; set write direction
movwf LCDtemp ; store command/data to send
; send hi-nibble
movfw LCDtemp ; get data
swapf LCDtemp,w ; swap hi- and lo-nibble, store in w
call LCDxmit ; transmit nibble
call LCDclk
; send lo-nibble

http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm (8 of 9)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm

movfw LCDtemp ; get data


call LCDxmit ; transmit nibble
call LCDclk
; reset LCD controls
clrLCDport ; reset LCD data lines
bcf LCD_RS ; reset command/data register
;bcf LCD_RW ; reset to write direction
RETURN

; clocks LCD data/command


LCDclk WAIT LCDWAIT
bsf LCD_EN ; set LCD enable
; insert LCDSPEED x nops to comply with manufacturer
; specifications for clock rates above 9 MHz
VARIABLE CNT_V ; declare intermediate variable
CNT_V = LCDSPEED ; assign pre-defined constant
WHILE (CNT_V > 0x0) ; perform while loop to insert 'nops'
nop ; insert 'nop'
CNT_V -= 1 ; decrement
ENDW
bcf LCD_EN
WAIT LCDWAIT ; clocks LCD data/command
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcd.asm (9 of 9)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm

;***************************************************************************
;
; LCD INTERFACE V2.26 for PIC 16XXX
; =================================
;
; written by Peter Luethi, 15.05.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 26.12.2004
;
; V2.26: Added new parameters: (26.12.2004)
; - LCDLINENUM: (default: 0x2) # of LCD lines (affects LCDL2/3)
; - LCDTYPE: type of LCD/controller:
; - 0x0: (default) standard LCD (w/ HD44780)
; - 0x1: EA DIP204-4 (w/ KS0073, white chars, blue bg)
; V2.25: Changed LCDinit and constants (24.06.2004)
; V2.24: Clean-up and general improvements, added
; parameter LCDSPEED (10.04.2004)
; V2.23: Improved masking of LCD data outputs,
; reduced code size, added parameter LCDWAIT
; (16.02.2003)
; V2.22: LCDinit coded as macro instead of procedure
; V2.21: LCDinit with "andwf" instead of "movwf"
; V2.20: Initial release (15.5.1999)
; With constant timing delays (No busy flag check)
; Ability to define your own characters for the LCD
; (=> see macro LCDspecialChars)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16X84, 16F7X, 16F87X
; Clock: 4.00 MHz - 10.00 MHz XT (tested)
; Throughput: 1 - 2.5 MIPS

http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm (1 of 10)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm

; LCD Transmission Mode: 4 bit on high nibble of LCD port


; (MSB D7-D4)
; LCD Connections: 7 wires on any portX (4 data, 3 command)
; X0: unused, X1-X7: D4-D7, E, R/W, RS
; Total: 10 wires
; (4 data, 3 command, 1 Vdd, 1 GND, 1 contrast)
;
;
; ADDITIONAL PROGRAM CODE:
; ========================
; macro LCD_CGAdr
; macro LCDspecialChars
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16C84 @ 4 MHz, but executeable on all PIC 16XXX.
; Program handles all aspects of setup and display on a dot matrix LCD
; display. Routines are provided to allow display of characters,
; display shifting and clearing, cursor setup, cursor positioning and
; line change.
; NEW: Allows to define your own characters (5x7 dots)
;
; Program calls module m_wait.asm with implemented standard delay:
; "WAIT 0x01" is equal to 1 Unit == 1.04 ms
; The assigned standard prescaler for TMR0 is "PRESCstd = b'00000001'"
;
; Call of implemented procedures with:
; "LCDinit" (macro)
; "LCDchar 'c'" display ascii character
; "LCDw" display char in working register
; "LCDcmd xxx"
; "LCD_DDAdr xxx" set cursor to explicit address
; --> REFER TO LCD DOCUMENTATION
; "LCDline x" set cursor to the beginning of line 1/2
;
; To display decimal-values, please include the following binary to
; decimal conversion modules:
; for 8 Bit: m_lcdv08.asm
; for 16 Bit: m_lcdv16.asm
;
;
; DEFAULT TIMING PARAMETERS:

http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm (2 of 10)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm

; ==========================
; CONSTANT LCDLINENUM = 0x02 ; LCD display has two lines (e.g. 2x20)
; CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
; CONSTANT LCDSPEED = 0x01 ; affecting LCD_EN 'clock': high speed PIC clock
; CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
; CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
;
; To maintain proper timing (setup time, wait time, LCD initialization),
; adjust the parameter LCDWAIT as follows:
; if Tosc <= 5 MHz: LCDWAIT = 0x01
; else LCDWAIT = floor(0.25 * clock frequency[MHz])
; To comply with manufacturer specifications (Enable High Time >= 450 ns),
; add a "nop" to the procedure LCDclk, if using this module with clock
; rates higher than 9 MHz. Therefore, define in your main program:
; CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
; CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; CONSTANT BASE = 0x0C Base address of user file registers
; LCDtris equ TRISB
; LCDport equ PORTB
;
; LCD port connections: B0: not used, still available for INTB
; B1: D4
; B2: D5
; B3: D6
; B4: D7
; B5: E
; B6: R/W
; B7: RS
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+2, BASE+3
;
;***************************************************************************
#DEFINE M_LCD_ID dummy

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID

http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm (3 of 10)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm

ERROR "Missing include file: m_bank.asm"


ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF

;***** CONSTANT DECLARATION *****

IFNDEF LCDLINENUM ; use default value, if unspecified


CONSTANT LCDLINENUM = 0x02 ; by default, 2 lines
ENDIF
IFNDEF LCDTYPE ; use default value, if unspecified
CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
;CONSTANT LCDTYPE = 0x01 ; EADIP204-4 (w/ KS0073)
ENDIF
IFNDEF LCDSPEED ; use default value, if unspecified
;CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
ENDIF
IFNDEF LCDWAIT ; use default value, if unspecified
CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
ENDIF
IFNDEF LCDCLRWAIT ; use default value, if unspecified
CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF LCDtris
ERROR "Declare LCDtris in MAIN PROGRAM"
ENDIF
IFNDEF LCDport
ERROR "Declare LCDport in MAIN PROGRAM"
ENDIF

; LCD data ports D4 - D7 == 0x01 - 0x04


#define LCD_EN LCDport,0x05 ; Enable Output / "CLK"
#define LCD_RW LCDport,0x06 ; Read/Write
#define LCD_RS LCDport,0x07 ; Register Select

;***** REGISTER DECLARATION *****

IFNDEF BASE

http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm (4 of 10)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm

ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

LCDbuf set BASE+d'2' ; LCD data buffer


LCDtemp set BASE+d'3' ; LCD temporary register

;***** LCD COMMANDS *****

;*** Standard LCD COMMANDS for INIT *** ( HI-NIBBLE only )


; for 4 bit mode: send only one nibble as high-nibble [DB7:DB4]
CONSTANT LCDEM8 = b'0011' ; entry mode set: 8 bit mode, 2 lines
CONSTANT LCDEM4 = b'0010' ; entry mode set: 4 bit mode, 2 lines
CONSTANT LCDDZ = b'1000' ; set Display Data Ram Address to zero

;*** Standard LCD COMMANDS *** ( HI- / LO-NIBBLE )


; USE THESE COMMANDS BELOW AS FOLLOW: "LCDcmd LCDCLR"
CONSTANT LCDCLR = b'00000001' ; clear display: resets address counter & cursor
CONSTANT LCDCH = b'00000010' ; cursor home
CONSTANT LCDCR = b'00000110' ; entry mode set: cursor moves right, display auto-shift off
CONSTANT LCDCL = b'00000100' ; entry mode set: cursor moves left, display auto-shift off
CONSTANT LCDCONT = b'00001100' ; display control: display on, cursor off, blinking off
CONSTANT LCDMCL = b'00010000' ; cursor/disp control: move cursor left
CONSTANT LCDMCR = b'00010100' ; cursor/disp control: move cursor right
CONSTANT LCDSL = b'00011000' ; cursor/disp control: shift display content left
CONSTANT LCDSR = b'00011100' ; cursor/disp control: shift display content right
CONSTANT LCD2L = b'00101000' ; function set: 4 bit mode, 2 lines, 5x7 dots
IF (LCDLINENUM == 0x2)
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (2xXX LCD)
CONSTANT LCDL2 = b'11000000' ; DDRAM address: 0x40, selects line 2 (2xXX LCD)
CONSTANT LCDL3 = b'10010100' ; (DDRAM address: 0x14, fallback)
CONSTANT LCDL4 = b'11010100' ; (DDRAM address: 0x54, fallback)
ELSE
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (4xXX LCD)
CONSTANT LCDL2 = b'10010100' ; DDRAM address: 0x14, selects line 2 (4xXX LCD)
CONSTANT LCDL3 = b'11000000' ; DDRAM address: 0x40, selects line 3 (4xXX LCD)
CONSTANT LCDL4 = b'11010100' ; DDRAM address: 0x54, selects line 4 (4xXX LCD)
ENDIF
; special configuration for EA DIP204-4
CONSTANT LCDEXT = b'00001001' ; extended function set EA DIP204-4
CONSTANT LCD2L_A = b'00101100' ; enter ext. function set: 4 bit mode, 2 lines, 5x7 dots
CONSTANT LCD2L_B = b'00101000' ; exit ext. function set: 4 bit mode, 2 lines, 5x7 dots

;***** MACROS *****

http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm (5 of 10)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm

LCDinit macro
BANK1
movlw b'0000001' ; set to output
andwf LCDtris,f
BANK0
bcf LCD_EN ; clear LCD clock line
bcf LCD_RW ; set write direction
bcf LCD_RS ; clear command/data line
clrLCDport ; reset LCD data lines
WAIT 4*LCDWAIT ; >= 4 ms @ 4 MHz

; LCD INITIALIZATION STARTS HERE


; start in 8 bit mode
movlw LCDEM8 ; send b'0011' on [DB7:DB4]
call LCDxmit ; start in 8 bit mode
call LCDclk ; That's while:
WAIT LCDWAIT ; On POWER UP, the LCD will initialize itself,
; but after a RESET of the microcontroller without
; POWER OFF, the 8 bit function mode will reboot
; the LCD to 4 bit mode safely.

movlw LCDDZ ; set DDRAM to zero


call LCDxmit
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

movlw LCDEM4 ; send b'0010' on [DB7:DB4]


call LCDxmit ; change to 4 bit mode
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

; now in 4 bit mode, sending two nibbles


IF LCDTYPE == 0x00
LCDcmd LCD2L ; function set: 4 bit mode, 2 lines, 5x7 dots
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
IF LCDTYPE == 0x01
; for LCD EA DIP204-4 (white chars, blue backlight)
LCDcmd LCD2L_A ; switch on extended function set
LCDcmd LCDEXT ; 4 lines

http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm (6 of 10)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm

LCDcmd LCD2L_B ; switch off extended function set


LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
ERROR "Unsupported parameter"
ENDIF
ENDIF
LCDspecialChars ; insert special character setup macro
endm

LCDspecialChars macro ; max. 8 self-defined chars


; *** first self-defined character "Delta" at position 0x00 ***
; *** call by "LCDchar 0x00" ***
LCD_CGAdr 0x00 ; send CGRamAddress
LCDchar b'00000110' ; write data to CGRamAddress
LCD_CGAdr 0x01
LCDchar b'00001000'
LCD_CGAdr 0x02
LCDchar b'00000100'
LCD_CGAdr 0x03
LCDchar b'00001010'
LCD_CGAdr 0x04
LCDchar b'00010001'
LCD_CGAdr 0x05
LCDchar b'00010001'
LCD_CGAdr 0x06
LCDchar b'00001110'
LCD_CGAdr 0x07
LCDchar b'00000000'

; *** second self-defined character "Big Omega" at position 0x01 ***


; *** call by "LCDchar 0x01" ***
LCD_CGAdr 0x08 ; send CGRamAddress
LCDchar b'00001110' ; write data to CGRamAddress
LCD_CGAdr 0x09
LCDchar b'00010001'
LCD_CGAdr 0x0A
LCDchar b'00010001'
LCD_CGAdr 0x0B
LCDchar b'00010001'
LCD_CGAdr 0x0C
LCDchar b'00010001'

http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm (7 of 10)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm

LCD_CGAdr 0x0D
LCDchar b'00001010'
LCD_CGAdr 0x0E
LCDchar b'00011011'
LCD_CGAdr 0x0F
LCDchar b'00000000'

LCD_DDAdr 0x00 ; reset DDRam for proper function


endm

LCDchar macro LCDarg ; write ASCII argument to LCD


movlw LCDarg
call LCDdata
endm

LCDw macro ; write content of w to LCD


call LCDdata
endm

LCDcmd macro LCDcommand ; write command to LCD


movlw LCDcommand
call LCDcomd
endm

LCDline macro line_num


IF (line_num == 1)
LCDcmd LCDL1 ; first line
ELSE
IF (line_num == 2)
LCDcmd LCDL2 ; second line
ELSE
IF (line_num == 3)
LCDcmd LCDL3 ; third line
ELSE
IF (line_num == 4)
LCDcmd LCDL4 ; fourth line
ELSE
ERROR "Wrong line number specified in LCDline"
ENDIF
ENDIF
ENDIF
ENDIF
endm

http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm (8 of 10)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm

LCD_DDAdr macro DDRamAddress


Local value = DDRamAddress | b'10000000' ; mask command
IF (DDRamAddress > 0x67)
ERROR "Wrong DD-RAM-Address specified in LCD_DDAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

LCD_CGAdr macro CGRamAddress


Local value = CGRamAddress | b'01000000' ; mask command
IF (CGRamAddress > b'00111111')
ERROR "Wrong CG-RAM-Address specified in LCD_CGAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

clrLCDport macro ; clear/reset LCD data lines


movlw b'11100001' ; get mask
andwf LCDport,f ; clear data lines only
endm

;***** SUBROUTINES *****

; transmit only lower nibble of w


LCDxmit movwf LCDbuf ; store command/data nibble
; first, clear LCD data lines
clrLCDport
; second, move data out to LCD data lines
rlf LCDbuf,w ; get data
andlw b'00011110' ; extract only valid part
iorwf LCDport,f ; put to LCD data lines
RETURN

; transmit command to LCD


LCDcomd bcf LCD_RS ; select command registers
goto _LCD_wr

; transmit data to LCD

http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm (9 of 10)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm

LCDdata bsf LCD_RS ; select data registers


_LCD_wr bcf LCD_RW ; set write direction
movwf LCDtemp ; store command/data to send
; send hi-nibble
movfw LCDtemp ; get data
swapf LCDtemp,w ; swap hi- and lo-nibble, store in w
call LCDxmit ; transmit nibble
call LCDclk
; send lo-nibble
movfw LCDtemp ; get data
call LCDxmit ; transmit nibble
call LCDclk
; reset LCD controls
clrLCDport ; reset LCD data lines
bcf LCD_RS ; reset command/data register
;bcf LCD_RW ; reset to write direction
RETURN

; clocks LCD data/command


LCDclk WAIT LCDWAIT
bsf LCD_EN ; set LCD enable
; insert LCDSPEED x nops to comply with manufacturer
; specifications for clock rates above 9 MHz
VARIABLE CNT_V ; declare intermediate variable
CNT_V = LCDSPEED ; assign pre-defined constant
WHILE (CNT_V > 0x0) ; perform while loop to insert 'nops'
nop ; insert 'nop'
CNT_V -= 1 ; decrement
ENDW
bcf LCD_EN
WAIT LCDWAIT ; clocks LCD data/command
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcdx.asm (10 of 10)12/02/2008 17:12:45


http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm

;***************************************************************************
;
; LCD INTERFACE V3.09 for PIC 16XXX
; =================================
;
; written by Peter Luethi, 15.05.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 26.12.2004
;
; V3.09: Added new parameters: (26.12.2004)
; - LCDLINENUM: (default: 0x2) # of LCD lines (affects LCDL2/3)
; - LCDTYPE: type of LCD/controller:
; - 0x0: (default) standard LCD (w/ HD44780)
; - 0x1: EA DIP204-4 (w/ KS0073, white chars, blue bg)
; - LCDBUSYWAIT: (default: 0x18) wait before LCD busy flag
; is available
; V3.08: Fixed high-speed timing issue in busy flag part
; (24.06.2004)
; V3.07: Changed LCDinit and constants (06.06.2004)
; V3.06: Clean-up and general improvements, added flag
; LCDcflag, removed register LCDtemp2 (10.04.2004)
; V3.05: Added parameter LCDSPEED (04.01.2004)
; V3.04: Improved masking of LCD data outputs,
; reduced code size, added parameter LCDWAIT (16.02.2003)
; V3.03: Replaced LCDtemp3 register used for busy flag with
; define statement: #define LCDbusy FLAGreg,0x06
; V3.02: LCDinit coded as macro instead of procedure
; V3.01: LCDinit with "andwf" instead of "movwf"
; V3.00: Reads busy flag of LCD, minimum waittime,
; 4.00 - 20.00 MHz clock (15.05.1999)
; Clock independent portable code!
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;

http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm (1 of 10)12/02/2008 17:12:46


http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm

; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16X84, 16F7X, 16F87X
; Clock: 4.00 MHz XT - 20.00 MHz HS Mode (tested)
; Throughput: 1 - 5 MIPS
; LCD Transmission Mode: 4 bit on high nibble of LCD port
; (MSB D7-D4)
; LCD Connections: 7 wires on any portX (4 data, 3 command)
; X0: unused, X1-X7: D4-D7, E, R/W, RS
; Total: 10 wires
; (4 data, 3 command, 1 Vdd, 1 GND, 1 contrast)
;
;
; ADDITIONAL PROGRAM CODE:
; ========================
; procedure CheckBusy
; procedure LCDbusyloop
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16F84 @ 4 MHz, tested on 16F84 @ 10 MHz
; and 16C74A/16F77 @ 20 MHz, but executeable on all PIC 16XXX.
; Program handles all aspects of setup and display on a dot matrix LCD
; display. Routines are provided to allow display of characters,
; display shifting and clearing, cursor setup, cursor positioning and
; line change.
;
; Program calls module m_wait.asm with implemented standard delay:
; "WAIT 0x01" is equal to 1 Unit == 1.04 ms (@ 4 MHz)
; The assigned standard prescaler for TMR0 is "PRESCstd = b'00000001'"
;
; Call of implemented procedures with:
; "LCDinit" (macro)
; "LCDchar 'c'" display ascii character
; "LCDw" display char in working register
; "LCDcmd xxx" e.g. "LCDcmd LCDCLR"
; "LCD_DDAdr xxx" set cursor to explicit address
; --> REFER TO LCD DOCUMENTATION
; "LCDline x" set cursor to the beginning of line 1/2
;
; To display decimal-values, please include the following binary to
; decimal conversion modules:

http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm (2 of 10)12/02/2008 17:12:46


http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm

; for 8 Bit: m_lcdv08.asm


; for 16 Bit: m_lcdv16.asm
;
;
; DEFAULT TIMING PARAMETERS:
; ==========================
; CONSTANT LCDLINENUM = 0x02 ; LCD display has two lines (e.g. 2x20)
; CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
; CONSTANT LCDSPEED = 0x01 ; affecting LCD_EN 'clock': high speed PIC clock
; CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
; CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
; CONSTANT LCDBUSYWAIT = 0x18 ; wait before LCD busy flag is available
;
; To maintain proper timing (setup time, wait time, LCD initialization),
; adjust the parameter LCDWAIT as follows:
; if Tosc <= 5 MHz: LCDWAIT = 0x01
; else LCDWAIT = floor(0.25 * clock frequency[MHz])
; To comply with manufacturer specifications (Enable High Time >= 450 ns),
; add a "nop" to the procedure LCDclk, if using this module with clock
; rates higher than 9 MHz. Therefore, define in your main program:
; CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
; CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; CONSTANT BASE = 0x0C Base address of user file registers
; LCDtris equ TRISB
; LCDport equ PORTB
; #define LCDbusy FLAGreg,0x06 ; LCD busy flag declared within flag register
; #define LCDcflag FLAGreg,0x07 ; LCD command/data flag
;
; LCD port connections: B0: not used, still available for INTB
; B1: D4
; B2: D5
; B3: D6
; B4: D7
; B5: E
; B6: R/W
; B7: RS
;
; REQUIRED MEMORY:
; ================

http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm (3 of 10)12/02/2008 17:12:46


http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm

; 2 registers: @ BASE+2 - BASE+3


; 2 flags: LCDbusy, LCDcflag
;
;***************************************************************************
#DEFINE M_LCD_ID dummy

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF

;***** CONSTANT DECLARATION *****

IFNDEF LCDLINENUM ; use default value, if unspecified


CONSTANT LCDLINENUM = 0x02 ; by default, 2 lines
ENDIF
IFNDEF LCDTYPE ; use default value, if unspecified
CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
;CONSTANT LCDTYPE = 0x01 ; EADIP204-4 (w/ KS0073)
ENDIF
IFNDEF LCDSPEED ; use default value, if unspecified
;CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
ENDIF
IFNDEF LCDWAIT ; use default value, if unspecified
CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
ENDIF
IFNDEF LCDCLRWAIT ; use default value, if unspecified
CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
ENDIF
IFNDEF LCDBUSYWAIT ; use default value, if unspecified
CONSTANT LCDBUSYWAIT = 0x18 ; wait before LCD busy flag is available
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF LCDtris
ERROR "Declare LCDtris in MAIN PROGRAM"
ENDIF

http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm (4 of 10)12/02/2008 17:12:46


http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm

IFNDEF LCDport
ERROR "Declare LCDport in MAIN PROGRAM"
ENDIF
IFNDEF LCDbusy
ERROR "#define LCDbusy FLAGreg,0x00 in MAIN PROGRAM"
ENDIF
IFNDEF LCDcflag
ERROR "#define LCDcflag FLAGreg,0x01 in MAIN PROGRAM"
ENDIF

; LCD data ports D4 - D7 == 0x01 - 0x04


D7 equ 0x04 ; LCD data line 7, for busy flag
#define LCD_EN LCDport,0x05 ; Enable Output / "CLK"
#define LCD_RW LCDport,0x06 ; Read/Write
#define LCD_RS LCDport,0x07 ; Register Select

;***** REGISTER DECLARATION *****

IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

LCDbuf set BASE+d'2' ; LCD data buffer


LCDtemp set BASE+d'3' ; LCD temporary register
LCDtemp2 set BASE+d'2' ; busy wait loop (re-use LCDbuf)

;***** LCD COMMANDS *****

;*** Standard LCD COMMANDS for INIT *** ( HI-NIBBLE only )


; for 4 bit mode: send only one nibble as high-nibble [DB7:DB4]
CONSTANT LCDEM8 = b'0011' ; entry mode set: 8 bit mode, 2 lines
CONSTANT LCDEM4 = b'0010' ; entry mode set: 4 bit mode, 2 lines
CONSTANT LCDDZ = b'1000' ; set Display Data Ram Address to zero

;*** Standard LCD COMMANDS *** ( HI- / LO-NIBBLE )


; USE THESE COMMANDS BELOW AS FOLLOW: "LCDcmd LCDCLR"
CONSTANT LCDCLR = b'00000001' ; clear display: resets address counter & cursor
CONSTANT LCDCH = b'00000010' ; cursor home
CONSTANT LCDCR = b'00000110' ; entry mode set: cursor moves right, display auto-shift off
CONSTANT LCDCL = b'00000100' ; entry mode set: cursor moves left, display auto-shift off
CONSTANT LCDCONT = b'00001100' ; display control: display on, cursor off, blinking off
CONSTANT LCDMCL = b'00010000' ; cursor/disp control: move cursor left
CONSTANT LCDMCR = b'00010100' ; cursor/disp control: move cursor right

http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm (5 of 10)12/02/2008 17:12:46


http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm

CONSTANT LCDSL = b'00011000' ; cursor/disp control: shift display content left


CONSTANT LCDSR = b'00011100' ; cursor/disp control: shift display content right
CONSTANT LCD2L = b'00101000' ; function set: 4 bit mode, 2 lines, 5x7 dots
IF (LCDLINENUM == 0x2)
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (2xXX LCD)
CONSTANT LCDL2 = b'11000000' ; DDRAM address: 0x40, selects line 2 (2xXX LCD)
CONSTANT LCDL3 = b'10010100' ; (DDRAM address: 0x14, fallback)
CONSTANT LCDL4 = b'11010100' ; (DDRAM address: 0x54, fallback)
ELSE
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (4xXX LCD)
CONSTANT LCDL2 = b'10010100' ; DDRAM address: 0x14, selects line 2 (4xXX LCD)
CONSTANT LCDL3 = b'11000000' ; DDRAM address: 0x40, selects line 3 (4xXX LCD)
CONSTANT LCDL4 = b'11010100' ; DDRAM address: 0x54, selects line 4 (4xXX LCD)
ENDIF
; special configuration for EA DIP204-4
CONSTANT LCDEXT = b'00001001' ; extended function set EA DIP204-4
CONSTANT LCD2L_A = b'00101100' ; enter ext. function set: 4 bit mode, 2 lines, 5x7 dots
CONSTANT LCD2L_B = b'00101000' ; exit ext. function set: 4 bit mode, 2 lines, 5x7 dots

;***** MACROS *****

LCDinit macro
BANK1
movlw b'0000001' ; set to output
andwf LCDtris,f
BANK0
bcf LCD_EN ; clear LCD clock line
bcf LCD_RW ; set write direction
bcf LCD_RS ; clear command/data line
clrLCDport ; reset LCD data lines
WAIT 4*LCDWAIT ; >= 4 ms @ 4 MHz

; LCD INITIALIZATION STARTS HERE


; start in 8 bit mode
movlw LCDEM8 ; send b'0011' on [DB7:DB4]
call LCDxmit ; start in 8 bit mode
call LCDclk ; That's while:
WAIT LCDWAIT ; On POWER UP, the LCD will initialize itself,
; but after a RESET of the microcontroller without
; POWER OFF, the 8 bit function mode will reboot
; the LCD to 4 bit mode safely.

movlw LCDDZ ; set DDRAM to zero

http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm (6 of 10)12/02/2008 17:12:46


http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm

call LCDxmit
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

movlw LCDEM4 ; send b'0010' on [DB7:DB4]


call LCDxmit ; change to 4 bit mode
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

; now in 4 bit mode, sending two nibbles


IF LCDTYPE == 0x00
LCDcmd LCD2L ; function set: 4 bit mode, 2 lines, 5x7 dots
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
IF LCDTYPE == 0x01
; for LCD EA DIP204-4 (white chars, blue backlight)
LCDcmd LCD2L_A ; switch on extended function set
LCDcmd LCDEXT ; 4 lines
LCDcmd LCD2L_B ; switch off extended function set
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
ERROR "Unsupported parameter"
ENDIF
ENDIF
endm

LCDchar macro LCDarg ; write ASCII argument to LCD


movlw LCDarg
call LCDdata
endm

LCDw macro ; write content of w to LCD


call LCDdata
endm

LCDcmd macro LCDcommand ; write command to LCD


movlw LCDcommand
call LCDcomd
endm

http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm (7 of 10)12/02/2008 17:12:46


http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm

LCDline macro line_num


IF (line_num == 1)
LCDcmd LCDL1 ; first line
ELSE
IF (line_num == 2)
LCDcmd LCDL2 ; second line
ELSE
IF (line_num == 3)
LCDcmd LCDL3 ; third line
ELSE
IF (line_num == 4)
LCDcmd LCDL4 ; fourth line
ELSE
ERROR "Wrong line number specified in LCDline"
ENDIF
ENDIF
ENDIF
ENDIF
endm

LCD_DDAdr macro DDRamAddress


Local value = DDRamAddress | b'10000000' ; mask command
IF (DDRamAddress > 0x67)
ERROR "Wrong DD-RAM-Address specified in LCD_DDAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

clrLCDport macro ; clear/reset LCD data lines


movlw b'11100001' ; get mask
andwf LCDport,f ; clear data lines only
endm

;***** SUBROUTINES *****

; transmit only lower nibble of w


LCDxmit movwf LCDbuf ; store command/data nibble
; first, clear LCD data lines
clrLCDport
; second, move data out to LCD data lines

http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm (8 of 10)12/02/2008 17:12:46


http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm

rlf LCDbuf,w ; get data


andlw b'00011110' ; extract only valid part
iorwf LCDport,f ; put to LCD data lines
RETURN

; transmit command to LCD


LCDcomd bsf LCDcflag ; set command
goto _LCD_wr

; transmit data to LCD


LCDdata bcf LCDcflag ; set data
_LCD_wr movwf LCDtemp ; store command/data to send
call CheckBusy ; check, if ready for next character
btfss LCDcflag ; skip if LCD command has been sent
bsf LCD_RS ; select data registers
; send hi-nibble
movfw LCDtemp ; get data
swapf LCDtemp,w ; swap hi- and lo-nibble, store in w
call LCDxmit ; transmit nibble
call LCDclk
; send lo-nibble
movfw LCDtemp ; get data
call LCDxmit ; transmit nibble
call LCDclk
; reset LCD controls
clrLCDport ; reset LCD data lines
bcf LCD_RS ; reset command/data register
bcf LCD_RW ; reset to write direction
RETURN

; clocks LCD data/command


LCDclk bsf LCD_EN ; set LCD enable
; insert LCDSPEED x nops to comply with manufacturer
; specifications for clock rates above 9 MHz
VARIABLE CNT_V ; declare intermediate variable
CNT_V = LCDSPEED ; assign pre-defined constant
WHILE (CNT_V > 0x0) ; perform while loop to insert 'nops'
nop ; insert 'nop'
CNT_V -= 1 ; decrement
ENDW
bcf LCD_EN
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm (9 of 10)12/02/2008 17:12:46


http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm

; busy wait loop, makes busy flag signalling safe


LCDbusyloop
movlw LCDBUSYWAIT ; pre-defined constant
movwf LCDtemp2
_LCDbusyloop
decfsz LCDtemp2,f
goto _LCDbusyloop ; busy loop
RETURN

; routine to poll busy flag from LCD


CheckBusy
bcf LCD_RS ; select command registers
bsf LCDbusy ; init LCD busy flag
BANK1
movlw b'00011110'
iorwf LCDtris,f ; set corresponding ports to inputs
BANK0
bsf LCD_RW ; apply read direction
nop ; additional safety
_LCDbusy bsf LCD_EN ; set enable
; the following busy wait code makes busy flag signalling safe
call LCDbusyloop ; (timing relaxation)
; poll now LCD busy flag
btfss LCDport,D7 ; check busy flag, skip if busy
bcf LCDbusy ; set register flag if not busy
bcf LCD_EN
; the following busy wait code makes busy flag signalling safe
call LCDbusyloop ; (timing relaxation)
; get low nibble, ignore it
call LCDclk
btfsc LCDbusy ; skip if register flag is not yet cleared
goto _LCDbusy
bcf LCD_RW ; re-apply write direction
BANK1
movlw b'11100001'
andwf LCDtris,f ; set ports to output again
BANK0
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcd_bf.asm (10 of 10)12/02/2008 17:12:46


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

;***************************************************************************
;
; LCD INTERFACE V3.29 for PIC 16XXX
; =================================
;
; written by Peter Luethi, 15.05.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 26.12.2004
;
; V3.29: Added new parameters: (26.12.2004)
; - LCDLINENUM: (default: 0x2) # of LCD lines (affects LCDL2/3)
; - LCDTYPE: type of LCD/controller:
; - 0x0: (default) standard LCD (w/ HD44780)
; - 0x1: EA DIP204-4 (w/ KS0073, white chars, blue bg)
; - LCDBUSYWAIT: (default: 0x18) wait before LCD busy flag
; is available
; V3.28: Fixed high-speed timing issue in busy flag part
; (24.06.2004)
; V3.27: Changed LCDinit and constants (06.06.2004)
; V3.26: Clean-up and general improvements, added flag
; LCDcflag, removed register LCDtemp2 (10.04.2004)
; V3.25: added parameter LCDSPEED (04.01.2004)
; V3.24: Improved masking of LCD data outputs,
; reduced code size, added parameter LCDWAIT (16.02.2003)
; V3.23: Replaced LCDtemp3 register used for busy flag with
; define statement: #define LCDbusy FLAGreg,0x06
; V3.22: LCDinit coded as macro instead of procedure
; V3.21: LCDinit with "andwf" instead of "movwf"
; V3.20: Reads busy flag of LCD, minimum waittime,
; 4.00 - 20.00 MHz clock (15.05.1999)
; Clock independent portable code!
; Ability to define your own characters for the LCD
; (=> see macro LCDspecialChars)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (1 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16X84, 16F7X, 16F87X
; Clock: 4.00 MHz XT - 20.00 MHz HS Mode (tested)
; Throughput: 1 - 5 MIPS
; LCD Transmission Mode: 4 bit on high nibble of LCD port
; (MSB D7-D4)
; LCD Connections: 7 wires on any portX (4 data, 3 command)
; X0: unused, X1-X7: D4-D7, E, R/W, RS
; Total: 10 wires
; (4 data, 3 command, 1 Vdd, 1 GND, 1 contrast)
;
;
; ADDITIONAL PROGRAM CODE:
; ========================
; procedure CheckBusy
; procedure LCDbusyloop
; macro LCD_CGAdr
; macro LCDspecialChars
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16C84 @ 4 MHz, tested on 16F84 @ 10 MHz
; and 16C74A @ 20 MHz, but executeable on all PIC 16XXX.
; Program handles all aspects of setup and display on a dot matrix LCD
; display. Routines are provided to allow display of characters,
; display shifting and clearing, cursor setup, cursor positioning and
; line change.
;
; Program calls module m_wait.asm with implemented standard delay:
; "WAIT 0x01" is equal to 1 Unit == 1.04 ms (@ 4 MHz)
; The assigned standard prescaler for TMR0 is "PRESCstd = b'00000001'"
;
; Call of implemented procedures with:
; "LCDinit" (macro)
; "LCDchar 'c'" display ascii character
; "LCDw" display char in working register
; "LCDcmd xxx" e.g. "LCDcmd LCDCLR"
; "LCD_DDAdr xxx" set cursor to explicit address
; --> REFER TO LCD DOCUMENTATION

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (2 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

; "LCDline x" set cursor to the beginning of line 1/2


;
; To display decimal-values, please include the following binary to
; decimal conversion modules:
; for 8 Bit: m_lcdv08.asm
; for 16 Bit: m_lcdv16.asm
;
;
; DEFAULT TIMING PARAMETERS:
; ==========================
; CONSTANT LCDLINENUM = 0x02 ; LCD display has two lines (e.g. 2x20)
; CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
; CONSTANT LCDSPEED = 0x01 ; affecting LCD_EN 'clock': high speed PIC clock
; CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
; CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
; CONSTANT LCDBUSYWAIT = 0x18 ; wait before LCD busy flag is available
;
; To maintain proper timing (setup time, wait time, LCD initialization),
; adjust the parameter LCDWAIT as follows:
; if Tosc <= 5 MHz: LCDWAIT = 0x01
; else LCDWAIT = floor(0.25 * clock frequency[MHz])
; To comply with manufacturer specifications (Enable High Time >= 450 ns),
; add a "nop" to the procedure LCDclk, if using this module with clock
; rates higher than 9 MHz. Therefore, define in your main program:
; CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
; CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; CONSTANT BASE = 0x0C Base address of user file registers
; LCDtris equ TRISB
; LCDport equ PORTB
; #define LCDbusy FLAGreg,0x06 ; LCD busy flag declared within flag register
; #define LCDcflag FLAGreg,0x07 ; LCD command/data flag
;
; LCD port connections: B0: not used, still available for INTB
; B1: D4
; B2: D5
; B3: D6
; B4: D7
; B5: E
; B6: R/W

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (3 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

; B7: RS
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+2 - BASE+3
; 2 flags: LCDbusy, LCDcflag
;
;***************************************************************************
#DEFINE M_LCD_ID dummy

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF

;***** CONSTANT DECLARATION *****

IFNDEF LCDLINENUM ; use default value, if unspecified


CONSTANT LCDLINENUM = 0x02 ; by default, 2 lines
ENDIF
IFNDEF LCDTYPE ; use default value, if unspecified
CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
;CONSTANT LCDTYPE = 0x01 ; EADIP204-4 (w/ KS0073)
ENDIF
IFNDEF LCDSPEED ; use default value, if unspecified
;CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
ENDIF
IFNDEF LCDWAIT ; use default value, if unspecified
CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
ENDIF
IFNDEF LCDCLRWAIT ; use default value, if unspecified
CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
ENDIF
IFNDEF LCDBUSYWAIT ; use default value, if unspecified
CONSTANT LCDBUSYWAIT = 0x18 ; wait before LCD busy flag is available
ENDIF

;***** HARDWARE DECLARATION *****

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (4 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

IFNDEF LCDtris
ERROR "Declare LCDtris in MAIN PROGRAM"
ENDIF
IFNDEF LCDport
ERROR "Declare LCDport in MAIN PROGRAM"
ENDIF
IFNDEF LCDbusy
ERROR "#define LCDbusy FLAGreg,0x00 in MAIN PROGRAM"
ENDIF
IFNDEF LCDcflag
ERROR "#define LCDcflag FLAGreg,0x01 in MAIN PROGRAM"
ENDIF

; LCD data ports D4 - D7 == 0x01 - 0x04


D7 equ 0x04 ; LCD data line 7, for busy flag
#define LCD_EN LCDport,0x05 ; Enable Output / "CLK"
#define LCD_RW LCDport,0x06 ; Read/Write
#define LCD_RS LCDport,0x07 ; Register Select

;***** REGISTER DECLARATION *****

IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

LCDbuf set BASE+d'2' ; LCD data buffer


LCDtemp set BASE+d'3' ; LCD temporary register
LCDtemp2 set BASE+d'2' ; busy wait loop (re-use LCDbuf)

;***** LCD COMMANDS *****

;*** Standard LCD COMMANDS for INIT *** ( HI-NIBBLE only )


; for 4 bit mode: send only one nibble as high-nibble [DB7:DB4]
CONSTANT LCDEM8 = b'0011' ; entry mode set: 8 bit mode, 2 lines
CONSTANT LCDEM4 = b'0010' ; entry mode set: 4 bit mode, 2 lines
CONSTANT LCDDZ = b'1000' ; set Display Data Ram Address to zero

;*** Standard LCD COMMANDS *** ( HI- / LO-NIBBLE )


; USE THESE COMMANDS BELOW AS FOLLOW: "LCDcmd LCDCLR"
CONSTANT LCDCLR = b'00000001' ; clear display: resets address counter & cursor
CONSTANT LCDCH = b'00000010' ; cursor home
CONSTANT LCDCR = b'00000110' ; entry mode set: cursor moves right, display auto-shift off

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (5 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

CONSTANT LCDCL = b'00000100' ; entry mode set: cursor moves left, display auto-shift off
CONSTANT LCDCONT = b'00001100' ; display control: display on, cursor off, blinking off
CONSTANT LCDMCL = b'00010000' ; cursor/disp control: move cursor left
CONSTANT LCDMCR = b'00010100' ; cursor/disp control: move cursor right
CONSTANT LCDSL = b'00011000' ; cursor/disp control: shift display content left
CONSTANT LCDSR = b'00011100' ; cursor/disp control: shift display content right
CONSTANT LCD2L = b'00101000' ; function set: 4 bit mode, 2 lines, 5x7 dots
IF (LCDLINENUM == 0x2)
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (2xXX LCD)
CONSTANT LCDL2 = b'11000000' ; DDRAM address: 0x40, selects line 2 (2xXX LCD)
CONSTANT LCDL3 = b'10010100' ; (DDRAM address: 0x14, fallback)
CONSTANT LCDL4 = b'11010100' ; (DDRAM address: 0x54, fallback)
ELSE
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (4xXX LCD)
CONSTANT LCDL2 = b'10010100' ; DDRAM address: 0x14, selects line 2 (4xXX LCD)
CONSTANT LCDL3 = b'11000000' ; DDRAM address: 0x40, selects line 3 (4xXX LCD)
CONSTANT LCDL4 = b'11010100' ; DDRAM address: 0x54, selects line 4 (4xXX LCD)
ENDIF
; special configuration for EA DIP204-4
CONSTANT LCDEXT = b'00001001' ; extended function set EA DIP204-4
CONSTANT LCD2L_A = b'00101100' ; enter ext. function set: 4 bit mode, 2 lines, 5x7 dots
CONSTANT LCD2L_B = b'00101000' ; exit ext. function set: 4 bit mode, 2 lines, 5x7 dots

;***** MACROS *****

LCDinit macro
BANK1
movlw b'0000001' ; set to output
andwf LCDtris,f
BANK0
bcf LCD_EN ; clear LCD clock line
bcf LCD_RW ; set write direction
bcf LCD_RS ; clear command/data line
clrLCDport ; reset LCD data lines
WAIT 4*LCDWAIT ; >= 4 ms @ 4 MHz

; LCD INITIALIZATION STARTS HERE


; start in 8 bit mode
movlw LCDEM8 ; send b'0011' on [DB7:DB4]
call LCDxmit ; start in 8 bit mode
call LCDclk ; That's while:
WAIT LCDWAIT ; On POWER UP, the LCD will initialize itself,
; but after a RESET of the microcontroller without

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (6 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

; POWER OFF, the 8 bit function mode will reboot


; the LCD to 4 bit mode safely.

movlw LCDDZ ; set DDRAM to zero


call LCDxmit
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

movlw LCDEM4 ; send b'0010' on [DB7:DB4]


call LCDxmit ; change to 4 bit mode
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

; now in 4 bit mode, sending two nibbles


IF LCDTYPE == 0x00
LCDcmd LCD2L ; function set: 4 bit mode, 2 lines, 5x7 dots
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
IF LCDTYPE == 0x01
; for LCD EA DIP204-4 (white chars, blue backlight)
LCDcmd LCD2L_A ; switch on extended function set
LCDcmd LCDEXT ; 4 lines
LCDcmd LCD2L_B ; switch off extended function set
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
ERROR "Unsupported parameter"
ENDIF
ENDIF
LCDspecialChars ; insert special character setup macro
endm

LCDspecialChars macro ; max. 8 self-defined chars


; *** first self-defined character "Delta" at position 0x00 ***
; *** call by "LCDchar 0x00" ***
LCD_CGAdr 0x00 ; send CGRamAddress
LCDchar b'00000110' ; write data to CGRamAddress
LCD_CGAdr 0x01
LCDchar b'00001000'
LCD_CGAdr 0x02

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (7 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

LCDchar b'00000100'
LCD_CGAdr 0x03
LCDchar b'00001010'
LCD_CGAdr 0x04
LCDchar b'00010001'
LCD_CGAdr 0x05
LCDchar b'00010001'
LCD_CGAdr 0x06
LCDchar b'00001110'
LCD_CGAdr 0x07
LCDchar b'00000000'

; *** second self-defined character "Big Omega" at position 0x01 ***


; *** call by "LCDchar 0x01" ***
LCD_CGAdr 0x08 ; send CGRamAddress
LCDchar b'00001110' ; write data to CGRamAddress
LCD_CGAdr 0x09
LCDchar b'00010001'
LCD_CGAdr 0x0A
LCDchar b'00010001'
LCD_CGAdr 0x0B
LCDchar b'00010001'
LCD_CGAdr 0x0C
LCDchar b'00010001'
LCD_CGAdr 0x0D
LCDchar b'00001010'
LCD_CGAdr 0x0E
LCDchar b'00011011'
LCD_CGAdr 0x0F
LCDchar b'00000000'

LCD_DDAdr 0x00 ; reset DDRam for proper function


endm

LCDchar macro LCDarg ; write ASCII argument to LCD


movlw LCDarg
call LCDdata
endm

LCDw macro ; write content of w to LCD


call LCDdata
endm

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (8 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

LCDcmd macro LCDcommand ; write command to LCD


movlw LCDcommand
call LCDcomd
endm

LCDline macro line_num


IF (line_num == 1)
LCDcmd LCDL1 ; first line
ELSE
IF (line_num == 2)
LCDcmd LCDL2 ; second line
ELSE
IF (line_num == 3)
LCDcmd LCDL3 ; third line
ELSE
IF (line_num == 4)
LCDcmd LCDL4 ; fourth line
ELSE
ERROR "Wrong line number specified in LCDline"
ENDIF
ENDIF
ENDIF
ENDIF
endm

LCD_DDAdr macro DDRamAddress


Local value = DDRamAddress | b'10000000' ; mask command
IF (DDRamAddress > 0x67)
ERROR "Wrong DD-RAM-Address specified in LCD_DDAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

LCD_CGAdr macro CGRamAddress


Local value = CGRamAddress | b'01000000' ; mask command
IF (CGRamAddress > b'00111111')
ERROR "Wrong CG-RAM-Address specified in LCD_CGAdr"
ELSE
movlw value
call LCDcomd
ENDIF

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (9 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

endm

clrLCDport macro ; clear/reset LCD data lines


movlw b'11100001' ; get mask
andwf LCDport,f ; clear data lines only
endm

;***** SUBROUTINES *****

; transmit only lower nibble of w


LCDxmit movwf LCDbuf ; store command/data nibble
; first, clear LCD data lines
clrLCDport
; second, move data out to LCD data lines
rlf LCDbuf,w ; get data
andlw b'00011110' ; extract only valid part
iorwf LCDport,f ; put to LCD data lines
RETURN

; transmit command to LCD


LCDcomd bsf LCDcflag ; set command
goto _LCD_wr

; transmit data to LCD


LCDdata bcf LCDcflag ; set data
_LCD_wr movwf LCDtemp ; store command/data to send
call CheckBusy ; check, if ready for next character
btfss LCDcflag ; skip if LCD command has been sent
bsf LCD_RS ; select data registers
; send hi-nibble
movfw LCDtemp ; get data
swapf LCDtemp,w ; swap hi- and lo-nibble, store in w
call LCDxmit ; transmit nibble
call LCDclk
; send lo-nibble
movfw LCDtemp ; get data
call LCDxmit ; transmit nibble
call LCDclk
; reset LCD controls
clrLCDport ; reset LCD data lines
bcf LCD_RS ; reset command/data register
bcf LCD_RW ; reset to write direction
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (10 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

; clocks LCD data/command


LCDclk bsf LCD_EN ; set LCD enable
; insert LCDSPEED x nops to comply with manufacturer
; specifications for clock rates above 9 MHz
VARIABLE CNT_V ; declare intermediate variable
CNT_V = LCDSPEED ; assign pre-defined constant
WHILE (CNT_V > 0x0) ; perform while loop to insert 'nops'
nop ; insert 'nop'
CNT_V -= 1 ; decrement
ENDW
bcf LCD_EN
RETURN

; busy wait loop, makes busy flag signalling safe


LCDbusyloop
movlw LCDBUSYWAIT ; pre-defined constant
movwf LCDtemp2
_LCDbusyloop
decfsz LCDtemp2,f
goto _LCDbusyloop ; busy loop
RETURN

; routine to poll busy flag from LCD


CheckBusy
bcf LCD_RS ; select command registers
bsf LCDbusy ; init LCD busy flag
BANK1
movlw b'00011110'
iorwf LCDtris,f ; set corresponding ports to inputs
BANK0
bsf LCD_RW ; apply read direction
nop ; additional safety
_LCDbusy bsf LCD_EN ; set enable
; the following busy wait code makes busy flag signalling safe
call LCDbusyloop ; (timing relaxation)
; poll now LCD busy flag
btfss LCDport,D7 ; check busy flag, skip if busy
bcf LCDbusy ; set register flag if not busy
bcf LCD_EN
; the following busy wait code makes busy flag signalling safe
call LCDbusyloop ; (timing relaxation)
; get low nibble, ignore it

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (11 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm

call LCDclk
btfsc LCDbusy ; skip if register flag is not yet cleared
goto _LCDbusy
bcf LCD_RW ; re-apply write direction
BANK1
movlw b'11100001'
andwf LCDtris,f ; set ports to output again
BANK0
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcdxbf.asm (12 of 12)12/02/2008 17:12:47


http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm

;***************************************************************************
;
; LCD INTERFACE V2.12e for PIC 16XXX
; ==================================
;
; written by Peter Luethi, 20.01.2003, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 17.08.2004
;
; V2.12e: Added new parameters: (17.08.2004)
; - LCDLINENUM: (default: 0x2) # of LCD lines (affects LCDL2/3)
; - LCDTYPE: type of LCD/controller:
; - 0x0: (default) standard LCD (w/ HD44780)
; - 0x1: EA DIP204-4 (w/ KS0073, white chars, blue bg)
; V2.11e: Changed LCDinit and constants (24.06.2004)
; V2.10e: Clean-up and general improvements, added
; parameter LCDSPEED (10.04.2004)
; V2.03e: Improved masking of LCD data ouputs,
; reduced code size, added parameter LCDWAIT
; (16.02.2003)
; V2.02e: LCDinit coded as macro instead of procedure
; V2.01e: LCDinit with "andwf" instead of "movwf"
; V2.00e: Initial release (20.01.2003)
; With constant timing delays (No busy flag check)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16X84, 16F7X
; Clock: 4.00 MHz XT - 10.00 MHz HS Mode (tested)
; Throughput: 1 - 2.5 MIPS
; LCD Transmission Mode: 4 bit on high nibble of LCD port
; (MSB D7-D4)

http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm (1 of 9)12/02/2008 17:12:48


http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm

; LCD Connections: 7 wires (4 data, 3 command),


; LCD data on low nibble of any port,
; LCD command on any port bits
; Total: 10 wires
; (4 data, 3 command, 1 Vdd, 1 GND, 1 contrast)
;
;
; DESCRIPTION:
; ============
; Developed on PIC 16F84, but executeable on all PIC 16XXX.
; Program handles all aspects of setup and display on a dot matrix LCD
; display. Routines are provided to allow display of characters,
; display shifting and clearing, cursor setup, cursor positioning and
; line change.
;
; Program calls module m_wait.asm with implemented standard delay:
; "WAIT 0x01" is equal to 1 Unit == 1.04 ms
; The assigned standard prescaler for TMR0 is "PRESCstd = b'00000001'"
;
; Call of implemented procedures with:
; "LCDinit" (macro)
; "LCDchar 'c'" display ascii character
; "LCDw" display char in working register
; "LCDcmd xxx" e.g. "LCDcmd LCDCLR"
; "LCD_DDAdr xxx" set cursor to explicit address
; --> REFER TO LCD DOCUMENTATION
; "LCDline x" set cursor to the beginning of line 1/2
;
; To display decimal-values, please include the following binary to
; decimal conversion modules:
; for 8 Bit: m_lcdv08.asm
; for 16 Bit: m_lcdv16.asm
;
;
; DEFAULT TIMING PARAMETERS:
; ==========================
; CONSTANT LCDLINENUM = 0x02 ; LCD display has two lines (e.g. 2x20)
; CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
; CONSTANT LCDSPEED = 0x01 ; affecting LCD_EN 'clock': high speed PIC clock
; CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
; CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
;
; To maintain proper timing (setup time, wait time, LCD initialization),

http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm (2 of 9)12/02/2008 17:12:48


http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm

; adjust the parameter LCDWAIT as follows:


; if Tosc <= 5 MHz: LCDWAIT = 0x01
; else LCDWAIT = floor(0.25 * clock frequency[MHz])
; To comply with manufacturer specifications (Enable High Time >= 450 ns),
; add a "nop" to the procedure LCDclk, if using this module with clock
; rates higher than 9 MHz. Therefore, define in your main program:
; CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
; CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; CONSTANT BASE = 0x0C Base address of user file registers
;
; LCDtris equ TRISA ; LCD data on low nibble of portA
; LCDport equ PORTA
; #define LCD_ENtris TRISB,0x01 ; EN on portB,1
; #define LCD_EN PORTB,0x01
; #define LCD_RStris TRISB,0x02 ; RS on portB,2
; #define LCD_RS PORTB,0x02
; #define LCD_RWtris TRISB,0x03 ; RW on portB,3
; #define LCD_RW PORTB,0x03
;
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+2 - BASE+3
;
;***************************************************************************
#DEFINE M_LCD_ID dummy

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF

;***** CONSTANT DECLARATION *****

IFNDEF LCDLINENUM ; use default value, if unspecified

http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm (3 of 9)12/02/2008 17:12:48


http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm

CONSTANT LCDLINENUM = 0x02 ; by default, 2 lines


ENDIF
IFNDEF LCDTYPE ; use default value, if unspecified
CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
;CONSTANT LCDTYPE = 0x01 ; EADIP204-4 (w/ KS0073)
ENDIF
IFNDEF LCDSPEED ; use default value, if unspecified
;CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
ENDIF
IFNDEF LCDWAIT ; use default value, if unspecified
CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
ENDIF
IFNDEF LCDCLRWAIT ; use default value, if unspecified
CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF LCDport
ERROR "Declare LCDport in MAIN PROGRAM"
ENDIF
IFNDEF LCDtris
ERROR "Declare LCDtris in MAIN PROGRAM"
ENDIF
IFNDEF LCD_EN
ERROR "Declare LCD_EN in MAIN PROGRAM"
ENDIF
IFNDEF LCD_ENtris
ERROR "Declare LCD_ENtris in MAIN PROGRAM"
ENDIF
IFNDEF LCD_RS
ERROR "Declare LCD_RS in MAIN PROGRAM"
ENDIF
IFNDEF LCD_RStris
ERROR "Declare LCD_RStris in MAIN PROGRAM"
ENDIF
IFNDEF LCD_RW
ERROR "Declare LCD_RW in MAIN PROGRAM"
ENDIF
IFNDEF LCD_RWtris
ERROR "Declare LCD_RWtris in MAIN PROGRAM"
ENDIF

http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm (4 of 9)12/02/2008 17:12:48


http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm

;***** REGISTER DECLARATION *****

IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

LCDbuf set BASE+d'2' ; LCD data buffer


LCDtemp set BASE+d'3' ; LCD temporary register

;***** LCD COMMANDS *****

;*** Standard LCD COMMANDS for INIT *** ( HI-NIBBLE only )


; for 4 bit mode: send only one nibble as high-nibble [DB7:DB4]
CONSTANT LCDEM8 = b'0011' ; entry mode set: 8 bit mode, 2 lines
CONSTANT LCDEM4 = b'0010' ; entry mode set: 4 bit mode, 2 lines
CONSTANT LCDDZ = b'1000' ; set Display Data Ram Address to zero

;*** Standard LCD COMMANDS *** ( HI- / LO-NIBBLE )


; USE THESE COMMANDS BELOW AS FOLLOW: "LCDcmd LCDCLR"
CONSTANT LCDCLR = b'00000001' ; clear display: resets address counter & cursor
CONSTANT LCDCH = b'00000010' ; cursor home
CONSTANT LCDCR = b'00000110' ; entry mode set: cursor moves right, display auto-shift off
CONSTANT LCDCL = b'00000100' ; entry mode set: cursor moves left, display auto-shift off
CONSTANT LCDCONT = b'00001100' ; display control: display on, cursor off, blinking off
CONSTANT LCDMCL = b'00010000' ; cursor/disp control: move cursor left
CONSTANT LCDMCR = b'00010100' ; cursor/disp control: move cursor right
CONSTANT LCDSL = b'00011000' ; cursor/disp control: shift display content left
CONSTANT LCDSR = b'00011100' ; cursor/disp control: shift display content right
CONSTANT LCD2L = b'00101000' ; function set: 4 bit mode, 2 lines, 5x7 dots
IF (LCDLINENUM == 0x2)
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (2xXX LCD)
CONSTANT LCDL2 = b'11000000' ; DDRAM address: 0x40, selects line 2 (2xXX LCD)
CONSTANT LCDL3 = b'10010100' ; (DDRAM address: 0x14, fallback)
CONSTANT LCDL4 = b'11010100' ; (DDRAM address: 0x54, fallback)
ELSE
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (4xXX LCD)
CONSTANT LCDL2 = b'10010100' ; DDRAM address: 0x14, selects line 2 (4xXX LCD)
CONSTANT LCDL3 = b'11000000' ; DDRAM address: 0x40, selects line 3 (4xXX LCD)
CONSTANT LCDL4 = b'11010100' ; DDRAM address: 0x54, selects line 4 (4xXX LCD)
ENDIF
; special configuration for EA DIP204-4
CONSTANT LCDEXT = b'00001001' ; extended function set EA DIP204-4

http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm (5 of 9)12/02/2008 17:12:48


http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm

CONSTANT LCD2L_A = b'00101100' ; enter ext. function set: 4 bit mode, 2 lines, 5x7 dots
CONSTANT LCD2L_B = b'00101000' ; exit ext. function set: 4 bit mode, 2 lines, 5x7 dots

;***** MACROS *****

LCDinit macro
BANK1
bcf LCD_ENtris ; set command lines to output
bcf LCD_RStris
bcf LCD_RWtris
movlw b'11110000' ; data output on low nibble
andwf LCDtris,f
BANK0
bcf LCD_EN ; clear LCD clock line
bcf LCD_RW ; set write direction
bcf LCD_RS ; clear command/data line
clrLCDport ; reset LCD data lines
WAIT 4*LCDWAIT ; >= 4 ms @ 4 MHz

; LCD INITIALIZATION STARTS HERE


; start in 8 bit mode
movlw LCDEM8 ; send b'0011' on [DB7:DB4]
call LCDxmit ; start in 8 bit mode
call LCDclk ; That's while:
WAIT LCDWAIT ; On POWER UP, the LCD will initialize itself,
; but after a RESET of the microcontroller without
; POWER OFF, the 8 bit function mode will reboot
; the LCD to 4 bit mode safely.

movlw LCDDZ ; set DDRAM to zero


call LCDxmit
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

movlw LCDEM4 ; send b'0010' on [DB7:DB4]


call LCDxmit ; change to 4 bit mode
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

; now in 4 bit mode, sending two nibbles


IF LCDTYPE == 0x00
LCDcmd LCD2L ; function set: 4 bit mode, 2 lines, 5x7 dots
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off

http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm (6 of 9)12/02/2008 17:12:48


http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm

LCDcmd LCDCLR ; clear display, address counter to zero


WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
IF LCDTYPE == 0x01
; for LCD EA DIP204-4 (white chars, blue backlight)
LCDcmd LCD2L_A ; switch on extended function set
LCDcmd LCDEXT ; 4 lines
LCDcmd LCD2L_B ; switch off extended function set
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
ERROR "Unsupported parameter"
ENDIF
ENDIF
endm

LCDchar macro LCDarg ; write ASCII argument to LCD


movlw LCDarg
call LCDdata
endm

LCDw macro ; write content of w to LCD


call LCDdata
endm

LCDcmd macro LCDcommand ; write command to LCD


movlw LCDcommand
call LCDcomd
endm

LCDline macro line_num


IF (line_num == 1)
LCDcmd LCDL1 ; first line
ELSE
IF (line_num == 2)
LCDcmd LCDL2 ; second line
ELSE
IF (line_num == 3)
LCDcmd LCDL3 ; third line
ELSE
IF (line_num == 4)
LCDcmd LCDL4 ; fourth line

http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm (7 of 9)12/02/2008 17:12:48


http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm

ELSE
ERROR "Wrong line number specified in LCDline"
ENDIF
ENDIF
ENDIF
ENDIF
endm

LCD_DDAdr macro DDRamAddress


Local value = DDRamAddress | b'10000000' ; mask command
IF (DDRamAddress > 0x67)
ERROR "Wrong DD-RAM-Address specified in LCD_DDAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

clrLCDport macro ; clear/reset LCD data lines


movlw b'11110000' ; get mask
andwf LCDport,f ; clear data lines only
endm

;***** SUBROUTINES *****

; transmit only lower nibble of w


LCDxmit movwf LCDbuf ; store command/data nibble
; first, clear LCD data lines
clrLCDport
; second, move data out to LCD data lines
movfw LCDbuf ; get data
andlw b'00001111' ; extract only valid part
iorwf LCDport,f ; put to LCD data lines
RETURN

; transmit command to LCD


LCDcomd bcf LCD_RS ; select command registers
goto _LCD_wr

; transmit data to LCD


LCDdata bsf LCD_RS ; select data registers
_LCD_wr bcf LCD_RW ; set write direction
movwf LCDtemp ; store command/data to send

http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm (8 of 9)12/02/2008 17:12:48


http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm

; send hi-nibble
movfw LCDtemp ; get data
swapf LCDtemp,w ; swap hi- and lo-nibble, store in w
call LCDxmit ; transmit nibble
call LCDclk
; send lo-nibble
movfw LCDtemp ; get data
call LCDxmit ; transmit nibble
call LCDclk
; reset LCD controls
clrLCDport ; reset LCD data lines
bcf LCD_RS ; reset command/data register
;bcf LCD_RW ; reset to write direction
RETURN

; clocks LCD data/command


LCDclk WAIT LCDWAIT
bsf LCD_EN ; set LCD enable
; insert LCDSPEED x nops to comply with manufacturer
; specifications for clock rates above 9 MHz
VARIABLE CNT_V ; declare intermediate variable
CNT_V = LCDSPEED ; assign pre-defined constant
WHILE (CNT_V > 0x0) ; perform while loop to insert 'nops'
nop ; insert 'nop'
CNT_V -= 1 ; decrement
ENDW
bcf LCD_EN
WAIT LCDWAIT ; clocks LCD data/command
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcde.asm (9 of 9)12/02/2008 17:12:48


http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm

;***************************************************************************
;
; LCD INTERFACE V4.03e for PIC 16XXX
; ==================================
;
; written by Peter Luethi, 09.04.2004, Urdorf, Switzerland
; http://www.electronic-engineering.ch
; last update: 17.08.2004
;
; V4.03e: Added new parameters: (17.08.2004)
; - LCDLINENUM: (default: 0x2) # of LCD lines (affects LCDL2/3)
; - LCDTYPE: type of LCD/controller:
; - 0x0: (default) standard LCD (w/ HD44780)
; - 0x1: EA DIP204-4 (w/ KS0073, white chars, blue bg)
; - LCDBUSYWAIT: (default: 0x18) wait before LCD busy flag
; is available
; V4.02e: Fixed high-speed timing issue in busy flag part
; (24.06.2004)
; V4.01e: Changed LCDinit and constants (06.06.2004)
; V4.00e: Initial release (10.04.2004)
; Added flag LCDcflag, removed register LCDtemp2
; Reads busy flag of LCD, minimum waittime.
; 4.00 - 20.00 MHz clock
; Clock independent portable code!
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16X84, 16F7X
; Clock: 4.00 MHz XT - 20.00 MHz HS Mode (tested)
; Throughput: 1 - 5 MIPS
; LCD Transmission Mode: 4 bit on high nibble of LCD port
; (MSB D7-D4)

http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm (1 of 11)12/02/2008 17:12:51


http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm

; LCD Connections: 7 wires (4 data, 3 command),


; LCD data on low nibble of any port,
; LCD command on any port bits
; Total: 10 wires
; (4 data, 3 command, 1 Vdd, 1 GND, 1 contrast)
;
;
; ADDITIONAL PROGRAM CODE:
; ========================
; procedure CheckBusy
; procedure LCDbusyloop
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16F84 @ 4 MHz, tested on 16F84 @ 10 MHz
; and 16C74A/16F77 @ 20 MHz, but executeable on all PIC 16XXX.
; Program handles all aspects of setup and display on a dot matrix LCD
; display. Routines are provided to allow display of characters,
; display shifting and clearing, cursor setup, cursor positioning and
; line change.
;
; Program calls module m_wait.asm with implemented standard delay:
; "WAIT 0x01" is equal to 1 Unit == 1.04 ms (@ 4 MHz)
; The assigned standard prescaler for TMR0 is "PRESCstd = b'00000001'"
;
; Call of implemented procedures with:
; "LCDinit" (macro)
; "LCDchar 'c'" display ascii character
; "LCDw" display char in working register
; "LCDcmd xxx" e.g. "LCDcmd LCDCLR"
; "LCD_DDAdr xxx" set cursor to explicit address
; --> REFER TO LCD DOCUMENTATION
; "LCDline x" set cursor to the beginning of line 1/2
;
; To display decimal-values, please include the following binary to
; decimal conversion modules:
; for 8 Bit: m_lcdv08.asm
; for 16 Bit: m_lcdv16.asm
;
;
; DEFAULT TIMING PARAMETERS:
; ==========================

http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm (2 of 11)12/02/2008 17:12:51


http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm

; CONSTANT LCDLINENUM = 0x02 ; LCD display has two lines (e.g. 2x20)
; CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
; CONSTANT LCDSPEED = 0x01 ; affecting LCD_EN 'clock': high speed PIC clock
; CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
; CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
; CONSTANT LCDBUSYWAIT = 0x18 ; wait before LCD busy flag is available
;
; To maintain proper timing (setup time, wait time, LCD initialization),
; adjust the parameter LCDWAIT as follows:
; if Tosc <= 5 MHz: LCDWAIT = 0x01
; else LCDWAIT = floor(0.25 * clock frequency[MHz])
; To comply with manufacturer specifications (Enable High Time >= 450 ns),
; add a "nop" to the procedure LCDclk, if using this module with clock
; rates higher than 9 MHz. Therefore, define in your main program:
; CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
; CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; CONSTANT BASE = 0x0C Base address of user file registers
; #define LCDbusy FLAGreg,0x06 ; LCD busy flag declared within flag register
; #define LCDcflag FLAGreg,0x07 ; LCD command/data flag
;
; LCDtris equ TRISA ; LCD data on low nibble of portA
; LCDport equ PORTA
; #define LCD_ENtris TRISB,0x01 ; EN on portB,1
; #define LCD_EN PORTB,0x01
; #define LCD_RStris TRISB,0x02 ; RS on portB,2
; #define LCD_RS PORTB,0x02
; #define LCD_RWtris TRISB,0x03 ; RW on portB,3
; #define LCD_RW PORTB,0x03
;
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+2 - BASE+3
; 2 flags: LCDbusy, LCDcflag
;
;***************************************************************************
#DEFINE M_LCD_ID dummy

;***** INCLUDE FILES *****

http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm (3 of 11)12/02/2008 17:12:51


http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF

;***** CONSTANT DECLARATION *****

IFNDEF LCDLINENUM ; use default value, if unspecified


CONSTANT LCDLINENUM = 0x02 ; by default, 2 lines
ENDIF
IFNDEF LCDTYPE ; use default value, if unspecified
CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
;CONSTANT LCDTYPE = 0x01 ; EADIP204-4 (w/ KS0073)
ENDIF
IFNDEF LCDSPEED ; use default value, if unspecified
;CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
ENDIF
IFNDEF LCDWAIT ; use default value, if unspecified
CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
ENDIF
IFNDEF LCDCLRWAIT ; use default value, if unspecified
CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
ENDIF
IFNDEF LCDBUSYWAIT ; use default value, if unspecified
CONSTANT LCDBUSYWAIT = 0x18 ; wait before LCD busy flag is available
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF LCDport
ERROR "Declare LCDport in MAIN PROGRAM"
ENDIF
IFNDEF LCDtris
ERROR "Declare LCDtris in MAIN PROGRAM"
ENDIF
IFNDEF LCD_EN
ERROR "Declare LCD_EN in MAIN PROGRAM"
ENDIF
IFNDEF LCD_ENtris

http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm (4 of 11)12/02/2008 17:12:51


http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm

ERROR "Declare LCD_ENtris in MAIN PROGRAM"


ENDIF
IFNDEF LCD_RS
ERROR "Declare LCD_RS in MAIN PROGRAM"
ENDIF
IFNDEF LCD_RStris
ERROR "Declare LCD_RStris in MAIN PROGRAM"
ENDIF
IFNDEF LCD_RW
ERROR "Declare LCD_RW in MAIN PROGRAM"
ENDIF
IFNDEF LCD_RWtris
ERROR "Declare LCD_RWtris in MAIN PROGRAM"
ENDIF
IFNDEF LCDbusy
ERROR "#define LCDbusy FLAGreg,0x00 in MAIN PROGRAM"
ENDIF
IFNDEF LCDcflag
ERROR "#define LCDcflag FLAGreg,0x01 in MAIN PROGRAM"
ENDIF

; LCD data ports D4 - D7 == 0x00 - 0x03


D7 equ 0x03 ; LCD data line 7, for busy flag

;***** REGISTER DECLARATION *****

IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

LCDbuf set BASE+d'2' ; LCD data buffer


LCDtemp set BASE+d'3' ; LCD temporary register
LCDtemp2 set BASE+d'2' ; busy wait loop (re-use LCDbuf)

;***** LCD COMMANDS *****

;*** Standard LCD COMMANDS for INIT *** ( HI-NIBBLE only )


; for 4 bit mode: send only one nibble as high-nibble [DB7:DB4]
CONSTANT LCDEM8 = b'0011' ; entry mode set: 8 bit mode, 2 lines
CONSTANT LCDEM4 = b'0010' ; entry mode set: 4 bit mode, 2 lines
CONSTANT LCDDZ = b'1000' ; set Display Data Ram Address to zero

;*** Standard LCD COMMANDS *** ( HI- / LO-NIBBLE )

http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm (5 of 11)12/02/2008 17:12:51


http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm

; USE THESE COMMANDS BELOW AS FOLLOW: "LCDcmd LCDCLR"


CONSTANT LCDCLR = b'00000001' ; clear display: resets address counter & cursor
CONSTANT LCDCH = b'00000010' ; cursor home
CONSTANT LCDCR = b'00000110' ; entry mode set: cursor moves right, display auto-shift off
CONSTANT LCDCL = b'00000100' ; entry mode set: cursor moves left, display auto-shift off
CONSTANT LCDCONT = b'00001100' ; display control: display on, cursor off, blinking off
CONSTANT LCDMCL = b'00010000' ; cursor/disp control: move cursor left
CONSTANT LCDMCR = b'00010100' ; cursor/disp control: move cursor right
CONSTANT LCDSL = b'00011000' ; cursor/disp control: shift display content left
CONSTANT LCDSR = b'00011100' ; cursor/disp control: shift display content right
CONSTANT LCD2L = b'00101000' ; function set: 4 bit mode, 2 lines, 5x7 dots
IF (LCDLINENUM == 0x2)
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (2xXX LCD)
CONSTANT LCDL2 = b'11000000' ; DDRAM address: 0x40, selects line 2 (2xXX LCD)
CONSTANT LCDL3 = b'10010100' ; (DDRAM address: 0x14, fallback)
CONSTANT LCDL4 = b'11010100' ; (DDRAM address: 0x54, fallback)
ELSE
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (4xXX LCD)
CONSTANT LCDL2 = b'10010100' ; DDRAM address: 0x14, selects line 2 (4xXX LCD)
CONSTANT LCDL3 = b'11000000' ; DDRAM address: 0x40, selects line 3 (4xXX LCD)
CONSTANT LCDL4 = b'11010100' ; DDRAM address: 0x54, selects line 4 (4xXX LCD)
ENDIF
; special configuration for EA DIP204-4
CONSTANT LCDEXT = b'00001001' ; extended function set EA DIP204-4
CONSTANT LCD2L_A = b'00101100' ; enter ext. function set: 4 bit mode, 2 lines, 5x7 dots
CONSTANT LCD2L_B = b'00101000' ; exit ext. function set: 4 bit mode, 2 lines, 5x7 dots

;***** MACROS *****

LCDinit macro
BANK1
bcf LCD_ENtris ; set command lines to output
bcf LCD_RStris
bcf LCD_RWtris
movlw b'11110000' ; data output on low nibble
andwf LCDtris,f
BANK0
bcf LCD_EN ; clear LCD clock line
bcf LCD_RW ; set write direction
bcf LCD_RS ; clear command/data line
clrLCDport ; reset LCD data lines
WAIT 4*LCDWAIT ; >= 4 ms @ 4 MHz

http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm (6 of 11)12/02/2008 17:12:51


http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm

; LCD INITIALIZATION STARTS HERE


; start in 8 bit mode
movlw LCDEM8 ; send b'0011' on [DB7:DB4]
call LCDxmit ; start in 8 bit mode
call LCDclk ; That's while:
WAIT LCDWAIT ; On POWER UP, the LCD will initialize itself,
; but after a RESET of the microcontroller without
; POWER OFF, the 8 bit function mode will reboot
; the LCD to 4 bit mode safely.

movlw LCDDZ ; set DDRAM to zero


call LCDxmit
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

movlw LCDEM4 ; send b'0010' on [DB7:DB4]


call LCDxmit ; change to 4 bit mode
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

; now in 4 bit mode, sending two nibbles


IF LCDTYPE == 0x00
LCDcmd LCD2L ; function set: 4 bit mode, 2 lines, 5x7 dots
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
IF LCDTYPE == 0x01
; for LCD EA DIP204-4 (white chars, blue backlight)
LCDcmd LCD2L_A ; switch on extended function set
LCDcmd LCDEXT ; 4 lines
LCDcmd LCD2L_B ; switch off extended function set
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
ERROR "Unsupported parameter"
ENDIF
ENDIF
endm

LCDchar macro LCDarg ; write ASCII argument to LCD


movlw LCDarg

http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm (7 of 11)12/02/2008 17:12:51


http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm

call LCDdata
endm

LCDw macro ; write content of w to LCD


call LCDdata
endm

LCDcmd macro LCDcommand ; write command to LCD


movlw LCDcommand
call LCDcomd
endm

LCDline macro line_num


IF (line_num == 1)
LCDcmd LCDL1 ; first line
ELSE
IF (line_num == 2)
LCDcmd LCDL2 ; second line
ELSE
IF (line_num == 3)
LCDcmd LCDL3 ; third line
ELSE
IF (line_num == 4)
LCDcmd LCDL4 ; fourth line
ELSE
ERROR "Wrong line number specified in LCDline"
ENDIF
ENDIF
ENDIF
ENDIF
endm

LCD_DDAdr macro DDRamAddress


Local value = DDRamAddress | b'10000000' ; mask command
IF (DDRamAddress > 0x67)
ERROR "Wrong DD-RAM-Address specified in LCD_DDAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

LCD_CGAdr macro CGRamAddress

http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm (8 of 11)12/02/2008 17:12:51


http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm

Local value = CGRamAddress | b'01000000' ; mask command


IF (CGRamAddress > b'00111111')
ERROR "Wrong CG-RAM-Address specified in LCD_CGAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

clrLCDport macro ; clear/reset LCD data lines


movlw b'11110000' ; get mask
andwf LCDport,f ; clear data lines only
endm

;***** SUBROUTINES *****

; transmit only lower nibble of w


LCDxmit movwf LCDbuf ; store command/data nibble
; first, clear LCD data lines
clrLCDport
; second, move data out to LCD data lines
movfw LCDbuf ; get data
andlw b'00001111' ; extract only valid part
iorwf LCDport,f ; put to LCD data lines
RETURN

; transmit command to LCD


LCDcomd bsf LCDcflag ; set command
goto _LCD_wr

; transmit data to LCD


LCDdata bcf LCDcflag ; set data
_LCD_wr movwf LCDtemp ; store command/data to send
call CheckBusy ; check, if ready for next character
btfss LCDcflag ; skip if LCD command has been sent
bsf LCD_RS ; select data registers
; send high nibble
movfw LCDtemp ; get data
swapf LCDtemp,w ; swap high and low nibble, store in w
call LCDxmit ; transmit nibble
call LCDclk
; send low nibble
movfw LCDtemp ; get data

http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm (9 of 11)12/02/2008 17:12:51


http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm

call LCDxmit ; transmit nibble


call LCDclk
; reset LCD controls
clrLCDport ; reset LCD data lines
bcf LCD_RS ; reset command/data register
bcf LCD_RW ; reset to write direction
RETURN

; clocks LCD data/command


LCDclk bsf LCD_EN ; set LCD enable
; insert LCDSPEED x nops to comply with manufacturer
; specifications for clock rates above 9 MHz
VARIABLE CNT_V ; declare intermediate variable
CNT_V = LCDSPEED ; assign pre-defined constant
WHILE (CNT_V > 0x0) ; perform while loop to insert 'nops'
nop ; insert 'nop'
CNT_V -= 1 ; decrement
ENDW
bcf LCD_EN
RETURN

; busy wait loop, makes busy flag signalling safe


LCDbusyloop
movlw LCDBUSYWAIT ; pre-defined constant
movwf LCDtemp2
_LCDbusyloop
decfsz LCDtemp2,f
goto _LCDbusyloop ; busy loop
RETURN

; routine to poll busy flag from LCD


CheckBusy
bcf LCD_RS ; select command registers
bsf LCDbusy ; init LCD busy flag
BANK1
movlw b'00001111'
iorwf LCDtris,f ; set corresponding ports to inputs
BANK0
bsf LCD_RW ; apply read direction
nop ; additional safety
_LCDbusy bsf LCD_EN ; set enable
; the following busy wait code makes busy flag signalling safe
call LCDbusyloop ; (timing relaxation)

http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm (10 of 11)12/02/2008 17:12:51


http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm

; poll now LCD busy flag


btfss LCDport,D7 ; check busy flag, skip if busy
bcf LCDbusy ; set register flag if not busy
bcf LCD_EN
; the following busy wait code makes busy flag signalling safe
call LCDbusyloop ; (timing relaxation)
; get low nibble, ignore it
call LCDclk
btfsc LCDbusy ; skip if register flag is not yet cleared
goto _LCDbusy
bcf LCD_RW ; re-apply write direction
BANK1
movlw b'11110000'
andwf LCDtris,f ; set ports to output again
BANK0
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcde_bf.asm (11 of 11)12/02/2008 17:12:51


http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm

;***************************************************************************
;
; LCD INTERFACE V4.23e for PIC 16XXX
; ==================================
;
; written by Peter Luethi, 09.04.2004, Urdorf, Switzerland
; http://www.electronic-engineering.ch
; last update: 17.08.2004
;
; V4.23e: Added new parameters: (17.08.2004)
; - LCDLINENUM: (default: 0x2) # of LCD lines (affects LCDL2/3)
; - LCDTYPE: type of LCD/controller:
; - 0x0: (default) standard LCD (w/ HD44780)
; - 0x1: EA DIP204-4 (w/ KS0073, white chars, blue bg)
; - LCDBUSYWAIT: (default: 0x18) wait before LCD busy flag
; is available
; V4.22e: Fixed high-speed timing issue in busy flag part
; (24.06.2004)
; V4.21e: Changed LCDinit and constants (06.06.2004)
; V4.20e: Initial release (10.04.2004)
; Reads busy flag of LCD, minimum waittime,
; 4.00 - 20.00 MHz clock
; Clock independent portable code!
; Ability to define your own characters for the LCD
; ( => see macro LCDspecialChars )
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16X84, 16F7X, 16F87X
; Clock: 4.00 MHz XT - 20.00 MHz HS Mode (tested)
; Throughput: 1 - 5 MIPS
; LCD Transmission Mode: 4 bit on high nibble of LCD port
; (MSB D7-D4)
; LCD Connections: 7 wires (4 data, 3 command),
; LCD data on low nibble of any port,

http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm (1 of 11)12/02/2008 17:12:52


http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm

; LCD command on any port bits


; Total: 10 wires
; (4 data, 3 command, 1 Vdd, 1 GND, 1 contrast)
;
;
; ADDITIONAL PROGRAM CODE:
; ========================
; procedure CheckBusy
; macro LCD_CGAdr
; macro LCDspecialChars
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16F84 @ 4 MHz, tested on 16F84 @ 10 MHz
; and 16C74A/16F77 @ 20 MHz, but executeable on all PIC 16XXX.
; Program handles all aspects of setup and display on a dot matrix LCD
; display. Routines are provided to allow display of characters,
; display shifting and clearing, cursor setup, cursor positioning and
; line change.
;
; Program calls module m_wait.asm with implemented standard delay:
; "WAIT 0x01" is equal to 1 Unit == 1.04 ms (@ 4 MHz)
; The assigned standard prescaler for TMR0 is "PRESCstd = b'00000001'"
;
; Call of implemented procedures with:
; "LCDinit" (macro)
; "LCDchar 'c'" display ascii character
; "LCDw" display char in working register
; "LCDcmd xxx" e.g. "LCDcmd LCDCLR"
; "LCD_DDAdr xxx" set cursor to explicit address
; --> REFER TO LCD DOCUMENTATION
; "LCDline x" set cursor to the beginning of line 1/2
;
; To display decimal-values, please include the following binary to
; decimal conversion modules:
; for 8 Bit: m_lcdv08.asm
; for 16 Bit: m_lcdv16.asm
;
;
; DEFAULT TIMING PARAMETERS:
; ==========================
; CONSTANT LCDLINENUM = 0x02 ; LCD display has two lines (e.g. 2x20)
; CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
; CONSTANT LCDSPEED = 0x01 ; affecting LCD_EN 'clock': high speed PIC clock
; CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz

http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm (2 of 11)12/02/2008 17:12:52


http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm

; CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
; CONSTANT LCDBUSYWAIT = 0x18 ; wait before LCD busy flag is available
;
; To maintain proper timing (setup time, wait time, LCD initialization),
; adjust the parameter LCDWAIT as follows:
; if Tosc <= 5 MHz: LCDWAIT = 0x01
; else LCDWAIT = floor(0.25 * clock frequency[MHz])
; To comply with manufacturer specifications (Enable High Time >= 450 ns),
; add a "nop" to the procedure LCDclk, if using this module with clock
; rates higher than 9 MHz. Therefore, define in your main program:
; CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
; CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; CONSTANT BASE = 0x0C Base address of user file registers
; #define LCDbusy FLAGreg,0x06 ; LCD busy flag declared within flag register
; #define LCDcflag FLAGreg,0x07 ; LCD command/data flag
;
; LCDtris equ TRISA ; LCD data on low nibble of portA
; LCDport equ PORTA
; #define LCD_ENtris TRISB,0x01 ; EN on portB,1
; #define LCD_EN PORTB,0x01
; #define LCD_RStris TRISB,0x02 ; RS on portB,2
; #define LCD_RS PORTB,0x02
; #define LCD_RWtris TRISB,0x03 ; RW on portB,3
; #define LCD_RW PORTB,0x03
;
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+2 - BASE+3
; 2 flags: LCDbusy, LCDcflag
; needs itself 3 stack levels
;
;***************************************************************************
#DEFINE M_LCD_ID dummy

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"

http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm (3 of 11)12/02/2008 17:12:52


http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm

ENDIF

;***** CONSTANT DECLARATION *****

IFNDEF LCDLINENUM ; use default value, if unspecified


CONSTANT LCDLINENUM = 0x02 ; by default, 2 lines
ENDIF
IFNDEF LCDTYPE ; use default value, if unspecified
CONSTANT LCDTYPE = 0x00 ; standard HD44780 LCD
;CONSTANT LCDTYPE = 0x01 ; EADIP204-4 (w/ KS0073)
ENDIF
IFNDEF LCDSPEED ; use default value, if unspecified
;CONSTANT LCDSPEED = 0x00 ; clk in [0..9] MHz
CONSTANT LCDSPEED = 0x01 ; clk in [9..20] MHz, default
ENDIF
IFNDEF LCDWAIT ; use default value, if unspecified
CONSTANT LCDWAIT = 0x01 ; for Tosc <= 5 MHz
ENDIF
IFNDEF LCDCLRWAIT ; use default value, if unspecified
CONSTANT LCDCLRWAIT = 0x08 ; wait after LCDCLR until LCD is ready again
ENDIF
IFNDEF LCDBUSYWAIT ; use default value, if unspecified
CONSTANT LCDBUSYWAIT = 0x18 ; wait before LCD busy flag is available
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF LCDport
ERROR "Declare LCDport in MAIN PROGRAM"
ENDIF
IFNDEF LCDtris
ERROR "Declare LCDtris in MAIN PROGRAM"
ENDIF
IFNDEF LCD_EN
ERROR "Declare LCD_EN in MAIN PROGRAM"
ENDIF
IFNDEF LCD_ENtris
ERROR "Declare LCD_ENtris in MAIN PROGRAM"
ENDIF
IFNDEF LCD_RS
ERROR "Declare LCD_RS in MAIN PROGRAM"
ENDIF
IFNDEF LCD_RStris
ERROR "Declare LCD_RStris in MAIN PROGRAM"
ENDIF
IFNDEF LCD_RW

http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm (4 of 11)12/02/2008 17:12:52


http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm

ERROR "Declare LCD_RW in MAIN PROGRAM"


ENDIF
IFNDEF LCD_RWtris
ERROR "Declare LCD_RWtris in MAIN PROGRAM"
ENDIF
IFNDEF LCDbusy
ERROR "#define LCDbusy FLAGreg,0x00 in MAIN PROGRAM"
ENDIF
IFNDEF LCDcflag
ERROR "#define LCDcflag FLAGreg,0x01 in MAIN PROGRAM"
ENDIF

; LCD data ports D4 - D7 == 0x00 - 0x03


D7 equ 0x03 ; LCD data line 7, for busy flag

;***** REGISTER DECLARATION *****

IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

LCDbuf set BASE+d'2' ; LCD data buffer


LCDtemp set BASE+d'3' ; LCD temporary register
LCDtemp2 set BASE+d'2' ; busy wait loop (re-use LCDbuf)

;***** LCD COMMANDS *****

;*** Standard LCD COMMANDS for INIT *** ( HI-NIBBLE only )


; for 4 bit mode: send only one nibble as high-nibble [DB7:DB4]
CONSTANT LCDEM8 = b'0011' ; entry mode set: 8 bit mode, 2 lines
CONSTANT LCDEM4 = b'0010' ; entry mode set: 4 bit mode, 2 lines
CONSTANT LCDDZ = b'1000' ; set Display Data Ram Address to zero

;*** Standard LCD COMMANDS *** ( HI- / LO-NIBBLE )


; USE THESE COMMANDS BELOW AS FOLLOW: "LCDcmd LCDCLR"
CONSTANT LCDCLR = b'00000001' ; clear display: resets address counter & cursor
CONSTANT LCDCH = b'00000010' ; cursor home
CONSTANT LCDCR = b'00000110' ; entry mode set: cursor moves right, display auto-shift off
CONSTANT LCDCL = b'00000100' ; entry mode set: cursor moves left, display auto-shift off
CONSTANT LCDCONT = b'00001100' ; display control: display on, cursor off, blinking off
CONSTANT LCDMCL = b'00010000' ; cursor/disp control: move cursor left
CONSTANT LCDMCR = b'00010100' ; cursor/disp control: move cursor right
CONSTANT LCDSL = b'00011000' ; cursor/disp control: shift display content left
CONSTANT LCDSR = b'00011100' ; cursor/disp control: shift display content right
CONSTANT LCD2L = b'00101000' ; function set: 4 bit mode, 2 lines, 5x7 dots

http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm (5 of 11)12/02/2008 17:12:52


http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm

IF (LCDLINENUM == 0x2)
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (2xXX LCD)
CONSTANT LCDL2 = b'11000000' ; DDRAM address: 0x40, selects line 2 (2xXX LCD)
CONSTANT LCDL3 = b'10010100' ; (DDRAM address: 0x14, fallback)
CONSTANT LCDL4 = b'11010100' ; (DDRAM address: 0x54, fallback)
ELSE
CONSTANT LCDL1 = b'10000000' ; DDRAM address: 0x00, selects line 1 (4xXX LCD)
CONSTANT LCDL2 = b'10010100' ; DDRAM address: 0x14, selects line 2 (4xXX LCD)
CONSTANT LCDL3 = b'11000000' ; DDRAM address: 0x40, selects line 3 (4xXX LCD)
CONSTANT LCDL4 = b'11010100' ; DDRAM address: 0x54, selects line 4 (4xXX LCD)
ENDIF
; special configuration for EA DIP204-4
CONSTANT LCDEXT = b'00001001' ; extended function set EA DIP204-4
CONSTANT LCD2L_A = b'00101100' ; enter ext. function set: 4 bit mode, 2 lines, 5x7 dots
CONSTANT LCD2L_B = b'00101000' ; exit ext. function set: 4 bit mode, 2 lines, 5x7 dots

;***** MACROS *****

LCDinit macro
BANK1
bcf LCD_ENtris ; set command lines to output
bcf LCD_RStris
bcf LCD_RWtris
movlw b'11110000' ; data output on low nibble
andwf LCDtris,f
BANK0
bcf LCD_EN ; clear LCD clock line
bcf LCD_RW ; set write direction
bcf LCD_RS ; clear command/data line
clrLCDport ; reset LCD data lines
WAIT 4*LCDWAIT ; >= 4 ms @ 4 MHz

; LCD INITIALIZATION STARTS HERE


; start in 8 bit mode
movlw LCDEM8 ; send b'0011' on [DB7:DB4]
call LCDxmit ; start in 8 bit mode
call LCDclk ; That's while:
WAIT LCDWAIT ; On POWER UP, the LCD will initialize itself,
; but after a RESET of the microcontroller without
; POWER OFF, the 8 bit function mode will reboot
; the LCD to 4 bit mode safely.

movlw LCDDZ ; set DDRAM to zero


call LCDxmit
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm (6 of 11)12/02/2008 17:12:52


http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm

movlw LCDEM4 ; send b'0010' on [DB7:DB4]


call LCDxmit ; change to 4 bit mode
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz

; now in 4 bit mode, sending two nibbles


IF LCDTYPE == 0x00
LCDcmd LCD2L ; function set: 4 bit mode, 2 lines, 5x7 dots
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
IF LCDTYPE == 0x01
; for LCD EA DIP204-4 (white chars, blue backlight)
LCDcmd LCD2L_A ; switch on extended function set
LCDcmd LCDEXT ; 4 lines
LCDcmd LCD2L_B ; switch off extended function set
LCDcmd LCDCONT ; display control: display on, cursor off, blinking off
LCDcmd LCDCLR ; clear display, address counter to zero
WAIT LCDCLRWAIT ; wait after LCDCLR until LCD is ready again
ELSE
ERROR "Unsupported parameter"
ENDIF
ENDIF
LCDspecialChars ; insert special character setup macro
endm

LCDspecialChars macro ; max. 8 self-defined chars


; *** first self-defined character "Delta" at position 0x00 ***
; *** call by "LCDchar 0x00" ***
LCD_CGAdr 0x00 ; send CGRamAddress
LCDchar b'00000110' ; write data to CGRamAddress
LCD_CGAdr 0x01
LCDchar b'00001000'
LCD_CGAdr 0x02
LCDchar b'00000100'
LCD_CGAdr 0x03
LCDchar b'00001010'
LCD_CGAdr 0x04
LCDchar b'00010001'
LCD_CGAdr 0x05
LCDchar b'00010001'
LCD_CGAdr 0x06
LCDchar b'00001110'
LCD_CGAdr 0x07

http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm (7 of 11)12/02/2008 17:12:52


http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm

LCDchar b'00000000'

; *** second self-defined character "Big Omega" at position 0x01 ***


; *** call by "LCDchar 0x01" ***
LCD_CGAdr 0x08 ; send CGRamAddress
LCDchar b'00001110' ; write data to CGRamAddress
LCD_CGAdr 0x09
LCDchar b'00010001'
LCD_CGAdr 0x0A
LCDchar b'00010001'
LCD_CGAdr 0x0B
LCDchar b'00010001'
LCD_CGAdr 0x0C
LCDchar b'00010001'
LCD_CGAdr 0x0D
LCDchar b'00001010'
LCD_CGAdr 0x0E
LCDchar b'00011011'
LCD_CGAdr 0x0F
LCDchar b'00000000'

LCD_DDAdr 0x00 ; reset DDRam for proper function


endm

LCDchar macro LCDarg ; write ASCII argument to LCD


movlw LCDarg
call LCDdata
endm

LCDw macro ; write content of w to LCD


call LCDdata
endm

LCDcmd macro LCDcommand ; write command to LCD


movlw LCDcommand
call LCDcomd
endm

LCDline macro line_num


IF (line_num == 1)
LCDcmd LCDL1 ; first line
ELSE
IF (line_num == 2)
LCDcmd LCDL2 ; second line
ELSE
IF (line_num == 3)

http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm (8 of 11)12/02/2008 17:12:52


http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm

LCDcmd LCDL3 ; third line


ELSE
IF (line_num == 4)
LCDcmd LCDL4 ; fourth line
ELSE
ERROR "Wrong line number specified in LCDline"
ENDIF
ENDIF
ENDIF
ENDIF
endm

LCD_DDAdr macro DDRamAddress


Local value = DDRamAddress | b'10000000' ; mask command
IF ((DDRamAddress > 0x67 && LCDTYPE == 0x0) || (DDRamAddress > 0x73 && LCDTYPE == 0x1))
ERROR "Wrong DD-RAM-Address specified in LCD_DDAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

LCD_CGAdr macro CGRamAddress


Local value = CGRamAddress | b'01000000' ; mask command
IF (CGRamAddress > b'00111111')
ERROR "Wrong CG-RAM-Address specified in LCD_CGAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

clrLCDport macro ; clear/reset LCD data lines


movlw b'11110000' ; get mask
andwf LCDport,f ; clear data lines only
endm

;***** SUBROUTINES *****

; transmit only lower nibble of w


LCDxmit movwf LCDbuf ; store command/data nibble
; first, clear LCD data lines
clrLCDport
; second, move data out to LCD data lines
movfw LCDbuf ; get data
andlw b'00001111' ; extract only valid part

http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm (9 of 11)12/02/2008 17:12:52


http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm

iorwf LCDport,f ; put to LCD data lines


RETURN

; transmit command to LCD


LCDcomd bsf LCDcflag ; set command
goto _LCD_wr

; transmit data to LCD


LCDdata bcf LCDcflag ; set data
_LCD_wr movwf LCDtemp ; store command/data to send
call CheckBusy ; check, if ready for next character
btfss LCDcflag ; skip if LCD command has been sent
bsf LCD_RS ; select data registers
; send high nibble
movfw LCDtemp ; get data
swapf LCDtemp,w ; swap high and low nibble, store in w
call LCDxmit ; transmit nibble
call LCDclk
; send low nibble
movfw LCDtemp ; get data
call LCDxmit ; transmit nibble
call LCDclk
; reset LCD controls
clrLCDport ; reset LCD data lines
bcf LCD_RS ; reset command/data register
bcf LCD_RW ; reset to write direction
RETURN

; clocks LCD data/command


LCDclk bsf LCD_EN ; set LCD enable
; insert LCDSPEED x nops to comply with manufacturer
; specifications for clock rates above 9 MHz
VARIABLE CNT_V ; declare intermediate variable
CNT_V = LCDSPEED ; assign pre-defined constant
WHILE (CNT_V > 0x0) ; perform while loop to insert 'nops'
nop ; insert 'nop'
CNT_V -= 1 ; decrement
ENDW
bcf LCD_EN
RETURN

; busy wait loop, makes busy flag signalling safe


LCDbusyloop
movlw LCDBUSYWAIT ; pre-defined constant
movwf LCDtemp2
_LCDbusyloop

http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm (10 of 11)12/02/2008 17:12:52


http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm

decfsz LCDtemp2,f
goto _LCDbusyloop ; busy loop
RETURN

; routine to poll busy flag from LCD


CheckBusy
bcf LCD_RS ; select command registers
bsf LCDbusy ; init LCD busy flag
BANK1
movlw b'00001111'
iorwf LCDtris,f ; set corresponding ports to inputs
BANK0
bsf LCD_RW ; apply read direction
nop ; additional safety
_LCDbusy bsf LCD_EN ; set enable
; the following busy wait code makes busy flag signalling safe
call LCDbusyloop ; (timing relaxation)
; poll now LCD busy flag
btfss LCDport,D7 ; check busy flag, skip if busy
bcf LCDbusy ; set register flag if not busy
bcf LCD_EN
; the following busy wait code makes busy flag signalling safe
call LCDbusyloop ; (timing relaxation)
; get low nibble, ignore it
call LCDclk
btfsc LCDbusy ; skip if register flag is not yet cleared
goto _LCDbusy
bcf LCD_RW ; re-apply write direction
BANK1
movlw b'11110000'
andwf LCDtris,f ; set ports to output again
BANK0
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcdexbf.asm (11 of 11)12/02/2008 17:12:52


http://www.trash.net/~luethi/microchip/modules/source/m_lcdv08.asm

;***************************************************************************
;
; BINARY to DECIMAL CONVERSION for LCD Display for PIC 16XXX V1.02
; ================================================================
;
; written by Peter Luethi, 18.01.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 20.08.2004
;
; V1.02: Changed labels such as to be able to use both, m_lcdv08.asm
; and m_lcdv16.asm simultaneously (24.06.2004)
; V1.01: Replaced register with #define statement for flag
; (16.02.2003)
; V1.00: Initial release (18.01.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16XXX
; Decimal Range: 0 - 255 unsigned
; Binary Range: 8 Bit unsigned
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16C84, but executeable on all PICs.
; Evaluates from 8 bit Binary Data in LO the equivalent
; decimal output for the LCD-Display. Preceeding zeros are
; not displayed.
;
; Call of implemented procedure with:
; "LCDval_08", value in LO
;

http://www.trash.net/~luethi/microchip/modules/source/m_lcdv08.asm (1 of 4)12/02/2008 17:12:53


http://www.trash.net/~luethi/microchip/modules/source/m_lcdv08.asm

; LO is not altered or cleared during operation and is


; still valid after termination of this routine.
; During the whole routine, LO_TEMP, BCflag must NOT be used
; by other routines ! ========
; TEMP1 - TEMP2 can be used by the LCD routine during conversion
; (call of LCDw), because they will be re-defined again.
;
;
; DECLARATIONS needed in MAIN PROGRAM :
; =====================================
; CONSTANT BASE = 0x0C ; Base address of user file registers
; LO equ BASE+?
; LO_TEMP set BASE+?
; #define BCflag <reg_name>,0x00 ; blank checker for preceeding zeros
; ; <reg_name> can be any register, containing also
; ; other flags
;
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+0 - BASE+1 (temporary registers)
; 2 registers: LO, LO_TEMP
; 1 flag: BCflag
; needs itself 2 stack levels, but LCDw needs some more
;
;***************************************************************************

;***** INCLUDE FILES *****

IFNDEF M_LCD_ID
ERROR "Missing include file: m_lcd.asm or similar"
ENDIF

;***** REGISTER DECLARATION *****

IFNDEF BASE
ERROR "ModuleError: Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
IFNDEF LO
ERROR "ModuleError: Declare LO in MAIN PROGRAM"
ENDIF
IFNDEF LO_TEMP
ERROR "ModuleError: Declare LO_TEMP in MAIN PROGRAM"

http://www.trash.net/~luethi/microchip/modules/source/m_lcdv08.asm (2 of 4)12/02/2008 17:12:53


http://www.trash.net/~luethi/microchip/modules/source/m_lcdv08.asm

ENDIF
IFNDEF BCflag
ERROR "ModuleError: #define BCflag FLAGreg,0x05 (Blank checker) in MAIN PROGRAM"
ENDIF

; *** Universal Temporary Register ***


TEMP1 set BASE ; Counter
TEMP2 set BASE+1 ; Sub-LO

;***** MACROS *****

LCDval_08 macro
call LCDval08
endm

;***** SUB-ROUTINES *****

LCDval08
movfw LO
movwf LO_TEMP ; LO -> LO_TEMP
bcf BCflag ; blank checker for preceeding zeros

movlw d'100' ; check amount of 100s


movwf TEMP2 ; ==> Decimal Range 0 - 255 <=> 8 bit
call _VALcnv08 ; call conversion sub-routine
LCDw ; call LCD sub-routine with value stored in w

movlw d'10' ; check amount of 10s


movwf TEMP2
call _VALcnv08 ; call conversion sub-routine
LCDw ; call LCD sub-routine with value stored in w

movlw d'1' ; check amount of 1s


movwf TEMP2
bsf BCflag ; remove blank checker in case of zero
call _VALcnv08 ; call conversion sub-routine
LCDw ; call LCD sub-routine with value stored in w
RETURN

_VALcnv08
clrf TEMP1 ; counter
movfw TEMP2 ; decrement-value
_V08_1 subwf LO_TEMP,0 ; TEST: LO_TEMP-TEMP2 >= 0 ?

http://www.trash.net/~luethi/microchip/modules/source/m_lcdv08.asm (3 of 4)12/02/2008 17:12:53


http://www.trash.net/~luethi/microchip/modules/source/m_lcdv08.asm

skpc ; skip, if true


goto _V08_LCD ; result negativ, exit
incf TEMP1,1 ; count
movfw TEMP2 ; decrement-value
subwf LO_TEMP,1 ; STORE: LO_TEMP = LO_TEMP - TEMP2
bsf BCflag ; invalidate flag
goto _V08_1 ; repeat
_V08_LCD
movlw '0' ; writes Number to LCD
addwf TEMP1,0 ; '0' is ascii offset, add counter
btfss BCflag ; check flag
movlw ' ' ; clear preceeding zeros
; return with data in w
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcdv08.asm (4 of 4)12/02/2008 17:12:53


http://www.trash.net/~luethi/microchip/modules/source/m_lcdv16.asm

;***************************************************************************
;
; BINARY to DECIMAL CONVERSION for LCD-Display for PIC 16XXX V1.02
; ================================================================
;
; written by Peter Luethi, 21.01.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 20.08.2004
;
; V1.02: Changed labels such as to be able to use both, m_lcdv08.asm
; and m_lcdv16.asm simultaneously (24.06.2004)
; V1.01: Replaced register with #define statement for flag
; (16.02.2003)
; V1.00: Initial release (21.01.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16XXX
; Decimal Range: 0 - 65'535 unsigned
; Binary Range: 16 Bit unsigned
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16C84, but executeable on all PICs.
; Evaluates from 16 bit Binary Data in HI,LO the equivalent
; decimal output for the LCD-Display. Preceeding zeros are
; not displayed.
;
; Call of implemented procedure with:
; "LCDval_16", value in HI & LO
;

http://www.trash.net/~luethi/microchip/modules/source/m_lcdv16.asm (1 of 5)12/02/2008 17:12:53


http://www.trash.net/~luethi/microchip/modules/source/m_lcdv16.asm

; LO & HI are NOT altered or cleared during operation and are


; still valid after termination of this routine.
; During the whole routine, LO_TEMP, HI_TEMP & BCflag must NOT
; be used by other routines ! ========
; TEMP1 - TEMP3 can be used by the LCD routine during conversion
; (call of LCDw), because they will be re-defined again.
;
;
; DECLARATIONS needed in MAIN PROGRAM :
; =====================================
; CONSTANT BASE = 0x0C ; Base address of user file registers
; LO equ BASE+?
; HI equ BASE+?
; LO_TEMP set BASE+?
; HI_TEMP set BASE+?
; #define BCflag <reg_name>,0x00 ; blank checker for preceeding zeros
; ; <reg_name> can be any register, containing also
; ; other flags
;
;
; REQUIRED MEMORY:
; ================
; 3 registers: @ BASE+0 - BASE+2 (temporary registers)
; 4 registers: LO, LO_TEMP, HI, HI_TEMP
; 1 flag: BCflag
; needs itself 2 stack levels, but LCDw needs some more
;
;***************************************************************************

;***** INCLUDE FILES *****

IFNDEF M_LCD_ID
ERROR "Missing include file: m_lcd.asm or similar"
ENDIF

;***** REGISTER DECLARATION *****

IFNDEF BASE
ERROR "ModuleError: Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
IFNDEF LO
ERROR "ModuleError: Declare LO in MAIN PROGRAM"
ENDIF

http://www.trash.net/~luethi/microchip/modules/source/m_lcdv16.asm (2 of 5)12/02/2008 17:12:53


http://www.trash.net/~luethi/microchip/modules/source/m_lcdv16.asm

IFNDEF HI
ERROR "ModuleError: Declare HI in MAIN PROGRAM"
ENDIF
IFNDEF LO_TEMP
ERROR "ModuleError: Declare LO_TEMP in MAIN PROGRAM"
ENDIF
IFNDEF HI_TEMP
ERROR "ModuleError: Declare HI_TEMP in MAIN PROGRAM"
ENDIF
IFNDEF BCflag
ERROR "ModuleError: #define BCflag FLAGreg,0x05 (Blank checker) in MAIN PROGRAM"
ENDIF

; *** Universal Temporary Register ***


TEMP1 set BASE+d'0' ; counter
TEMP2 set BASE+d'1' ; Sub-LO
TEMP3 set BASE+d'2' ; Sub-HI

;***** MACROS *****

LCDval_16 macro
call LCDval16
endm

;***** SUB-ROUTINES *****

LCDval16
movfw LO ; LO -> LO_TEMP
movwf LO_TEMP
movfw HI ; HI -> HI_TEMP
movwf HI_TEMP
bcf BCflag ; Blank checker for preceeding zeros

movlw b'00010000' ; check amount of 10000s


movwf TEMP2 ; Sub-LO
movlw b'00100111'
movwf TEMP3 ; Sub-HI
call _VALcnv16 ; call conversion sub-routine
LCDw ; call LCD sub-routine with value stored in w

movlw b'11101000' ; check amount of 1000s


movwf TEMP2 ; Sub-LO
movlw b'00000011'

http://www.trash.net/~luethi/microchip/modules/source/m_lcdv16.asm (3 of 5)12/02/2008 17:12:53


http://www.trash.net/~luethi/microchip/modules/source/m_lcdv16.asm

movwf TEMP3 ; Sub-HI


call _VALcnv16 ; call conversion sub-routine
LCDw ; call LCD sub-routine with value stored in w

movlw b'01100100' ; check amount of 100s


movwf TEMP2 ; Sub-LO
clrf TEMP3 ; Sub-HI is zero
call _VALcnv16 ; call conversion sub-routine
LCDw ; call LCD sub-routine with value stored in w

movlw b'00001010' ; check amount of 10s


movwf TEMP2 ; Sub-LO
clrf TEMP3 ; Sub-HI is zero
call _VALcnv16 ; call conversion sub-routine
LCDw ; call LCD sub-routine with value stored in w

movlw b'00000001' ; check amount of 1s


movwf TEMP2 ; Sub-LO
clrf TEMP3 ; Sub-HI is zero
bsf BCflag ; remove blank checker in case of zero
call _VALcnv16 ; call conversion sub-routine
LCDw ; call LCD sub-routine with value stored in w
RETURN

_VALcnv16
clrf TEMP1 ; clear counter
_V16_1 movfw TEMP3
subwf HI_TEMP,w ; TEST: HI_TEMP-TEMP3 >= 0 ?
skpc ; skip, if true
goto _V16_LCD ; result negativ, exit
bnz _V16_2 ; test zero, jump if result > 0
movfw TEMP2 ; Precondition: HI-TEST is zero
subwf LO_TEMP,w ; TEST: LO_TEMP-TEMP2 >= 0 ?
skpc ; skip, if true
goto _V16_LCD ; result negativ, exit
_V16_2
movfw TEMP3
subwf HI_TEMP,f ; STORE: HI_TEMP = HI_TEMP - TEMP3
movfw TEMP2
subwf LO_TEMP,f ; STORE: LO_TEMP = LO_TEMP - TEMP2
skpc ; skip, if true
decf HI_TEMP,f ; decrement HI
incf TEMP1,f ; increment counter

http://www.trash.net/~luethi/microchip/modules/source/m_lcdv16.asm (4 of 5)12/02/2008 17:12:53


http://www.trash.net/~luethi/microchip/modules/source/m_lcdv16.asm

bsf BCflag ; invalidate flag


goto _V16_1
_V16_LCD
movlw '0' ; writes number to LCD
addwf TEMP1,w ; '0' is ascii offset, add counter
btfss BCflag ; check flag
movlw ' ' ; clear preceeding zeros
; return with data in w
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcdv16.asm (5 of 5)12/02/2008 17:12:53


http://www.trash.net/~luethi/microchip/modules/source/m_lcdb08.asm

;***************************************************************************
;
; 8 Bit Binary Output on LCD Display for PIC 16XXX
; ================================================
;
; written by Peter Luethi, 02.08.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 20.08.2004
;
; V1.00: Initial release (02.08.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16XXX
; Binary Range: 8 Bit
;
;
; DESCRIPTION:
; ============
; Developed on PIC 16C84, but executeable on all PIC 16XXX.
; Displays the 8 bit binary value stored in LO on the
; LCD display in binary format.
; This routine is only used for debugging registers and bit-
; streams.
;
;
; NOTE:
; =====
; Call of implemented procedure with:
; "LCDbin_08", value in LO
;
; LO is not altered or cleared during operation and is

http://www.trash.net/~luethi/microchip/modules/source/m_lcdb08.asm (1 of 3)12/02/2008 17:12:54


http://www.trash.net/~luethi/microchip/modules/source/m_lcdb08.asm

; still valid after termination of this routine.


; During the whole routine, LO_TEMP and b08_cnt must NOT be
; used by other routines ! ========
;
;
; DECLARATIONS needed in MAIN PROGRAM :
; =====================================
; CONSTANT BASE = 0x0C ; Base address of user file registers
; b08_cnt equ BASE+? ; counter
; LO equ BASE+?
; LO_TEMP equ BASE+?
;
;
; REQUIRED MEMORY:
; ================
; 3 registers declared in main program.
; needs itself 1 stack level, but LCDw needs some more
;
;***************************************************************************

;***** INCLUDE FILES *****

IFNDEF M_LCD_ID
ERROR "Missing include file: m_lcd.asm or similar"
ENDIF

;***** REGISTER DECLARATION *****

IFNDEF b08_cnt
ERROR "ModuleError: Declare b08_cnt in MAIN PROGRAM"
ENDIF
IFNDEF LO
ERROR "ModuleError: Declare LO in MAIN PROGRAM"
ENDIF
IFNDEF LO_TEMP
ERROR "ModuleError: Declare LO_TEMP in MAIN PROGRAM"
ENDIF

;***** MACROS *****

LCDbin_08 macro
call LCDbin08
endm

http://www.trash.net/~luethi/microchip/modules/source/m_lcdb08.asm (2 of 3)12/02/2008 17:12:54


http://www.trash.net/~luethi/microchip/modules/source/m_lcdb08.asm

;***** SUB-ROUTINES *****

LCDbin08
movfw LO
movwf LO_TEMP
movlw d'8'
movwf b08_cnt
bin_loop08
movlw '0'
btfsc LO_TEMP,7 ; check if bit is set, skip if cleared
movlw '1'
LCDw ; call LCD sub-routine with data stored in w
rlf LO_TEMP,1
decfsz b08_cnt,1
goto bin_loop08
RETURN

http://www.trash.net/~luethi/microchip/modules/source/m_lcdb08.asm (3 of 3)12/02/2008 17:12:54


http://www.trash.net/~luethi/microchip/modules/source/m_lcdb16.asm

;***************************************************************************
;
; 16 Bit Binary Output on LCD Display for PIC 16XXX
; =================================================
;
; written by Peter Luethi, 02.08.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 20.08.2004
;
; V1.00: Initial release (02.08.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16XXX
; Binary Range: 16 Bit
;
;
; DESCRIPTION:
; ============
; Developed on PIC 16C84, but executeable on all PIC 16XXX.
; Displays the 16 bit binary value stored in HI & LO on the
; LCD display in binary format (consecutive order).
; This routine is only used for debugging registers and bit-
; streams.
;
;
; NOTE:
; =====
; Call of implemented procedure with:
; "LCDbin_16", value in HI & LO
;
; HI & LO are not altered or cleared during operation and are

http://www.trash.net/~luethi/microchip/modules/source/m_lcdb16.asm (1 of 3)12/02/2008 17:12:54


http://www.trash.net/~luethi/microchip/modules/source/m_lcdb16.asm

; still valid after termination of this routine.


; During the whole routine, LO_TEMP, HI_TEMP and b16_cnt must NOT
; be used by other routines ! ========
;
;
; DECLARATIONS needed in MAIN PROGRAM :
; =====================================
; CONSTANT BASE = 0x0C ; Base address of user file registers
; b16_cnt equ BASE+? ; counter
; LO equ BASE+?
; LO_TEMP equ BASE+?
; HI equ BASE+?
; HI_TEMP equ BASE+? ; is only used for flag bit
;
;
; REQUIRED MEMORY:
; ================
; 5 registers declared in main program.
; needs itself 1 stack level, but LCDw needs some more
;
;***************************************************************************

;***** INCLUDE FILES *****

IFNDEF M_LCD_ID
ERROR "Missing include file: m_lcd.asm or similar"
ENDIF

;***** REGISTER DECLARATION *****

IFNDEF b16_cnt
ERROR "ModuleError: Declare b16_cnt in MAIN PROGRAM"
ENDIF
IFNDEF LO
ERROR "ModuleError: Declare LO in MAIN PROGRAM"
ENDIF
IFNDEF LO_TEMP
ERROR "ModuleError: Declare LO_TEMP in MAIN PROGRAM"
ENDIF
IFNDEF HI
ERROR "ModuleError: Declare HI in MAIN PROGRAM"
ENDIF
IFNDEF HI_TEMP

http://www.trash.net/~luethi/microchip/modules/source/m_lcdb16.asm (2 of 3)12/02/2008 17:12:54


http://www.trash.net/~luethi/microchip/modules/source/m_lcdb16.asm

ERROR "ModuleError: Declare HI_TEMP in MAIN PROGRAM"


ENDIF

;***** MACROS *****

LCDbin_16 macro
call LCDbin16
endm

;***** SUB-ROUTINES *****

LCDbin16
bsf HI_TEMP,0 ; set flag for first run with HI
movfw HI ; upper 8 bit to display = HI
bin_16 movwf LO_TEMP
movlw d'8'
movwf b16_cnt
bin_loop16
movlw '0'
btfsc LO_TEMP,7 ; check if bit is set, skip if cleared
movlw '1'
LCDw ; call LCD sub-routine with data stored in w
rlf LO_TEMP,1
decfsz b16_cnt,1
goto bin_loop16

btfss HI_TEMP,0 ; check flag, skip if set


RETURN
bcf HI_TEMP,0 ; clear flag: second run with LO
movfw LO ; lower 8 bit to display = LO
goto bin_16 ; re-enter for the second run

http://www.trash.net/~luethi/microchip/modules/source/m_lcdb16.asm (3 of 3)12/02/2008 17:12:54


http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm

;***************************************************************************
;
; RS232 Software Interface for PIC 16XXX
; ======================================
;
; written by Peter Luethi, 23.11.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 14.05.2004
;
; V1.02: Changed error handling to dedicated ISR termination label
; _ISR_RS232error required at the end of the ISR
; (11.04.2004)
; V1.01: Clean-up and improvements (30.12.2000)
; V1.00: Initial release (23.11.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16F84
; Clock: 4.00 MHz XT
; Throughput: 1 MIPS
; Serial Rate: 2400 baud, 8 bit, no parity, 1 stopbit
; Required Hardware: RS232 level shifter (MAX232)
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16F84, executeable on all interrupt
; featured PICs.
; Program handles all aspects of
; Transmission (Register TXD) and
; Reception (Register RXD) through interrupt.
;

http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm (1 of 7)12/02/2008 17:12:55


http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm

; Waitcycle for 2400 baud ==> 416 us each bit


;
; Call of implemented procedures with:
; "RS232init" Initialization
; "SEND 'c'" sends character 'c'
; "SENDw" sends content of working register
; "RECEIVE" macro in ISR: receive from RS232, store in RXD
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; ORG 0x00 ; processor reset vector
; goto MAIN ; main program
;
; ORG 0x04 ; interrupt vector
; goto ISR ; Interrupt Service Routine (ISR)
;
; CONSTANT BASE = 0x0C ; base address of user file registers
; TXD equ BASE+? ; TX-Data register
; RXD equ BASE+? ; RX-Data register
;
; #define TXport PORTA,0x00 ; RS232 output port, could be
; #define TXtris TRISA,0x00 ; any active push/pull port
; ; RS232 input port is RB0, because of its own interrupt flag
;
; Example code snippet of main program:
; -------------------------------------
; FLAGreg equ BASE+d'7'
; #define RSflag FLAGreg,0x00 ; RS232 data reception flag
;
; RSservice ; RS232 service sub-routine
; movfw RXD ; get received RS232 data
; <do whatever you want...>
; bcf RSflag ; reset RS232 data reception flag
; bsf INTCON,INTE ; re-enable RB0/INT interrupt
; RETURN
;
; MAIN RS232init ; RS232 Initialization
; clrf FLAGreg ; initialize all flags
;
; LOOP btfsc RSflag ; check RS232 data reception flag
; call RSservice ; if set, call RS232 echo & LCD display routine
; goto LOOP

http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm (2 of 7)12/02/2008 17:12:55


http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm

;
; END
;
; Example code snippet of ISR (to be implemented in main program):
; ----------------------------------------------------------------
; ;***** INTERRUPT SERVICE ROUTINE *****
; ISR <... context save ...>
;
; ;*** determine origin of interrupt ***
; btfsc INTCON,INTF ; check for RB0/INT interrupt
; goto _ISR_RS232 ; if set, there was a keypad stroke
;
; <... check other sources, if any ...>
;
; ; catch-all
; goto ISRend ; unexpected IRQ, terminate execution of ISR
;
; ;*** RS232 DATA ACQUISITION ***
; _ISR_RS232
; ; first, disable interrupt source
; bcf INTCON,INTE ; disable RB0/INT interrupt
; ; second, acquire RS232 data
; RECEIVE ; macro of RS232 software reception
; bsf RSflag ; enable RS232 data reception flag
; goto _ISR_RS232end ; terminate RS232 ISR properly
;
; <... other ISR sources' handling section ...>
;
; ;*** ISR Termination ***
; ; NOTE: Below, I only clear the interrupt flags! This does not
; ; necessarily mean, that the interrupts are already re-enabled.
; ; Basically, interrupt re-enabling is carried out at the end of
; ; the corresponding service routine in normal operation mode.
; ; The flag responsible for the current ISR call has to be cleared
; ; to prevent recursive ISR calls. Other interrupt flags, activated
; ; during execution of this ISR, will immediately be served upon
; ; termination of the current ISR run.
; _ISR_RS232error
; bsf INTCON,INTE ; after error, re-enable IRQ already here
; _ISR_RS232end
; bcf INTCON,INTF ; clear RB0/INT interrupt flag
; goto ISRend ; terminate execution of ISR
;

http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm (3 of 7)12/02/2008 17:12:55


http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm

; <... other ISR sources' termination ...>


;
; ISRend <... context restore ...> ; general ISR context restore
; RETFIE ; enable INTCON,GIE
;
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+0 - BASE+1
;
;***************************************************************************

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF TXport
ERROR "Define TXport in MAIN PROGRAM."
ENDIF
IFNDEF TXtris
ERROR "Define TXtris in MAIN PROGRAM."
ENDIF

MESSG "Default RS232 RXport is PORTB,0x00."

#define RXport PORTB,0x00 ; Needs to be an interrupt supervised


#define RXtris TRISB,0x00 ; port! When modify, set adequate
; flags in INTCON register.

;***** CONSTANT DECLARATION *****

CONSTANT LF = d'10' ; Line Feed


CONSTANT CR = d'13' ; Carriage Return
CONSTANT TAB = d'9' ; Tabulator
CONSTANT BS = d'8' ; Backspace

;***** REGISTER DECLARATION *****

IFNDEF BASE

http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm (4 of 7)12/02/2008 17:12:55


http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm

ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

TEMP1 set BASE+d'0' ; universal temporary register


TEMP2 set BASE+d'1'

IFNDEF TXD
ERROR "Declare TXD register in MAIN PROGRAM"
ENDIF
IFNDEF RXD
ERROR "Declare RXD register in MAIN PROGRAM"
ENDIF

;***** MACROS *****

RS232init macro
BANK1
bcf TXtris ; set output
bsf RXtris ; set input with weak pull-up
bcf OPTION_REG,INTEDG ; RS232 interrupt on falling edge
BANK0
bsf TXport ; set default state: logical 1
bcf INTCON,INTF ; ensure interrupt flag is cleared
bsf INTCON,INTE ; enable RB0/INT interrupt
bsf INTCON,GIE ; enable global interrupt
endm

SEND macro S_string ; "SEND 'X'" sends character to RS232


movlw S_string
call SENDsub
endm

SENDw macro
call SENDsub
endm

RECEIVE macro
call SB_Wait ; first wait sub-routine
btfsc RXport
goto _RSerror ; no valid start bit
movlw 0x08
movwf TEMP1 ; number of bits to receive, 9600-8-N-1
_RECa call T_Wait ; inter-baud wait sub-routine

http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm (5 of 7)12/02/2008 17:12:55


http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm

btfsc RXport
bsf RXD,0x07
btfss RXport
bcf RXD,0x07
decfsz TEMP1,w ; skip if TEMP1 == 1
rrf RXD,f ; do this only 7 times
decfsz TEMP1,f
goto _RECa
call T_Wait ; inter-baud wait sub-routine
btfss RXport ; check if stop bit is valid
goto _RSerror ; no valid stop bit
endm

;***** SUBROUTINES *****

SENDsub movwf TXD ; store in data register


bcf TXport ; start bit
movlw 0x08
movwf TEMP1 ; number of bits to send, 9600-8-N-1
call T_Wait
_SENDa btfsc TXD,0x00 ; send LSB first !
bsf TXport
btfss TXD,0x00
bcf TXport
rrf TXD,f
call T_Wait
decfsz TEMP1,f
goto _SENDa
bsf TXport ; stop bit
call T_Wait
call T_Wait ; due to re-synchronization
RETURN

T_Wait movlw 0x86 ; FOR TRANSMISSION & RECEPTION


movwf TEMP2 ; total wait cycle until next
goto X_Wait ; bit: 2400 baud ==> 416 us

;*** When entering this subroutine, ISR context restore has already consumed some cycles ***
SB_Wait movlw 0x3C ; FOR RECEPTION of start bit
movwf TEMP2 ; total wait cycle : 208 us
goto X_Wait ; (=> sampling in the center of each bit)

X_Wait decfsz TEMP2,1 ; LOOP

http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm (6 of 7)12/02/2008 17:12:55


http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm

goto X_Wait
RETURN

_RSerror clrf RXD ; invalid data


goto _ISR_RS232error ; goto RS232 error handling in ISR

http://www.trash.net/~luethi/microchip/modules/source/m_rs024.asm (7 of 7)12/02/2008 17:12:55


http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm

;***************************************************************************
;
; RS232 Software Interface for PIC 16XXX
; ======================================
;
; written by Peter Luethi, 21.11.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 14.05.2004
;
; V1.02: Changed error handling to dedicated ISR termination label
; _ISR_RS232error required at the end of the ISR
; (11.04.2004)
; V1.01: Clean-up and improvements (30.12.2000)
; V1.00: Initial release (21.11.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16F84
; Clock: 4.00 MHz XT
; Throughput: 1 MIPS
; Serial Rate: 4800 baud, 8 bit, no parity, 1 stopbit
; Required Hardware: RS232 level shifter (MAX232)
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16F84, executeable on all interrupt
; featured PICs.
; Program handles all aspects of
; Transmission (Register TXD) and
; Reception (Register RXD) through interrupt.
;

http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm (1 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm

; Waitcycle for 4800 baud ==> 208 us each bit


;
; Call of implemented procedures with:
; "RS232init" Initialization
; "SEND 'c'" send character
; "SENDw" send content of working register
; "RECEIVE" macro in ISR: receive from RS232, store in RXD
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; ORG 0x00 ; processor reset vector
; goto MAIN ; main program
;
; ORG 0x04 ; interrupt vector
; goto ISR ; Interrupt Service Routine (ISR)
;
; CONSTANT BASE = 0x0C ; base address of user file registers
; TXD equ BASE+? ; TX-Data register
; RXD equ BASE+? ; RX-Data register
;
; #define TXport PORTA,0x00 ; RS232 output port, could be
; #define TXtris TRISA,0x00 ; any active push/pull port
; ; RS232 input port is RB0, because of its own interrupt flag
;
; Example code snippet of main program:
; -------------------------------------
; FLAGreg equ BASE+d'7'
; #define RSflag FLAGreg,0x00 ; RS232 data reception flag
;
; RSservice ; RS232 service sub-routine
; movfw RXD ; get received RS232 data
; <do whatever you want...>
; bcf RSflag ; reset RS232 data reception flag
; bsf INTCON,INTE ; re-enable RB0/INT interrupt
; RETURN
;
; MAIN RS232init ; RS232 Initialization
; clrf FLAGreg ; initialize all flags
;
; LOOP btfsc RSflag ; check RS232 data reception flag
; call RSservice ; if set, call RS232 echo & LCD display routine
; goto LOOP

http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm (2 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm

;
; END
;
; Example code snippet of ISR (to be implemented in main program):
; ----------------------------------------------------------------
; ;***** INTERRUPT SERVICE ROUTINE *****
; ISR <... context save ...>
;
; ;*** determine origin of interrupt ***
; btfsc INTCON,INTF ; check for RB0/INT interrupt
; goto _ISR_RS232 ; if set, there was a keypad stroke
;
; <... check other sources, if any ...>
;
; ; catch-all
; goto ISRend ; unexpected IRQ, terminate execution of ISR
;
; ;*** RS232 DATA ACQUISITION ***
; _ISR_RS232
; ; first, disable interrupt source
; bcf INTCON,INTE ; disable RB0/INT interrupt
; ; second, acquire RS232 data
; RECEIVE ; macro of RS232 software reception
; bsf RSflag ; enable RS232 data reception flag
; goto _ISR_RS232end ; terminate RS232 ISR properly
;
; <... other ISR sources' handling section ...>
;
; ;*** ISR Termination ***
; ; NOTE: Below, I only clear the interrupt flags! This does not
; ; necessarily mean, that the interrupts are already re-enabled.
; ; Basically, interrupt re-enabling is carried out at the end of
; ; the corresponding service routine in normal operation mode.
; ; The flag responsible for the current ISR call has to be cleared
; ; to prevent recursive ISR calls. Other interrupt flags, activated
; ; during execution of this ISR, will immediately be served upon
; ; termination of the current ISR run.
; _ISR_RS232error
; bsf INTCON,INTE ; after error, re-enable IRQ already here
; _ISR_RS232end
; bcf INTCON,INTF ; clear RB0/INT interrupt flag
; goto ISRend ; terminate execution of ISR
;

http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm (3 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm

; <... other ISR sources' termination ...>


;
; ISRend <... context restore ...> ; general ISR context restore
; RETFIE ; enable INTCON,GIE
;
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+0 - BASE+1
;
;***************************************************************************

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF TXport
ERROR "Define TXport in MAIN PROGRAM."
ENDIF
IFNDEF TXtris
ERROR "Define TXtris in MAIN PROGRAM."
ENDIF

MESSG "Default RS232 RXport is PORTB,0x00."

#define RXport PORTB,0x00 ; Needs to be an interrupt supervised


#define RXtris TRISB,0x00 ; port! When modify, set adequate
; flags in INTCON register.

;***** CONSTANT DECLARATION *****

CONSTANT LF = d'10' ; Line Feed


CONSTANT CR = d'13' ; Carriage Return
CONSTANT TAB = d'9' ; Tabulator
CONSTANT BS = d'8' ; Backspace

;***** REGISTER DECLARATION *****

IFNDEF BASE

http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm (4 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm

ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

TEMP1 set BASE+d'0' ; universal temporary register


TEMP2 set BASE+d'1'

IFNDEF TXD
ERROR "Declare TXD register in MAIN PROGRAM"
ENDIF
IFNDEF RXD
ERROR "Declare RXD register in MAIN PROGRAM"
ENDIF

;***** MACROS *****

RS232init macro
BANK1
bcf TXtris ; set output
bsf RXtris ; set input with weak pull-up
bcf OPTION_REG,INTEDG ; RS232 interrupt on falling edge
BANK0
bsf TXport ; set default state: logical 1
bcf INTCON,INTF ; ensure interrupt flag is cleared
bsf INTCON,INTE ; enable RB0/INT interrupt
bsf INTCON,GIE ; enable global interrupt
endm

SEND macro S_string ; "SEND 'X'" sends character to RS232


movlw S_string
call SENDsub
endm

SENDw macro
call SENDsub
endm

RECEIVE macro
call SB_Wait ; first wait sub-routine
btfsc RXport
goto _RSerror ; no valid start bit
movlw 0x08
movwf TEMP1 ; number of bits to receive, 9600-8-N-1
_RECa call T_Wait ; inter-baud wait sub-routine

http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm (5 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm

btfsc RXport
bsf RXD,0x07
btfss RXport
bcf RXD,0x07
decfsz TEMP1,w ; skip if TEMP1 == 1
rrf RXD,f ; do this only 7 times
decfsz TEMP1,f
goto _RECa
call T_Wait ; inter-baud wait sub-routine
btfss RXport ; check if stop bit is valid
goto _RSerror ; no valid stop bit
endm

;***** SUBROUTINES *****

SENDsub movwf TXD ; store in data register


bcf TXport ; start bit
movlw 0x08
movwf TEMP1 ; number of bits to send, 9600-8-N-1
call T_Wait
_SENDa btfsc TXD,0x00 ; send LSB first !
bsf TXport
btfss TXD,0x00
bcf TXport
rrf TXD,f
call T_Wait
decfsz TEMP1,f
goto _SENDa
bsf TXport ; stop bit
call T_Wait
call T_Wait ; due to re-synchronization
RETURN

T_Wait movlw 0x41 ; FOR TRANSMISSION & RECEPTION


movwf TEMP2 ; total wait cycle until next
goto X_Wait ; bit: 4800 baud ==> 208 us

;*** When entering this subroutine, ISR context restore has already consumed some cycles ***
SB_Wait movlw 0x18 ; FOR RECEPTION of start bit
movwf TEMP2 ; total wait cycle : 104 us
goto X_Wait ; (=> sampling in the center of each bit)

X_Wait decfsz TEMP2,1 ; LOOP

http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm (6 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm

goto X_Wait
RETURN

_RSerror clrf RXD ; invalid data


goto _ISR_RS232error ; goto RS232 error handling in ISR

http://www.trash.net/~luethi/microchip/modules/source/m_rs048.asm (7 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm

;***************************************************************************
;
; RS232 Software Interface for PIC 16XXX
; ======================================
;
; written by Peter Luethi, 31.01.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 14.05.2004
;
; V1.02: Changed error handling to dedicated ISR termination label
; _ISR_RS232error required at the end of the ISR
; (11.04.2004)
; V1.01: Clean-up and improvements (30.12.2000)
; V1.00: Initial release (31.01.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16F84
; Clock: 4.00 MHz XT
; Throughput: 1 MIPS
; Serial Rate: 9600 baud, 8 bit, no parity, 1 stopbit
; Required Hardware: RS232 level shifter (MAX232)
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16F84, executeable on all interrupt
; featured PICs.
; Program handles all aspects of
; Transmission (Register TXD) and
; Reception (Register RXD) through interrupt.
;

http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm (1 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm

; Waitcycle for 9600 baud ==> 104 us each bit


;
; Call of implemented procedures with:
; "RS232init" Initialization
; "SEND 'c'" sends character 'c'
; "SENDw" sends content of working register
; "RECEIVE" macro in ISR: receive from RS232, store in RXD
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; ORG 0x00 ; processor reset vector
; goto MAIN ; main program
;
; ORG 0x04 ; interrupt vector
; goto ISR ; Interrupt Service Routine (ISR)
;
; CONSTANT BASE = 0x0C ; base address of user file registers
; TXD equ BASE+? ; TX-Data register
; RXD equ BASE+? ; RX-Data register
;
; #define TXport PORTA,0x00 ; RS232 output port, could be
; #define TXtris TRISA,0x00 ; any active push/pull port
; ; RS232 input port is RB0, because of its own interrupt flag
;
; Example code snippet of main program:
; -------------------------------------
; FLAGreg equ BASE+d'7'
; #define RSflag FLAGreg,0x00 ; RS232 data reception flag
;
; RSservice ; RS232 service sub-routine
; movfw RXD ; get received RS232 data
; <do whatever you want...>
; bcf RSflag ; reset RS232 data reception flag
; bsf INTCON,INTE ; re-enable RB0/INT interrupt
; RETURN
;
; MAIN RS232init ; RS232 Initialization
; clrf FLAGreg ; initialize all flags
;
; LOOP btfsc RSflag ; check RS232 data reception flag
; call RSservice ; if set, call RS232 echo & LCD display routine
; goto LOOP

http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm (2 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm

;
; END
;
; Example code snippet of ISR (to be implemented in main program):
; ----------------------------------------------------------------
; ;***** INTERRUPT SERVICE ROUTINE *****
; ISR <... context save ...>
;
; ;*** determine origin of interrupt ***
; btfsc INTCON,INTF ; check for RB0/INT interrupt
; goto _ISR_RS232 ; if set, there was a keypad stroke
;
; <... check other sources, if any ...>
;
; ; catch-all
; goto ISRend ; unexpected IRQ, terminate execution of ISR
;
; ;*** RS232 DATA ACQUISITION ***
; _ISR_RS232
; ; first, disable interrupt source
; bcf INTCON,INTE ; disable RB0/INT interrupt
; ; second, acquire RS232 data
; RECEIVE ; macro of RS232 software reception
; bsf RSflag ; enable RS232 data reception flag
; goto _ISR_RS232end ; terminate RS232 ISR properly
;
; <... other ISR sources' handling section ...>
;
; ;*** ISR Termination ***
; ; NOTE: Below, I only clear the interrupt flags! This does not
; ; necessarily mean, that the interrupts are already re-enabled.
; ; Basically, interrupt re-enabling is carried out at the end of
; ; the corresponding service routine in normal operation mode.
; ; The flag responsible for the current ISR call has to be cleared
; ; to prevent recursive ISR calls. Other interrupt flags, activated
; ; during execution of this ISR, will immediately be served upon
; ; termination of the current ISR run.
; _ISR_RS232error
; bsf INTCON,INTE ; after error, re-enable IRQ already here
; _ISR_RS232end
; bcf INTCON,INTF ; clear RB0/INT interrupt flag
; goto ISRend ; terminate execution of ISR
;

http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm (3 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm

; <... other ISR sources' termination ...>


;
; ISRend <... context restore ...> ; general ISR context restore
; RETFIE ; enable INTCON,GIE
;
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+0 - BASE+1
;
;***************************************************************************

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF TXport
ERROR "Define TXport in MAIN PROGRAM."
ENDIF
IFNDEF TXtris
ERROR "Define TXtris in MAIN PROGRAM."
ENDIF

MESSG "Default RS232 RXport is PORTB,0x00."

#define RXport PORTB,0x00 ; Needs to be an interrupt supervised


#define RXtris TRISB,0x00 ; port! When modify, set adequate
; flags in INTCON register.

;***** CONSTANT DECLARATION *****

CONSTANT LF = d'10' ; Line Feed


CONSTANT CR = d'13' ; Carriage Return
CONSTANT TAB = d'9' ; Tabulator
CONSTANT BS = d'8' ; Backspace

;***** REGISTER DECLARATION *****

IFNDEF BASE

http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm (4 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm

ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

TEMP1 set BASE+d'0' ; universal temporary register


TEMP2 set BASE+d'1'

IFNDEF TXD
ERROR "Declare TXD register in MAIN PROGRAM"
ENDIF
IFNDEF RXD
ERROR "Declare RXD register in MAIN PROGRAM"
ENDIF

;***** MACROS *****

RS232init macro
BANK1
bcf TXtris ; set output
bsf RXtris ; set input with weak pull-up
bcf OPTION_REG,INTEDG ; RS232 interrupt on falling edge
BANK0
bsf TXport ; set default state: logical 1
bcf INTCON,INTF ; ensure interrupt flag is cleared
bsf INTCON,INTE ; enable RB0/INT interrupt
bsf INTCON,GIE ; enable global interrupt
endm

SEND macro S_string ; "SEND 'X'" sends character to RS232


movlw S_string
call SENDsub
endm

SENDw macro
call SENDsub
endm

RECEIVE macro
call SB_Wait ; first wait sub-routine
btfsc RXport
goto _RSerror ; no valid start bit
movlw 0x08
movwf TEMP1 ; number of bits to receive, 9600-8-N-1
_RECa call T_Wait ; inter-baud wait sub-routine

http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm (5 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm

btfsc RXport
bsf RXD,0x07
btfss RXport
bcf RXD,0x07
decfsz TEMP1,w ; skip if TEMP1 == 1
rrf RXD,f ; do this only 7 times
decfsz TEMP1,f
goto _RECa
call T_Wait ; inter-baud wait sub-routine
btfss RXport ; check if stop bit is valid
goto _RSerror ; no valid stop bit
endm

;***** SUBROUTINES *****

SENDsub movwf TXD ; store in data register


bcf TXport ; start bit
movlw 0x08
movwf TEMP1 ; number of bits to send, 9600-8-N-1
call T_Wait
_SENDa btfsc TXD,0x00 ; send LSB first !
bsf TXport
btfss TXD,0x00
bcf TXport
rrf TXD,f
call T_Wait
decfsz TEMP1,f
goto _SENDa
bsf TXport ; stop bit
call T_Wait
call T_Wait ; due to re-synchronization
RETURN

T_Wait movlw 0x1D ; FOR TRANSMISSION & RECEPTION


movwf TEMP2 ; total wait cycle until next
goto X_Wait ; bit: 9600 baud ==> 104 us

;*** When entering this subroutine, ISR context restore has already consumed some cycles ***
SB_Wait movlw 0x08 ; FOR RECEPTION of start bit
movwf TEMP2 ; total wait cycle: 52 us
goto X_Wait ; (=> sampling in the center of each bit)

X_Wait decfsz TEMP2,f ; WAIT LOOP

http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm (6 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm

goto X_Wait
RETURN

_RSerror clrf RXD ; invalid data


goto _ISR_RS232error ; goto RS232 error handling in ISR

http://www.trash.net/~luethi/microchip/modules/source/m_rs096.asm (7 of 7)12/02/2008 17:12:56


http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm

;***************************************************************************
;
; RS232 Software Interface for PIC 16XXX
; ======================================
;
; written by Peter Luethi, 21.11.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 14.05.2004
;
; V1.02: Changed error handling to dedicated ISR termination label
; _ISR_RS232error required at the end of the ISR
; (11.04.2004)
; V1.01: Clean-up and improvements (30.12.2000)
; V1.00: Initial release (21.11.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16F84
; Clock: 4.00 MHz XT
; Throughput: 1 MIPS
; Serial Rate: 19200 baud, 8 bit, no parity, 1 stopbit
; Required Hardware: RS232 level shifter (MAX232)
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16F84, executeable on all interrupt
; featured PICs.
; Program handles all aspects of
; Transmission (Register TXD) and
; Reception (Register RXD) through interrupt.
;

http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm (1 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm

; Waitcycle for 19200 baud ==> 52 us each bit


;
; Call of implemented procedures with:
; "RS232init" Initialization
; "SEND 'c'" sends character 'c'
; "SENDw" sends content of working register
; "RECEIVE" macro in ISR: receive from RS232, store in RXD
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; ORG 0x00 ; processor reset vector
; goto MAIN ; main program
;
; ORG 0x04 ; interrupt vector
; goto ISR ; Interrupt Service Routine (ISR)
;
; CONSTANT BASE = 0x0C ; base address of user file registers
; TXD equ BASE+? ; TX-Data register
; RXD equ BASE+? ; RX-Data register
;
; #define TXport PORTA,0x00 ; RS232 output port, could be
; #define TXtris TRISA,0x00 ; any active push/pull port
; ; RS232 input port is RB0, because of its own interrupt flag
;
; Example code snippet of main program:
; -------------------------------------
; FLAGreg equ BASE+d'7'
; #define RSflag FLAGreg,0x00 ; RS232 data reception flag
;
; RSservice ; RS232 service sub-routine
; movfw RXD ; get received RS232 data
; <do whatever you want...>
; bcf RSflag ; reset RS232 data reception flag
; bsf INTCON,INTE ; re-enable RB0/INT interrupt
; RETURN
;
; MAIN RS232init ; RS232 Initialization
; clrf FLAGreg ; initialize all flags
;
; LOOP btfsc RSflag ; check RS232 data reception flag
; call RSservice ; if set, call RS232 echo & LCD display routine
; goto LOOP

http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm (2 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm

;
; END
;
; Example code snippet of ISR (to be implemented in main program):
; ----------------------------------------------------------------
; ;***** INTERRUPT SERVICE ROUTINE *****
; ISR <... context save ...>
;
; ;*** determine origin of interrupt ***
; btfsc INTCON,INTF ; check for RB0/INT interrupt
; goto _ISR_RS232 ; if set, there was a keypad stroke
;
; <... check other sources, if any ...>
;
; ; catch-all
; goto ISRend ; unexpected IRQ, terminate execution of ISR
;
; ;*** RS232 DATA ACQUISITION ***
; _ISR_RS232
; ; first, disable interrupt source
; bcf INTCON,INTE ; disable RB0/INT interrupt
; ; second, acquire RS232 data
; RECEIVE ; macro of RS232 software reception
; bsf RSflag ; enable RS232 data reception flag
; goto _ISR_RS232end ; terminate RS232 ISR properly
;
; <... other ISR sources' handling section ...>
;
; ;*** ISR Termination ***
; ; NOTE: Below, I only clear the interrupt flags! This does not
; ; necessarily mean, that the interrupts are already re-enabled.
; ; Basically, interrupt re-enabling is carried out at the end of
; ; the corresponding service routine in normal operation mode.
; ; The flag responsible for the current ISR call has to be cleared
; ; to prevent recursive ISR calls. Other interrupt flags, activated
; ; during execution of this ISR, will immediately be served upon
; ; termination of the current ISR run.
; _ISR_RS232error
; bsf INTCON,INTE ; after error, re-enable IRQ already here
; _ISR_RS232end
; bcf INTCON,INTF ; clear RB0/INT interrupt flag
; goto ISRend ; terminate execution of ISR
;

http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm (3 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm

; <... other ISR sources' termination ...>


;
; ISRend <... context restore ...> ; general ISR context restore
; RETFIE ; enable INTCON,GIE
;
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+0 - BASE+1
;
;***************************************************************************

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF TXport
ERROR "Define TXport in MAIN PROGRAM."
ENDIF
IFNDEF TXtris
ERROR "Define TXtris in MAIN PROGRAM."
ENDIF

MESSG "Default RS232 RXport is PORTB,0x00."

#define RXport PORTB,0x00 ; Needs to be an interrupt supervised


#define RXtris TRISB,0x00 ; port! When modify, set adequate
; flags in INTCON register.

;***** CONSTANT DECLARATION *****

CONSTANT LF = d'10' ; Line Feed


CONSTANT CR = d'13' ; Carriage Return
CONSTANT TAB = d'9' ; Tabulator
CONSTANT BS = d'8' ; Backspace

;***** REGISTER DECLARATION *****

IFNDEF BASE

http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm (4 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm

ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

TEMP1 set BASE+d'0' ; universal temporary register


TEMP2 set BASE+d'1'

IFNDEF TXD
ERROR "Declare TXD register in MAIN PROGRAM"
ENDIF
IFNDEF RXD
ERROR "Declare RXD register in MAIN PROGRAM"
ENDIF

;***** MACROS *****

RS232init macro
BANK1
bcf TXtris ; set output
bsf RXtris ; set input with weak pull-up
bcf OPTION_REG,INTEDG ; RS232 interrupt on falling edge
BANK0
bsf TXport ; set default state: logical 1
bcf INTCON,INTF ; ensure interrupt flag is cleared
bsf INTCON,INTE ; enable RB0/INT interrupt
bsf INTCON,GIE ; enable global interrupt
endm

SEND macro S_string ; "SEND 'X'" sends character to RS232


movlw S_string
call SENDsub
endm

SENDw macro
call SENDsub
endm

RECEIVE macro
call SB_Wait ; first wait sub-routine
btfsc RXport
goto _RSerror ; no valid start bit
movlw 0x08
movwf TEMP1 ; number of bits to receive, 9600-8-N-1
_RECa call T_Wait ; inter-baud wait sub-routine

http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm (5 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm

btfsc RXport
bsf RXD,0x07
btfss RXport
bcf RXD,0x07
decfsz TEMP1,w ; skip if TEMP1 == 1
rrf RXD,f ; do this only 7 times
decfsz TEMP1,f
goto _RECa
call T_Wait ; inter-baud wait sub-routine
btfss RXport ; check if stop bit is valid
goto _RSerror ; no valid stop bit
endm

;***** SUBROUTINES *****

SENDsub movwf TXD ; store in data register


bcf TXport ; start bit
movlw 0x08
movwf TEMP1 ; number of bits to send, 9600-8-N-1
call T_Wait
_SENDa btfsc TXD,0x00 ; send LSB first !
bsf TXport
btfss TXD,0x00
bcf TXport
rrf TXD,f
call T_Wait
decfsz TEMP1,f
goto _SENDa
bsf TXport ; stop bit
call T_Wait
call T_Wait ; due to re-synchronization
RETURN

T_Wait movlw 0x0C ; FOR TRANSMISSION & RECEPTION


movwf TEMP2 ; total wait cycle until next
goto X_Wait ; bit: 19200 baud ==> 52 us

;*** When entering this subroutine, ISR context restore has already consumed some cycles ***
SB_Wait movlw 0x01 ; FOR RECEPTION of start bit
movwf TEMP2 ; total wait cycle : 26 us
goto X_Wait ; (=> sampling in the center of each bit)

X_Wait decfsz TEMP2,1 ; WAIT LOOP

http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm (6 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm

goto X_Wait
RETURN

_RSerror clrf RXD ; invalid data


goto _ISR_RS232error ; goto RS232 error handling in ISR

http://www.trash.net/~luethi/microchip/modules/source/m_rs192.asm (7 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm

;***************************************************************************
;
; RS232 Software Interface for PIC 16XXX
; ======================================
;
; written by Peter Luethi, 16.04.1999, Dietikon, Switzerland
; http://www.electronic-engineering.ch
; last update: 14.05.2004
;
; V1.02: Changed error handling to dedicated ISR termination label
; _ISR_RS232error required at the end of the ISR
; (11.04.2004)
; V1.01: Clean-up and improvements (30.12.2000)
; V1.00: Initial release (16.04.1999)
;
; This code and accompanying files may be distributed freely and
; modified, provided this header with my name and this notice remain
; intact. Ownership rights remain with me.
; You may not sell this software without my approval.
;
; This software comes with no guarantee or warranty except for my
; good intentions. By using this code you agree to indemnify me from
; any liability that might arise from its use.
;
;
; SPECIFICATIONS:
; ===============
; Processor: Microchip PIC 16F84
; Clock: 4.00 MHz XT
; Throughput: 1 MIPS
; Serial Rate: 9600 baud, 7 bit, no parity, 1 stopbit
; Required Hardware: MAX 232
;
;
; DESCRIPTION:
; ============
; Developed and tested on PIC 16F84, executeable on all interrupt
; featured PICs.
; Program handles all aspects of
; Transmission (Register TXD) and
; Reception (Register RXD) through interrupt.
;

http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm (1 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm

; Waitcycle for 9600 baud ==> 104 us each bit


;
; Call of implemented procedures with:
; "RS232init" Initialization
; "SEND 'c'" send character
; "SENDw" send content of working register
; "RECEIVE" macro in ISR: receive from RS232, store in RXD
;
;
; DECLARATIONS needed in MAIN PROGRAM:
; ====================================
; ORG 0x00 ; processor reset vector
; goto MAIN ; main program
;
; ORG 0x04 ; interrupt vector
; goto ISR ; Interrupt Service Routine (ISR)
;
; CONSTANT BASE = 0x0C ; base address of user file registers
; TXD equ BASE+? ; TX-Data register
; RXD equ BASE+? ; RX-Data register
;
; #define TXport PORTA,0x00 ; RS232 output port, could be
; #define TXtris TRISA,0x00 ; any active push/pull port
; ; RS232 input port is RB0, because of its own interrupt flag
;
; Example code snippet of main program:
; -------------------------------------
; FLAGreg equ BASE+d'7'
; #define RSflag FLAGreg,0x00 ; RS232 data reception flag
;
; RSservice ; RS232 service sub-routine
; movfw RXD ; get received RS232 data
; <do whatever you want...>
; bcf RSflag ; reset RS232 data reception flag
; bsf INTCON,INTE ; re-enable RB0/INT interrupt
; RETURN
;
; MAIN RS232init ; RS232 Initialization
; clrf FLAGreg ; initialize all flags
;
; LOOP btfsc RSflag ; check RS232 data reception flag
; call RSservice ; if set, call RS232 echo & LCD display routine
; goto LOOP

http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm (2 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm

;
; END
;
; Example code snippet of ISR (to be implemented in main program):
; ----------------------------------------------------------------
; ;***** INTERRUPT SERVICE ROUTINE *****
; ISR <... context save ...>
;
; ;*** determine origin of interrupt ***
; btfsc INTCON,INTF ; check for RB0/INT interrupt
; goto _ISR_RS232 ; if set, there was a keypad stroke
;
; <... check other sources, if any ...>
;
; ; catch-all
; goto ISRend ; unexpected IRQ, terminate execution of ISR
;
; ;*** RS232 DATA ACQUISITION ***
; _ISR_RS232
; ; first, disable interrupt source
; bcf INTCON,INTE ; disable RB0/INT interrupt
; ; second, acquire RS232 data
; RECEIVE ; macro of RS232 software reception
; bsf RSflag ; enable RS232 data reception flag
; goto _ISR_RS232end ; terminate RS232 ISR properly
;
; <... other ISR sources' handling section ...>
;
; ;*** ISR Termination ***
; ; NOTE: Below, I only clear the interrupt flags! This does not
; ; necessarily mean, that the interrupts are already re-enabled.
; ; Basically, interrupt re-enabling is carried out at the end of
; ; the corresponding service routine in normal operation mode.
; ; The flag responsible for the current ISR call has to be cleared
; ; to prevent recursive ISR calls. Other interrupt flags, activated
; ; during execution of this ISR, will immediately be served upon
; ; termination of the current ISR run.
; _ISR_RS232error
; bsf INTCON,INTE ; after error, re-enable IRQ already here
; _ISR_RS232end
; bcf INTCON,INTF ; clear RB0/INT interrupt flag
; goto ISRend ; terminate execution of ISR
;

http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm (3 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm

; <... other ISR sources' termination ...>


;
; ISRend <... context restore ...> ; general ISR context restore
; RETFIE ; enable INTCON,GIE
;
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+0 - BASE+1
;
;***************************************************************************

;***** INCLUDE FILES *****

IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF

;***** HARDWARE DECLARATION *****

IFNDEF TXport
ERROR "Define TXport in MAIN PROGRAM."
ENDIF
IFNDEF TXtris
ERROR "Define TXtris in MAIN PROGRAM."
ENDIF

MESSG "Default RS232 RXport is PORTB,0x00."

#define RXport PORTB,0x00 ; Needs to be an interrupt supervised


#define RXtris TRISB,0x00 ; port! When modify, set adequate
; flags in INTCON register.

;***** CONSTANT DECLARATION *****

CONSTANT LF = d'10' ; Line Feed


CONSTANT CR = d'13' ; Carriage Return
CONSTANT TAB = d'9' ; Tabulator
CONSTANT BS = d'8' ; Backspace

;***** REGISTER DECLARATION *****

IFNDEF BASE

http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm (4 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm

ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF

TEMP1 set BASE+d'0' ; universal temporary register


TEMP2 set BASE+d'1'

IFNDEF TXD
ERROR "Declare TXD register in MAIN PROGRAM"
ENDIF
IFNDEF RXD
ERROR "Declare RXD register in MAIN PROGRAM"
ENDIF

;***** MACROS *****

RS232init macro
BANK1
bcf TXtris ; set output
bsf RXtris ; set input with weak pull-up
bcf OPTION_REG,INTEDG ; RS232 interrupt on falling edge
BANK0
bsf TXport ; set default state: logical 1
bcf INTCON,INTF ; ensure interrupt flag is cleared
bsf INTCON,INTE ; enable RB0/INT interrupt
bsf INTCON,GIE ; enable global interrupt
endm

SEND macro S_string ; "SEND 'X'" sends character to RS232


movlw S_string
call SENDsub
endm

SENDw macro
call SENDsub
endm

RECEIVE macro
call SB_Wait ; first wait sub-routine
btfsc RXport
goto _RSerror ; no valid start bit
movlw 0x07
movwf TEMP1 ; number of bits to receive, 9600-7-N-1
_RECa call T_Wait ; inter-baud wait sub-routine

http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm (5 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm

btfsc RXport
bsf RXD,0x07
btfss RXport
bcf RXD,0x07
rrf RXD,f ; do this 7 times
decfsz TEMP1,f
goto _RECa
bcf RXD,0x07 ; clear MSB since only 7 bits arrived
call T_Wait ; inter-baud wait sub-routine
btfss RXport ; check if stop bit is valid
goto _RSerror ; no valid stop bit
endm

;***** SUBROUTINES *****

SENDsub movwf TXD ; store in data register


bcf TXport ; start bit
movlw 0x07
movwf TEMP1 ; number of bits to send, 9600-7-N-1
call T_Wait
_SENDa btfsc TXD,0x00 ; send LSB first !
bsf TXport
btfss TXD,0x00
bcf TXport
rrf TXD,f
call T_Wait
decfsz TEMP1,f
goto _SENDa
bsf TXport ; stop bit
call T_Wait
call T_Wait ; due to re-synchronization
RETURN

T_Wait movlw 0x1D ; FOR TRANSMISSION & RECEPTION


movwf TEMP2 ; total wait cycle until next
goto X_Wait ; bit: 9600 baud ==> 104 us

;*** When entering this subroutine, ISR context restore has already consumed some cycles ***
SB_Wait movlw 0x08 ; FOR RECEPTION of start bit
movwf TEMP2 ; total wait cycle: 52 us
goto X_Wait ; (=> sampling in the center of each bit)

X_Wait decfsz TEMP2,f ; WAIT LOOP

http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm (6 of 7)12/02/2008 17:12:57


http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm

goto X_Wait
RETURN

_RSerror clrf RXD ; invalid data


goto _ISR_RS232error ; goto RS232 error handling in ISR

http://www.trash.net/~luethi/microchip/modules/source/m_rs7n1.asm (7 of 7)12/02/2008 17:12:57


Automatic Table Generator for MPLAB Assembler with Excel 97

Automatic Table Generator


Excel 97 work sheet for MPLAB Assembler

Table of Contents [Toc]

Concept
Available resources

Concept [Toc] [Top]

http://www.trash.net/~luethi/microchip/software/tablegenerator.html (1 of 2)12/02/2008 17:12:58


Automatic Table Generator for MPLAB Assembler with Excel 97

This Excel Worksheet has been designed to speed-up the implementation of 16 bit assembler look-up tables.
There are the following advantages:

Visualization of table data.


Quick changes on table data possible.
Data exchange with standard data format.
Easy adaptable for project specific requirements.

The Worksheet activates a Visual Basic macro, which fetchs the hexadecimal blocks from the table.
The "Analyse-Function" Excel Add-In needs to be switched on to calculate the 8 bit hexadecimal blocks from the
decimal values.

The software has been tested under Windows 95 and Excel 97 on a Pentium 166.
The assembler source code, which shows the implementation of the table read is available under :
projects / 16 bit table read.

Available Resources [Toc] [Top]

Item Size File

Automatic Table Generator (Excel 97 Worksheet) 20 kB TableGenerator.zip

Last updated: 23.01.2005

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/software/tablegenerator.html (2 of 2)12/02/2008 17:12:58


how to build a teleclub decoder

Teleclub-Decoder

Update August 2002: Teleclub wird digital! Wirklich? In vielen Gemeinden ist der Teleclub weiterhin analog zu
empfangen. Hier kann dieser Decoder immernoch funktionieren!

Update Mai 2000: Bestellnummern berprft und angepasst. Der Decoder luft auch im sterreichischen Wien fr den
Sender TELEKINO!

ACHTUNG: Der Nachbau und Betrieb dieser Schaltung zum Empfangen von "Teleclub" ist verboten!
Die hier zu findenden Informationen sind ausschliesslich zur Information und Weiterbildung gedacht!

Sie arbeiten fr Teleclub? Dann hier klicken!

Inhalt:

Luft der Decoder bei mir berhaupt?

Layout
Bestckungsplan
Schema
Stckliste
Bauanleitung
Abgleichanleitung
FAQ
Links zum Thema

http://www.goldfuss.de/deceed/index.html (1 of 5)12/02/2008 17:13:00


how to build a teleclub decoder

Layout:
zurck...

download, anzeigen

Bestckungsplan:
zurck...

download, anzeigen

http://www.goldfuss.de/deceed/index.html (2 of 5)12/02/2008 17:13:00


how to build a teleclub decoder

Schema:
zurck...

Fr die technisch interessierten Leute hier das genaue Schema des Decoders. Zum Anschauen am Bildschirm oder zum
downloaden und ausdrucken...

Stckliste:
zurck...

Anzahl Pos. Bezeichnung Wert Lieferant Preis


2 R1, R6 Widerstand 100k Distrelec 71 41 48 -.08
1 R2 Widerstand 10k Distrelec 71 41 15 -.08
1 R3 Widerstand 56k Distrelec 71 41 42 -.08
1 R4 Widerstand 47k Distrelec 71 41 40 -.08
1 R5 Widerstand 18k Distrelec 71 41 30 -.08
1 R7 Widerstand 6.2k Distrelec 71 41 10 -.08
1 R8 Widerstand 22k Distrelec71 41 32 -.08
1 R9 Widerstand 47 Distrelec71 40 49 -.08
1 C1 Drehkondensator 1.6p - 15p Conrad 48 30 28-11 1.35
1 C2 Kondensator 1000p Distrelec 82 05 80 -.25
3 C3, C4, C7 Kondensator 100p Distrelec 82 05 74 -.45
2 C5, C8 Kondensator 2200p Distrelec 82 05 82 -.30
1 C6 Kondensator 68p Distrelec 83 13 24 -.20
1 IC1 Dual Monoflop 4538 Distrelec 64 21 03 -.90
1 IC2 Hex-Inverter 4069 Distrelec 64 60 45 1.40
5 D1 - D5 Diode 1N4148 Distrelec 60 30 16 -.20
2 P1, P3 Potentiometer 25k Distrelec 74 01 08 1.10
1 P2 Potentiometer 10k Distrelec 74 01 07 1.10
1 P4 Potentiometer 100k Distrelec 74 01 10 1.10
1 P5 Potentiometer 2M (2.5M) *Distrelec 74 22 30 2.50
1 P6 Potentiometer 100 *Distrelec 74 22 08 2.50
*=Ersatztypen. Die ursprnglich von mir verwendeten Bauteile sind leider nicht mehr von mir erhltlich.

Das sind die Bauteile die unbedingt bentigt werden. Wer den Decoder mit Batterie betreiben will oder schon ein Netzteil besitzt,
und wer die Antennenkabel direkt auf den Print lten will, kann sich damit einen fertigen, perfekt funktionierenden Decoder
bauen. Fr alle die etwas hhere Ansprche haben, hier noch einige Bauteile fr die "Luxus-Ausfhrung"...

Anz. Pos. Bauteil Wert Lieferant Preis


1 X1 Antennenbuchse Conrad 73 97 15-11 1.70
1 X2 Antennenstecker Conrad 73 96 85-11 1.70

http://www.goldfuss.de/deceed/index.html (3 of 5)12/02/2008 17:13:00


how to build a teleclub decoder

1 X3 SCART-Stecker Conrad 74 17 87-11 2.50


1 S1 Schalter Distrelec 20 20 70 2.00
1 HF Gehuse 105x25x49 Conrad 52 16 39-11 13.95
z.B.: Distrelec 92 00 27 19.00
1 Steckernetzgert 9V
oder: Distrelec 92 06 10 14.60

Bauanleitung:
zurck...

1. Layout, Bestckungsplan und Stckliste am Besten gleich ausdrucken.


2. Leiterplatte mit Layout herstellen. (siehe FAQ)
3. Lcher fr Bauteile bohren. (0.8mm, Lcher fr Potis 1.3mm)
4. Bauteile bestcken und einlten.
5. Notwendige Drahtbrcken (orange eingezeichnet) nicht vergessen!
6. Scart- und Antennenstecker anschliessen.
7. Speisung anschliessen. (ca. 6-12V)
8. Decoder nach Abgleichanleitung einstellen.

Abgleichanleitung:
zurck...

Der Abgleich erfordert einiges an Gedult. Also nicht gleich aufgeben bevor man nicht mindestens 20min an den Potis
herumgeschraub hat. Grundstzlich lsst sich sagen: Wenn sich das Bild eines uncodierten Senders durch Einschalten des
Decoders irgendwie verndert, dann funktioniert er auch.

1. Decoder in die Antennenleitung des Fernsehers oder Videos schalten. Scart Strecker anschliessen. (WICHTIG: Scart- und
Antennenstecker mssen am selben Gert angeschlosen werden!)

2. Potentiometer wie folgt einstellen: P1 ganz nach rechts, P2 in Mittelstellung, P3 Mittelstellung, P4 ganz nach rechts, P5 ganz
nach links, P6 ganz nach links, C1 auf maximale Kapazitt.

Die Stellungen "links" und "rechts" bei den stehend montierten Potentiometern sind wie folgt definiert:

Die Potentiometer P5, P6 und P3 knnen normalerweise in dieser Stellung belassen werden. Fr die Einstellung des Decoders
sind vorallem P1, P2 und P4 von Bedeutung.

3. Einen uncodierten Sender einstellen. Solange der Decoder ausgeschalten ist, sollte das Bild absolub normal erscheinen. Sobald

http://www.goldfuss.de/deceed/index.html (4 of 5)12/02/2008 17:13:00


how to build a teleclub decoder

der Decoder aber eingeschalten wird, erscheinen helle, horizontale Streifen und das Bild ist unruhig.

4. Bild mit P2 stabilisieren. Die Streifen bleiben, das Bild sollte aber ruhiger werden.

5. P1 langsam nach links drehen, bis die Streifen pltzlich verschwinden und das Bild gleichmssig hell erscheint.

6. Auf Teleclub umschalten. P4 langsam nach links drehen bis das decodierte Bild erscheint.

7. Eventuell P2 etwas nachstellen um die Bildqualitt zu verbessern.

8. Mit P4 kann die horizontale Position des Bildes so eingestellt werden, dass keine flimmernden Kanten an den Bildrndern
links und rechts zu sehen sind.

9. Mit P5 knnen, falls vorhanden, Verzerrungen am oberen Bildrand ausgeglichen werden.

10. Mit C1 und P6 die Bildhelligkeit ev. etwas dunkler einstellen.

11. Je nach verwendetem Fernsehgert oder Videorecorder kann es sein dass der Eingangspegel des SCART-Signals mit P3
nachgestellt werden muss.

Nichts funktioniert? Oder sonstige Probleme mit dem Ablgeich? Vielleicht steht was im FAQ...

teleclub.html, last modified: 15.08.2002 zurck zu 'deceed's homeplace'

http://www.goldfuss.de/deceed/index.html (5 of 5)12/02/2008 17:13:00


Electronic Circuits & Radio Controlled Modeling

Electronic
Circuits &
Radio Controlled
Modeling

Microchip PIC
Microcontrollers

PIC Assembler Projects


PIC Assembler Modules
Electronic Circuits
Student Projects
Data Sheets

R/C Modeling

Photo Gallery
Electronic Circuits
Servo Checker

http://www.electronic-engineering.ch/index.html12/02/2008 17:13:01
Guestbook of www.electronic-engineering.ch

Guestbook

Thank you for stopping by my website.


Please take a moment and sign the guestbook.

The following e-mail addresses may not be abused by spam!


Entries to increase Google ranking by adding URL and senseless comment will be erased.

Tuesday, 12th February 2008, 14:03 R/C & Electronics


Great... You know, it's very great to see your web site. I really want to use keyboard as the input of PIC.
Now I see what to do. It's very interesting..... Thanks a lot
Sai Seng Lynn Pyin Oo Lwin Myanmar no URL given

Tuesday, 12th February 2008, 07:52 Electronics


Nice web site, and many usefull contents
Salah Algiers Algeria no URL given

Monday, 11th February 2008, 17:36 Electronics


Zrya ti tak [email protected] zrya ti tak
Ahz Texas USA http://goglya.com/

Thursday, 29th November 2007, 22:28 Electronics


Nice site, great to see you spending time to write about your experiences. It is a great help to others. Thanks.
D Cummings UK no URL given

Monday, 26th November 2007, 09:08 Electronics


Nice!!
Xaivier Chia Johor Malaysia no URL given

http://www.electronic-engineering.ch/guestbook/guestbook.html (1 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Wednesday, 21st November 2007, 10:37 Electronics


Please help me convert the .asm code for the LCD to Basic codes because I'm using the PIC Basic Pro
Compiler to program PIC16F877A. Please send it by email at [email protected]. Thank you.
Ria Gudito Bohol Philippines no URL given

Wednesday, 31st October 2007, 18:58 Electronics


Muito bom, com circuitos elaborados com o PIC 16F que jamais pensei que podia existir, tal como: Teclado
AT com LCD
Jos Carlos Santa
Cruz Braslia Brasil no URL given

Monday, 24th September 2007, 06:51 Electronics


Good site.
Gaiya Memphis USA no URL given

Friday, 17th August 2007, 03:54 R/C Modeling


Hello, I'm a man try to be a engineerer just like you. You are my role model. I'm a student, and 16 years old.
My hobby is assembly programming. I want you never shut down this site until I can overcome you. You
give me the future I want to be. Thanks very much! Danke shun(?). Anyway thanks very much, teacher!!!
Ghil Seoul Korea, South no URL given

Sunday, 5th August 2007, 16:24 Electronics


Is it possible to build a PIC Micro controller to command a radio to do a self test and then receive and
display the test result at the controller via RS 232?
John Seah Singapore Singapore no URL given

Thursday, 14th June 2007, 20:31 Electronics


Hi, I liked much your web site. I think, it is full of data about PIC. Thanks a lot for this work...
Mresat Konya Turkey http://www.pic-proje.page.tl

http://www.electronic-engineering.ch/guestbook/guestbook.html (2 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Friday, 30th March 2007, 08:48 Electronics


How should I start with the initialization process incase of interfacing LCD GDM160 1C with the PIC
16F84A? Thanks.
Debabrata Bhaskar Haldia India no URL given

Friday, 23rd March 2007, 11:42 Electronics


Hi, On the section about making a peripheral set-up using a keyboard and LCD; what do the .hex files do in
the project resources section? Many Thanks
Tom Birmingham no URL given

Friday, 23rd February 2007, 12:33 Just came over


Excuses my English. it is really an interesting site for the one who programs pic microcontroller if you want
you can insert the site of picforge (pic basic compiler) it is free hi
Gabriele Milano Italy http://picforge.interfree.it

Tuesday, 30th January 2007, 15:01 Electronics


I'm highly impressed by your records and the many works you've done. Your model plane project and your
biodata are great inspiration to me. I once built an LED moving character display using digital logic ics,
EEPROM, and Qbasic program. Now, i have rebuilt it with PIC16F84 and a self made PIC programmer.
(thanks to the internet). You've inspired me. I must do more. THANK YOU
Kayode Olagunju Lagos Nigeria no URL given

Tuesday, 23rd January 2007, 14:09 Electronics


It worked direct, great, but i need Timer0 for a other application. Can we deal with the delay's in a other way.
Harry H. Arends Netherlands http://www.harry-arends.nl

Saturday, 16th December 2006, 16:31 Electronics


Congratulations, I have never seen a web page like this where you can find a lot of projects and they work.
Luck Diego.
Diego Bernal Argentina no URL given

http://www.electronic-engineering.ch/guestbook/guestbook.html (3 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Tuesday, 14th November 2006, 06:51 R/C & Electronics


Great site! I didn't even hear about RC modelling before coming to this site. The site triggers a lot of
inspiration and a lot of help. Good luck to all those fellows maintaining this site.
J. Gab Cochin India no URL given

Tuesday, 10th October 2006, 15:48 Just came over


Great site for electronic engineers! You have done a great job! Keep it continue men...
Sharad P.
Bhadouria Indore India no URL given

Saturday, 30th September 2006, 22:07 R/C Modeling


Dear Sir, finay i found wat i am looking for, the size of the Nomad that you are, ore made. Sinds 10 years i
am looking there for, i got the plan of the GAF factory on A4 paper from the serie of the flying dockters and
finaly i found the plan in FMT but a size off 1,50 meter span, can you please help me on a plan your size
plan off the NOMAD N22 I am retierd now so i have got the time to build it. Thank you very mutch. Sorry
for my English.
Jo Van Weert Sint Oedenrode Netherlands no URL given

Tuesday, 26th September 2006, 21:55 R/C & Electronics


Nice page! The models gallery is amazing! Can't wait until I start a project of mine.
Ncolas C.
Lebedenco Rio de Janeiro Brazil no URL given

Tuesday, 26th September 2006, 21:46 Electronics


Hello brothers!! Your website is very intersting, and itve helped me a lot.Im working on a CPU project,
using 16F88, and I need use a AT keyboard.So Im starting test your keyboard routines.I hope those ones
work propely on my project. Be sure that your name will be noticed, and Ill indicate your website as
reference for microcontrollers profesional and hobbyst desings. Bye!!!
Genival Santos
Filho Rio de Janeiro Brasil no URL given

Sunday, 7th May 2006, 11:07 Electronics

http://www.electronic-engineering.ch/guestbook/guestbook.html (4 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Hallo peter jan, 17 juni a.s is er op vliegbasis leeuwarden de jaarlijkse open dag van de kon. luchtmacht. er
komen alle bekende stuntteams van de navo, vooral de blue angels uit de usa zijn bijzonder zij zullen
eenmalig in europa optreden. het volledige programma vind je op google :kon.luchtmacht, open dagen 2006.
belangstelling?? groeten uit nijverdal.
Hans Voortman Nijverdal Nederland no URL given

Monday, 6th March 2006, 10:29 R/C & Electronics


Hello all , anybody help me infor idea about firmwave in PIC, to simulate Windows Termial. I just want
load telephone number from PIC to modem by USART. In Windows, it is not problem, because we have
Windows Hyperterminal. But if the naked PIC, we must simulate this Hyperterminal in firmwave of PIC.
Please send me your advice to [email protected], TRI from Vietnam
Superwanderman Nha Trang Vietnam no URL given

Sunday, 5th March 2006, 15:45 Electronics


Well... thanks for the modules offered here. It has been a great help for me in my final year project. Well I
have a question to ask you: I am using the m_lcdv16.asm module and the counter.asm sample in my project.
My question is how can I modify the counter.asm file so that it stops counting at decimal 2000 times or
4000 times or 6000 times? Thank you if you can have a couple of minutes into my question. Thanks again.
Karkeong Yeoh Penang Malaysia no URL given

Monday, 27th February 2006, 19:54 Electronics


I search for friends which have the same aim and field.
Muhammad
Abassery Arafa Alexandria Egypt no URL given

Wednesday, 22nd February 2006, 11:55 R/C Modeling


Hello, I want to say that your page is great. I came to your Website when I was looking for pictures of the
GAF N22 Nomad. Ive seen your model and I like it. Ive got a smaller plan of this aircraft with a wingspan
of 1.50 meters, but its just semi scale. So the Rudders are a little bit bigger than in the original. So could
you send me your construction plans to my e-mail adress?
Thomas Pilot Cottbus Germany no URL given

Monday, 20th February 2006, 07:01 Electronics

http://www.electronic-engineering.ch/guestbook/guestbook.html (5 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Thanks for the oportunity to tell you what a great site this is. Many thanks, [email protected]
John Eiderton Nanjing China no URL given

Saturday, 11th February 2006, 00:45 Electronics


This is a great website!
Mike Smith Toledo USA no URL given

Friday, 10th February 2006, 01:28 Electronics


Great site, very comprehensive.... many thanks!
Bradley Macinnis Toronto Canada no URL given

Thursday, 9th February 2006, 17:42 R/C & Electronics


I would like if you can send me tips on the basics of microcontrollers programming especially on
PIC16F84A.
Mpuoane Alfred Bloemfontein South Africa http://www.webmail.co.za

Tuesday, 7th February 2006, 23:23 Just came over


Best regards to all of my engineering friends. Engineers are great!
Richard Nacamuli California USA no URL given

Saturday, 14th January 2006, 02:43 Electronics


Absolutely excellent site, thank you very much for your kindliness. Best wishes to you.
Apisart Chanpuang Bangkok Thailand no URL given

Sunday, 25th December 2005, 01:25 Electronics


I used your commtest1.hex file to make connecting between pc and pic but I couldn't succeed it. Anyway
your projects and studying are very nice. I am master student in Turkey and my thesis about "Control
System with Microcontroller without cable". In 15 days I have to finish my thesis but I have some problems
about projects. When I finish it I will go to Germany to apply Duisburg Uni for doctorate program. Nice site
really, take it easy...

http://www.electronic-engineering.ch/guestbook/guestbook.html (6 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Cem Kara stanbul Turkey no URL given

Thursday, 8th December 2005, 21:07 Electronics


Hello! My final year project is USB Radio, i.e. I need to play FM radio in computer and controlled (tunning
etc) from its application (software). I still in problem of the USB Controller what I should I use and how to
interface it in C#.NET as I suggested C#.NET in my proposal. Kindly can any one help me. Email me at
[email protected]. Thanks.
Khurram Kazim Sindh Pakistan http://www.ssuet.edu.pk/~khurama

Wednesday, 23rd November 2005, 12:45 Electronics


Great site! Guyman
Yalah Guyman London England no URL given

Sunday, 11th September 2005, 09:42 Electronics


Great site! Very interesting.
Alan Winnipeg Canada http://www.alan-parekh.webhop.net

Friday, 5th August 2005, 22:10 Electronics


I am interested how is used graphic LCD, and I found that information on this site. But my display is 3x40
with no purshase on it. Where I can find that information? Thanks, Djordje
Djordje Herceg-Novi SCG no URL given

Sunday, 24th July 2005, 05:12 Electronics


Very impressed.
K.Thiru Petaling Jaya Malaysia no URL given

Friday, 22nd July 2005, 03:16 Electronics


Nice site, LCD displays have always been a problem for me, but you make it so simple, thanks.
Steve Burlington Canada no URL given

http://www.electronic-engineering.ch/guestbook/guestbook.html (7 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Tuesday, 19th July 2005, 12:40 R/C Modeling


Hi, I saw that cool n-22 model.I have the plans for it but i got only one part of the plans.:( I wanted to ask
you could someone mail me a link of plans for n-22. or mail me scanned plans.
Andrew Kaunas Lithuania no URL given

Monday, 11th July 2005, 09:59 R/C & Electronics


I am a neophyte in the field of pic micro... I would like to solicite your idea on how to use 4x7 dot matrix as
output for my pic project... my project is to build a road construction notice system. The project will
produce several pre programmed text such as.... road construction ahead,,,, detour,,,,bridge under
construction...and the like... i would appreciate any word from you then...
Vicente Y
Buenconsejo Jr. Bacolod City Philippines no URL given

Wednesday, 6th July 2005, 12:16 Just came over


I was just surfing, BTW good website.
27 IDX 106 - Odinn Iceland http://www.dxman.com

Wednesday, 6th July 2005, 12:15 Just came over


Very good website, Best 73s folks....
TF2CT - Aegir Iceland http://www.simnet.is/aolafs/

Friday, 1st July 2005, 09:57 Electronics


I'm looking for a pressure sensor Motorola MPX4100, but I cannot find any vendors. Do you know where I
could purchase it? thanks
Alessandro Ascanio Spello Italy http://www.deltavolo.com

Friday, 10th June 2005, 23:25 Electronics


Dear Sir, This Site is Great I am a Newer to Electronics and Try my best to become a Good Designer, But In
my country resources are not enough to reach us. but in your site i got lots of info. Thank you very much for
you SIR, for you honest effort. I like to very much to stay in touch woth you sir, U can mail my address.
Thanks Sharanga Thilina

http://www.electronic-engineering.ch/guestbook/guestbook.html (8 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Sharanga Thilina Sri Lanka no URL given

Monday, 6th June 2005, 20:26 Electronics


A very nice site! Excellent layout. Excellent graphics. Excellent material. thanks for your time and effort.
Wayne Cummins
Wayne Cummins Pisgah, Alabama USA no URL given

Thursday, 2nd June 2005, 21:22 R/C Modeling


Can any body please answer to my enq? how to develop RF Transciever using 16F84A
Velmurugan Udumalpet India no URL given

Friday, 27th May 2005, 20:13 Electronics


I am interested how is used MCP3304/08 with PIC16F877-SPI hardware modul & LCD...... well i hope that
in this page can help me in it. I used An703,719 but...nothing Sorry for my English. It is not a native
language for me.
Stoyan Rousse Bulgaria no URL given

Friday, 29th April 2005, 07:04 R/C & Electronics


I am interested how is used graphic lcd in drawing signals like the sine wave.... well i hope that in this page
can help me in it
Fernando
Raymundo Lima Peru no URL given

Sunday, 27th March 2005, 21:27 R/C & Electronics


I am very interested in the robots i made a lot of them since i am a kid the best one is a hoovercraft and its
amazing but i think your robot is a lot more sofisticated than mine anyway i would like to get email from
your new inventions
Christopher Sakr Beirut Lebanon no URL given

Wednesday, 23rd March 2005, 17:47 R/C & Electronics

http://www.electronic-engineering.ch/guestbook/guestbook.html (9 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

What an incredible source for pic users!!! It's a very very impressive work you have done here!! Probably
the best on those topics we can find on the web! Crystal clear informations!!! Thanks a lot for such a
synthetic view of the lcd, RS232 and RC program using PIC micro!!! Thanks a lot!
Vincent Paris France no URL given

Monday, 14th March 2005, 01:26 R/C & Electronics


Great info, looking at using the simple rs232 interface for the 16f84a in my final year uni project, really
appreciate this being available as it saves me time having to develop one myself leaving me to worry about
the core of my project.
Ben Wiseman Melbourne Australia no URL given

Friday, 25th February 2005, 10:31 Electronics


Very Good Job!! Well done 2 u.
Harun Usm Penang Malaysia no URL given

Thursday, 24th February 2005, 15:15 Electronics


I really like finding these sites. You also provided all the necessary information for other people to build on.
Thank you for all the effort and place the information on web.
Srinivas Hyderabad India no URL given

Sunday, 20th February 2005, 12:49 Electronics


Very cool, I really like finding these sites! Thank you very much! Mi ingles es malo asi que tambien en
espaol, gracias. Esteban
Esteban Gruccos Buenos Aires Argentina no URL given

Monday, 7th February 2005, 01:01 R/C & Electronics


You have done a good job in low cost inertial navigation system. You also provided all the necessary
information for other people to build on. Thank you for all the effort and place the information on web. Best
Regard,
Wen-Hwa Chu Plano TX no URL given

http://www.electronic-engineering.ch/guestbook/guestbook.html (10 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Friday, 14th January 2005, 09:44 Electronics


Found the program for PIC 16F84 for running messages using Dot Matrix LCDs.
Abu Bakar Gombak Kuala Lumpur no URL given

Sunday, 9th January 2005, 18:26 R/C & Electronics


Very cool, I really like finding these sites! Thank you very much! Sonny
Sonny Jeffers Rosman USA no URL given

Tuesday, 4th January 2005, 22:36 Electronics


EXCELLENT - enough praise cannot be heaped upon this site: so much work by the author, not just that all
these projects actually work, but are very well presented. Well Done.
Nigel Spinney Gillingham UK no URL given

Sunday, 26th December 2004, 18:10 Electronics


Nice job!
Lauren Campbell no URL given

Saturday, 6th November 2004, 12:46 Electronics


Hallo Peter! Gratuliere zu einer sehr informativen und hilfreichen Website. Bin gerade dabei zu versuchen
einen PIC16F84 mit einer RS232-Schnittstelle zum Laufen zu bekommen und Deine Routinen sind mir
dabei eine grosse Hilfe. Nicht zuletzt wegen den ausfhrlichen Kommentaren! Alles Gute! Michael
Michael Aach-Linz Deutschland http://www.qsl.net/df1zn

Thursday, 28th October 2004, 14:34 R/C & Electronics


Hello Peter. Nice site! I came across it Googling for a servo driver circuit and selected your 2.7v Servo
Checker. I built it last night and it works great! Thanks! Now to explore your site further...
Klaus Wolter Dexter, MI USA no URL given

Thursday, 14th October 2004, 23:08 Electronics

http://www.electronic-engineering.ch/guestbook/guestbook.html (11 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Excellent website! I have tried a lot of your serial LCD modules, adapting them to 20 Mhz instead of 4 Mhz,
using PIC16F84A and PIC16F877A and 4x20, 2x12, 2x16 and 2x40 LCD's. I also slowed down the
animation when first connecting to the serial port. At 20 Mhz it was running really fast! Your assembler
modules have worked smoothly. Thanks again... I really do appreciate your hard work!
Mark Zembal Town of York Canada no URL given

Wednesday, 1st September 2004, 02:22 Electronics


Hey !!! Great site. Actually found you on Google! I'm working for a precision instruments company using
many PICs as the main microcontroller in their meters (TACHs, Speedo's, Sounders, etc.). If anyone is into
USB for these little micros, post a message. The new 18Cxxxx supports USB 2.0 but I'm looking for USB
1.1 stuff right now. I know the 16C745/765 support USB 1.1 but is there anybody out there doing this stuff?
Happy happy... John ( SicMan )
SicMan CT. Wolcott USA no URL given

Tuesday, 24th August 2004, 14:04 R/C Modeling


Grezi Herr Luethi Ich befasse mich mit dem Bau einer Cherokee. Knnen Sie mir sagen wo man gute
Unterlagen (Seitenrisse, Querschnitte) bekommt? Gibt es evt sogar Plne von Ihrer Maschine, die man
kaufen knnte? Freundliche Grsse Martin Waser
Martin Waser Neerach CH no URL given

Thursday, 19th August 2004, 21:49 Electronics


Congratulations, Mr. Peter Luethi! Your site is really usefull. Very good designs, excellent source of
research. Thanks a lot!!
Ricardo Sao Paulo Brazil no URL given

Tuesday, 13th July 2004, 17:28 Electronics


Hi, thanks for making this page. It gives many informations to its readers! Yesterday I came in first contact
with PICs while I was building an interface for an old PC in school. And it's very interesting! Greetz
Winburner
Winburner Germany no URL given

Thursday, 3rd June 2004, 20:14 R/C & Electronics

http://www.electronic-engineering.ch/guestbook/guestbook.html (12 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

I'm also a radio modeler like you with prefers into giant scale models. I 'm a mechanical engineer but I'm
new in PICs and I found your site very helpful. You have done a nice work! It will help me to begin more
easy with PICs. Thank you, Prodromos
Prodromos Kavala Greece no URL given

Friday, 14th May 2004, 21:58 R/C & Electronics


GREAT SITE !!! All of your information is very well organized. Many of your ideas have helped me on my
own projects. Ill be sure to come back.
Christopher
Placentile Toronto Canada no URL given

Tuesday, 4th May 2004, 20:07 R/C Modeling


Is there a set plans for the GAF Nomad suitable for electric propulsion? Thanks for your help.
Greg USA no URL given

Tuesday, 27th April 2004, 18:01 Electronics


Very good web site for PICs & very good routines and examples. Dani
Daniel Burgues Lleida Spain no URL given

Thursday, 15th April 2004, 22:39 R/C & Electronics


Just starting out in PIC programming and have found it difficult to find some good examples in asm not
basic. Thanks a lot and i'll be sure to come back here again... Cheers!
Rawstar Sheffield UK no URL given

Tuesday, 13th April 2004, 02:20 R/C & Electronics


Interesting page. Lots of PIC related Projects (currently adapting USART of PIC16f628 to PC). Found true
assembler projects that are helpful to implement them in PIC BASIC.
Mario Alberto
Camarillo Ramos Mexicali, Baja California Mexico no URL given

http://www.electronic-engineering.ch/guestbook/guestbook.html (13 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Sunday, 29th February 2004, 13:33 Electronics


Your site is wonderful, especially PIC routine section. I used your hardware controlled USART routine in
my school project, it works fine. Meanwhile I converted some assembly routines to Hitech C PIC compiler
routines. Thanks for all.
Engin Karabulut Kayseri Turkey http://technogate.tripod.com

Wednesday, 11th February 2004, 18:27 R/C & Electronics


I really like your web site. Great detail on your projects. I plan to try some of your routines. Dennis Koroluk
Dennis Koroluk Winnipeg, Manitoba Canada no URL given

Sunday, 23rd November 2003, 03:58 Electronics


Fantastic PIC Projects site. Went through the entire PIC Web ring, but found this site through electronics
Web ring only.
Warner Li Ontario Canada no URL given

Wednesday, 19th November 2003, 10:46 Electronics


Great thanx for a nice asm modules. Very,very useful for studying. Found one error in comtest.asm in
ending of ISR need to clear interrupt flag RB0/INT (as u write in comm9600 asm module) once again great
thanx!
Gleb Ashdod Israel http://www.dynaco.h10.ru

Friday, 19th September 2003, 20:47 R/C & Electronics


Need to implement a low cost navigational circuit to pilot an unmanned aerial vehicle in a 360 degree
pattern 100-1000 feet in air. Any ideas. I am kind of stuck at the moment on how to? Feel free to contact me
here @ work 724-589-1586 w/ any ideas or contact via email jconn#AT#kent.edu jconn#AT#vectechnology.
com
Jason Conn Austintown USA no URL given

Thursday, 4th September 2003, 03:49 R/C & Electronics


I think your model plane is awesome, as is your website. Thanks for posting so much information. - William
Miller

http://www.electronic-engineering.ch/guestbook/guestbook.html (14 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

William Miller Douglas,Georgia USA no URL given

Wednesday, 3rd September 2003, 13:02 R/C & Electronics


Hi Peter, I'm a last year student at the Scheppers-Istitute in Belgium (studying electricity-electronics). I have
an RC plane and I was thinking to install your designed altimeter (as my final). But I'm only 17 years old,
low on cash, and I noticed that the receiver and transmitter are very expensive (+/- 250 dollars). So I
wondered: Is it possible to make my own transceiver??? At school we've got good facilities, but do you
think it's possible? Well, thanks in forward and good luck with your site! Thomas
ThomASSHOLE Belgium http://www.thomasshole.tk

Sunday, 10th August 2003, 04:32 Electronics


I want to know how if to project AT Keyboard Interface xxx podria to communicate by radio frequency, you
or alquien you have a scheme of circuit of communication RS232 by FSK or another one, serious a new idea
for this project. From me already many thanks.
Facundo Cabezudo Uruguay no URL given

Friday, 2nd May 2003, 20:13 R/C Modeling


Schne Seite. Ich bin auch dabei eine Nomad zu bauen, aber noch lange nicht so weit wie Sie. Gre aus
dem Mnsterland Jrgen Hartog
Jrgen Hartog Sdlohn Deutschland no URL given

Saturday, 26th April 2003, 20:38 Electronics


Congrats on the site Peter, a job well done. I'm doing the same degree as you in Ireland.
Barry Belfast Ireland no URL given

Friday, 18th April 2003, 16:12 Electronics


Congratulations for your home page!
Alexandre Nolasco Ipatinga Brazil no URL given

Wednesday, 16th April 2003, 04:56 Electronics

http://www.electronic-engineering.ch/guestbook/guestbook.html (15 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Hola! Enhorabuena por tu pgina, los contenidos que tienes en ella son muy buenos y me estan sirviendo
mucho para el proyecto que estoy desarrollando. Gracias !! Y saludos desde Espaa !! Byez...
Charly Zaragoza Espaa no URL given

Tuesday, 15th April 2003, 13:22 Electronics


I agree with the some of the other comments in this guestbook: This site is nicely made - congratulations on
a job well done!
BT Germany no URL given

Tuesday, 18th February 2003, 12:53 Electronics


I was looking for PC oscilloscope software and found your software page with some useful links, thanks !
We're writing a DSO application (in preview release) for BitScope, our open design PIC based mixed signal
capture engine for PCs.
Bruce Tulloch Sydney Australia http://www.bitscope.com

Monday, 10th February 2003, 11:08 Electronics


Hi, nice info. I also work on a jumper channels with PIC from a 2.4GHz wireless receiver VR31 (X10
protocol) to be able to work with 4 wireless cameras WBR
Sica Zaletchi Rm Valcea Romania no URL given

Tuesday, 4th February 2003, 14:57 R/C & Electronics


I am currently an electronics student and I want to make it begin this field of engineering. I need your
assistance , I wonder if you could send me some of your projects for my own experiments.
Adams Uganda no URL given

Saturday, 1st February 2003, 06:46 Electronics


Hello Peter, I'm a student of University Technology MARA, Faculty of Electrical Engineering, Electronics.
Nothing to say...very interesting website!! I've learned a lot. Actually I'm doing my final year project in PIC
microcontroller. I'm interested with your PIC project. Could u please help me, to send a full schematic
diagram of the AT Keyboard interface with RS232 link using PIC 16F84 and other requirements need. I
really hope to hear from u. TQ.
Al-Fahmi Al-Azmi Kuala Lumpur Malaysia http://www.uitm.edu.my

http://www.electronic-engineering.ch/guestbook/guestbook.html (16 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Tuesday, 28th January 2003, 06:04 R/C & Electronics


You are starting to be known all around the world... I would really like be in touch with you. Nice site.
Alfonso Perez
Garcia San Luis Potosi Mexico no URL given

Saturday, 18th January 2003, 09:00 R/C & Electronics


Very good pages for my students. Thanks for sources.
Francomme Paris France http://francomme.fr.fm

Sunday, 5th January 2003, 14:40 Electronics


Hi, a very good homepage. I was searching for sourcecode for PIC microcontroller when I came to your
page. I am working (private for fun) on a project to use a accelerometercircuit to find the best acceleration
on a car and at which RPM. For that I will use a microcontroller (maybe 2) with RS232
serialcommunication. I saw in your code that you used interrupt, I don't know if I should use interrupt. The
PIC will just fetch data and deliver to the serialinterface so I don't see any need to use interrupt. But I will
for sure look a little in your code. Regards Bengt
Bengt Sweden no URL given

Tuesday, 31st December 2002, 14:43 Electronics


I'm programming Smartcard applications by Visual C++ 6 and microcontrollers as well, i have made a
project for image data compresion also by Visual C++.
Hakiem Misurata Libya no URL given

Monday, 30th December 2002, 11:02 Electronics


Great work!!! Your projects are very helpful for my work, I will waiting for your projects in TCP/IP. Tanks
for your information and wait news about my projets. SALUDOS. :-)
Hugo Retana Distrito Federal Mexico no URL given

Tuesday, 17th December 2002, 13:31 R/C & Electronics


Excellent , impressive and one of the best sites I visited. Will be back again. Balki

http://www.electronic-engineering.ch/guestbook/guestbook.html (17 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Balki Chennai India no URL given

Saturday, 2nd November 2002, 16:23 R/C & Electronics


Woopy you are good influence on me. I can really use your prog & scheme but i want to make a 433 Mhz
transmitting keyboard so i can receive ascii on rotating parts. or make a school cheat application. Industrie
standards (rs232) are useful. But for people there are no standards :) hi hi I must go. My compliments for
your clear presentation of your work! Ciao
Lauris Arnheim Holland no URL given

Friday, 11th October 2002, 04:01 Electronics


Soy Latino y no se mucho ingles, si tienen mandenmen algun circuito de para hacer un proyecto para la
Escuela Superior de Electronica
Santiago Rizzo Montevideo Uruguay no URL given

Wednesday, 2nd October 2002, 10:50 R/C & Electronics


Like your great PIC projects your keyboard project just helped me around a lot of errors I am trying to
develop a wheelchair controller for a handicapped friend. I also love your Nomad model I have been
building models since about 1958 once again thanks for a great site cheers Geoff Quinn
Coffs Harbour NSW
Geoff Quinn 2450 Australia no URL given

Tuesday, 13th August 2002, 16:41 R/C & Electronics


I am interested in Electronic Engineer. I need more information from outside. I hope that you can help me.
Thank you!
Pan Yuanliang Chongqing China no URL given

Monday, 22nd July 2002, 07:41 Electronics


Peter, as the Microchip Representative of Switzerland I am more than happy to have found your page. You
did a excellent job. It is the kind of sense we all working for Microchip are looking for. If you need any
help, any support or just a sample we will be more than happy to support you. Thank you for promoting
Microchip and its product in this manner, if it is with the digital or the analog product portfolio. Roland
Ruetimann

http://www.electronic-engineering.ch/guestbook/guestbook.html (18 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Roland Ruetimann Dottikon Switzerland http://www.mero.ch

Thursday, 27th June 2002, 22:43 R/C Modeling


Peter, First of all I'd like to mention a coincidence that happened when I found your page and read about
you. I lived with a German guy named Peter and he's from Dresden too. Peter Eisentraut, is a Computer
Science major and currently lives back in Dresden. I lived with him here in the Michigan a few years ago.
We still keep in touch. Now to the important stuff. I'm just starting flying my first RC trainer and would like
to include an altimeter inside my plane. I would like to be able to know how high the plane flies. I have a
degree in Mechanical Engineering, so my knowledge in electronics is somewhat limited. I was wondering if
you knew anywhere I could buy a setup similar to yours. Small precise, inexpensive, etc. Or maybe if you
could write an instructions manual for people to buy the components and assemble it. Thanks Roberto
Roberto Crescencio Grand Rapids, Michigan USA http://www.me.mtu.edu/~rdcresce

Thursday, 30th May 2002, 18:57 Electronics


Excellent site. I found an interesting project based on the 16F84 so wait for my comments on it soon.
Thanks!
Aaron Benitez Veracruz Mexico http://ab.netfirms.com

Monday, 20th May 2002, 21:25 Electronics


This a perfect page. Thanks.
Lucho Bogota Colombia http://www.geocities.com/grupo2dos

Tuesday, 30th April 2002, 06:29 R/C Modeling


That drawing of your GAF-Nomad ? Is it possible to get a copy of the drawing ? I started awhile ago to
build the same aircraft but I didn't finnished it. I build a tripple engine airplane instead, but now i have
planes to start over with my "Baby". Send me a mail, and plase visit our clubsite on the adress above, it is
unfortunetly in swedish but the pictures in "BILDDAGBOK" (Picture diary) is universal. Fly safe ! (slow
and low...)
Jan Hedstrm Nrpes Finland http://www.narpes.fi/~portomrc

Saturday, 27th April 2002, 14:01 Electronics


Great work, it's one of the best homepage I have ever seen. Some of your designs are helpful for me. Many
thanks to you.

http://www.electronic-engineering.ch/guestbook/guestbook.html (19 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Shalk Young Jinan China http://www.exingye.com

Monday, 22nd April 2002, 17:06 Electronics


Is it possible that I can send since for e-mail the file rs 232 debug interface the discharge in your it page it
doesn't work. Regards Reynaldo
Reynaldo Berrios no URL given

Tuesday, 16th April 2002, 18:35 R/C & Electronics


Hi, congratulations..! Your web page is very nice. Specially PIC-Excel scope. Bye...
Oktay Sirrik Istanbul Turkey http://www.turkengineers.com

Thursday, 11th April 2002, 20:47 Just came over


Dear Peter I am a longtime friend of your father. We worked together at BBC in the early 70-ties and after
that at Motor Columbus. We still are in touch now and then and he told me proudly about your homepage.
He can be proud of you and you of your achievements I am impressed. I especially enjoyed the picture of
the DeHavilland DC2 Beaver. My first job was at De Havilland in Canada where the Beaver was designed
and produced. I even did some work on the Beaver: the engineering of repairs. All the best Theo schotten
Theo Schotten Wermatswil Switzerland no URL given

Monday, 8th April 2002, 09:15 R/C Modeling


Firstly, a very nice web page. A friend spotted your altimeter project a forwarded your URL. I look yours
over with great interest as I too have built one and used it quite a lot from about a year and a half ago. My
prototype is based on the MPX5100 (a temperature compensated sensor) and an Atmel AT89c4052 with 12
bit Max ADC. I amplify the sensor output and achieved a resolution of 30 -50cm between ADC bits The RF
link consists of a synthesizers for the TX and RX running at 433 MHz. I wanted to use the higher 800-
900MHz ISM band, but that has been trashed by local cell phone operators. I used a slightly more powerful
output device to achieve around 19dbm of output power. The 10mW RF (10dbm) will not get reliable data
the range when aircraft exceeds a few hundred meters. Yes I have been sending data from a thermal plane
that achieved more than 800 meters of height gain!! (Not too mention that I also ran out of ADC bits!!) The
RX outputs the data on a fairly large LCD that shows temperature, battery voltages, sink/climb rates and of
course altitude. An audio vario output is also available. (calculated from the sink/climb digital data). The
entire flight is recorded (on the airborne unit) to a serial memory devices that is later dumped to a PC for
further analysis.. The entire system is all SMD technology and works very well. My next generation system
is using the new micros for Analogue Devices with built in ADC. RF link is based on a RF Micro Devices
IC that allows for 28K data rates. Sensor used is now similar to yours .. the MPX4100 (no S version?) I have
also acquired a small GPS PCB that will dump data to the onboard micro as well. The resolution will be

http://www.electronic-engineering.ch/guestbook/guestbook.html (20 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

down graded to 1 meter steps (atmospheric variations mess things up a bit) The RX will also have a sensor
(the reference pressure at ground level) to help eliminate the atmospheric variations. I hope to have this
system up and running in about a month's time. I hope this lot will provide you with some further ideas. The
use of such a device in a model glider is unbelievable. You learn so much form it. You can also set up/trim a
competition plane for minimum sink quite easily with such an instrument. Good luck
Brian Mulder Cape Town South Africa no URL given

Saturday, 30th March 2002, 14:07 Just came over


I love the low cost inertial navigation system. I ordered an evaluation ADXL150 from Analog.com. Then
looked at Crossbow.com and their stuff. Then found your site. Maybe I will be able to make something with
it- but I doubt it. Even your rig had errors you pointed out. The crossbow site has some nice free software
for logging graphing the results. Anyway well done on the website.
Quinny no URL given

Sunday, 24th March 2002, 19:18 R/C & Electronics


Wonderful page, I have been looking for a working keyboard to RS232 routine and have finally found one.
Thanks you.
Harrison no URL given

Saturday, 16th March 2002, 20:27 R/C & Electronics


Hello Peter!! Great work, good job you have here. You build systems for your RC, I build them for high-
altitude baloons !!! Keep it real! Sena
Antonio Sergio
Sena Lisboa Portugal http://www.qsl.net/ct2gpw

Monday, 11th March 2002, 22:23 Electronics


Great stuff, made bookmark and for sure be back soon.
Lodie Johannesburg South africa no URL given

Monday, 4th February 2002, 22:43 Just came over


Excellent work, Peter. Sudhir
Sudhir Gupta London Canada http://mcjournal.com

http://www.electronic-engineering.ch/guestbook/guestbook.html (21 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Monday, 12th November 2001, 05:37 Electronics


Hello Peter. I just wanted to thank you for such an informative and well designed site. I am doing some
research for a future project and stumbled across your site. I don't usually sign guestbooks but your site is
one of those gems you find every now and again while searching the net and will certainly find it's way into
my bookmark list. Very impressive. Shane Ely http://www.serialgrafix.com
Shane Granville, NY USA http://www.serialgrafix.com

Friday, 9th November 2001, 21:51 Electronics


Thanks, thanks, infinite thanks, Peter for your Keyboard to PIC program. Im a electronics student in
Cartagena (Murcia, Spain), ending my studies. Im developing a PIC-based text-video system at the end of
my studies, and Im interested to include a keyboard input in it. I hope your code will help me, Ive only just
read it now. The fact is "nowhere" else I found Keyboard to PIC16F84 protocol implemented so natural as
here (to Motorola ucontrolers in other sites). Thanks again. By the way, your page is great. HIP HOP non
stop!!!!!
Alberto B Murcia Espaa no URL given

Tuesday, 16th October 2001, 13:50 Electronics


The microcontroller PIC is fantastic... That's all!!!
Edilson Campinas Brazil no URL given

Saturday, 13th October 2001, 15:49 Electronics


This site is excellent. Thank you for sharing your knowledge. I work on INUs, to avoid temperature
problems the instruments are heated to a constant temperature. This way they maintain a constant
tempurature regardless of the ambient temperature. I guess you have already considered this method. I am
very impressed with your work.
Gavin Sydney Australia no URL given

Friday, 14th September 2001, 15:39 R/C & Electronics


Ah si tous les utilisateurs de PIC povaient en faire autant... Felicitations pour la clartee et le
professionalisme de votre site. ;=)
Philippe de
Chaponnire Nimes France no URL given

http://www.electronic-engineering.ch/guestbook/guestbook.html (22 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Tuesday, 4th September 2001, 17:06 R/C Modeling


Hello, Through a search looking for R/C Piper Cherokee's I came accross yours. Very nice. Many R/C
planes are modeled of Cessna's. I'm a student pilot of the full size Cherokee and have been looking for a R/C
version. Top Flight makes the Bonanza.......but prefer the Cherokee. I'm taking it that yours is built from
scratch. Looks Great! Brad
Brad P Grosse Pointe, Michigan USA no URL given

Monday, 6th August 2001, 11:31 R/C & Electronics


I'm recently engaged with a project usig pic micro-controller and found whatever I'ld need in this regards.
Superb and nothing else I've to say about the collection being stuffed on this site. At least every Electronic
Engineer must add this URL to his Favourites.
Majdi Farooq Karachi Pakistan no URL given

Tuesday, 24th July 2001, 15:43 R/C Modeling


Very nice site mate gud luck with it :-)
http://www.geocities.com/rc_raceruk/
Scott Gloucester United Kingdom rchomepageenter.html

Monday, 23rd July 2001, 04:41 Electronics


I was just looking for info on RS232-based Keyboard Interface, and it is quite nicely explained...Thanks
K.Mahabala Shetty Singapore no URL given

Wednesday, 18th July 2001, 23:44 Electronics


Hallo! Zuerst Gratulation zu Deinen gelungenen Projekten und der super Homepage! Ich bin Automech,
Modellbauer und Hobbyelektroniker(oder Bastler). Die KFZ Steuergerte in unseren Autos (Airbag, Motor,
Klimaanlage usw.)verfgen ber einen Fehlerspeicher, der mit einem Gert ausgelesen wird. Die vom
Steuergert gesendeten Daten werden Bitseriell bertragen. Nun suche ich einige Links
(Programmbeispiele, am besten in Qbasic /Visual Basic) um diese Daten zu erfassen, darzustellen und
auszuwerten. Mein Ziel wre es dann diese Daten mit dem PC/Laptop am /im Fahrzeug zu erfassen. Httest
Du einige Ideen und Links? Die meisten Programmierhomepages enthalten leider nur Spiele und andere
Programme usw. Ich ich wrde mich riesig auf eine Antwort freuen und hoffe Du findest etwas Zeit dafr.
Guido Wger

http://www.electronic-engineering.ch/guestbook/guestbook.html (23 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Stadel / Perth Switzerland /


Guido Wger Australia no URL given

Sunday, 17th June 2001, 15:31 R/C & Electronics


Nice page, it's nice to see someone willing to share their work progress. I am just about to start designing
my own altimeter for my RC aircraft, the ultimate aim is to make an UAV, if you are interested, check out
www.silvertone.com.au, they have great stuff. I will post my work on my own webpage. Your skills are
advantageous to this type off work, keep up the good work. I will shore to drop past and check it out from
time to time
Colin Conrick Adeladie Australia no URL given

Friday, 15th June 2001, 08:23 Just came over


This is good idelism site. Thanks for making it easy to access. I need a hand, I also want to make an
altimeter digital for my last project on campus. Because I don't know much - still learning - about
microcomputer applications, I need to ask a few questions. 1. what is the basic theory of altimeter ? 2. what
other theory and concepts that I have to know to make an altimeter digital ? 3. what are the components ?
That's all for today. I'm looking forward for your reply. Thanks a lot.
Henry Jakarta Indonesia no URL given

Tuesday, 5th June 2001, 22:25 R/C & Electronics


Quite impressive.
Edgar Allan
Policarpio Philippines no URL given

Wednesday, 16th May 2001, 16:10 Just came over


I happened across your page while looking for a keyboard/barcode slot reader. I was looking for a way to
interpret RS232 input into keyboard input for a time keeping system. Very interesting site. The robots are
very cool.
Curt Sandberg Pottstown, PA USA no URL given

Friday, 4th May 2001, 19:53 R/C & Electronics


Very good work !

http://www.electronic-engineering.ch/guestbook/guestbook.html (24 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Murary Kottayam India http://vetcross.com

Wednesday, 11th April 2001, 20:18 R/C & Electronics


Nice site...
Michel Bruxelles Belgium http://www.viralex.be

Friday, 19th January 2001, 19:29 R/C Modeling


Hello everybody, I have some time now so I would like to share some tips to all those budding pic
programmers that frequent this site. Using the Pic 16F84 and the Microchip MPLAB development software
I have managed to get myself started interfacing with a LCD. At first I had less than overwhelming results
trying to do this via shift registers and other added componantry. The lessons I have learnt are as follows: 1.
Beware of static when dealing with 74HC595s. It's all too easy to destroy them without knowing. :) 2.
Unbranded "blob based" LCDs do work! Remember to have larger delay routines to get them working, you
can always optimise later. Also be sure that your circuit has enough power to start up, otherwise the PIC can
be sending wasted commands to other devices that haven't initialised (or worse). 3. Make sure you
understand the way "banks" operate in the PIC16F84s. You will need to switch between them when
choosing TRISA and TRISB options. I suggest you download the 150 page (or so) datasheet, it will explain
things fairly clearly. 4. Have fun and learn from your mistakes. Until next time, happy programming!
Zare Zarev no URL given

Tuesday, 16th January 2001, 20:08 R/C & Electronics


Great site. Best wishes for your studies, and for your future career.
Zare Zarev Perth Australia http://web.one.net.au/~zarevz/index.htm

Tuesday, 16th January 2001, 12:31 Electronics


Awsome site very well done, GREAT info. I've just begun learning PIC stuff and am always looking for
pages like yours, wish there were more. Thanx Shawn
Shawn Kelly Kirkland, WA USA no URL given

Monday, 18th December 2000, 12:38 R/C & Electronics


Great work! Tell us more about RC flying in Switzerland. In Singapore most people fly power planes. The
club is called Radio Modellers Singapore. A few (your fellow countrymen) do aerotowing of 1/4 scale
gliders.

http://www.electronic-engineering.ch/guestbook/guestbook.html (25 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Jim Singapore no URL given

Sunday, 10th December 2000, 16:22 R/C & Electronics


I'm hoping that your Keyboard and RS232 routines are just what I need at home. They are the best laid out
pages that I have come across and you have explained them very well. Thank you for sharing them and the
effort you have put into your site.
Ian Hunaban Malvern England no URL given

Friday, 29th September 2000, 13:24 R/C & Electronics


Great site. Nice, clear structure, and very good electronics. I've already bookmarked it. I really liked your
guestbook. Keep on like this!
Fabian Pedrosa Tucuman Argentina no URL given

Wednesday, 27th September 2000, 09:57 Electronics


An excellent site and very interesting. Keep up your good work.
Dariusz Kudala Poland no URL given

Monday, 4th September 2000, 18:30 Electronics


Very good work, keep up them.
Sergio Vidales Argentina no URL given

Friday, 25th August 2000, 23:15 Electronics


I came across looking about PICs, and I found your very good works. Keep on.
Stefano Melis Uras italy no URL given

Friday, 28th July 2000, 01:49 Electronics


The Excel based RS-232 debug interface is something I have wanted to write for some time now. You have
saved me a week of my life. Thank you......
Nigel Somerville Brisbane Australia no URL given

http://www.electronic-engineering.ch/guestbook/guestbook.html (26 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Thursday, 13th July 2000, 04:50 Electronics


Impressive work, both with the web page and the PIC projects you have done.
Chris Chin Darwin Australia no URL given

Sunday, 2nd July 2000, 11:01 Electronics


Very good indeed. Keep up your good work.
Robert Yan Singapore Singapore http://www.wkc.com.sg

Monday, 26th June 2000, 14:41 R/C & Electronics


Very nice job and a very good page. Hope to see more of your projects in the future. Billy
Vassios Vassilis Thessaloniki Greece no URL given

Tuesday, 6th June 2000, 13:52 R/C & Electronics


Very nice. I will book mark your page and hope you continue to improve it. Thank You.
Nestor Cotelo Rio de Janeiro Brazil no URL given

Tuesday, 6th June 2000, 02:56 Electronics


Very nice, clean and fast just the way we like them. I will book mark it in case I need some of your
modules. Keep at it. Dave
David Friedeck Valinda USA no URL given

Saturday, 15th April 2000, 10:08 Electronics


I like your page. Very tidy. I have made a timer to control a cassette recorder and control my Awai
Minidisc recorder. I have also used LCD devices. I have hacked my web pages together to share some
of the ideas. Best wishes, Doug Rice
Doug Rice Ipswich, Suffolk UK http://www.doug.h.rice.btinternet.co.uk

Friday, 14th April 2000, 10:18 R/C & Electronics


An excellent site, well presented, with excellent PIC routines.

http://www.electronic-engineering.ch/guestbook/guestbook.html (27 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Andy Holdaway Stourbridge United Kingdom no URL given

Tuesday, 28th March 2000, 16:05 Electronics


Hi, nice pages indeed ! You are an example of what it means youthfull years... I like too your
guestbook, maybe I will inspire from it. Vasile
Surducan Vasile Cluj-Napoca Romania http://geocities.com/vsurducan/vasile.htm

Sunday, 5th March 2000, 20:17 Electronics


I just wanted to tell you that you are my hero! Thank you for your excellent job with your PIC site! It is by
far the best site of it's kind I have ever seen. For over 2 months I've been looking for a 4-bit LCD interface
but on all of the pages I looked at, there was always information missing or the code didn't work. Now, I
don't know much about assembly, so I am very grateful at how well you documented all of your work. I'm
an amateur radio operator and I am trying to build a ham radio pager that works using DTMF tones for my
personal use (not commercial). Now that I found your routines, I can finally move away from the LCD stage
and work on the DTMF decoder stage. Thanks a lot for a job well done!
Adam Porr no URL given

Saturday, 4th March 2000, 16:28 Electronics


I came accross your site whilst trying to find code and a circuit diagram for a dot matrix LCD voltmeter.
You have some very impressive projects on the go at the moment and the site is laid out excellently to see
them all - well done on the design !
James Gaylard United Kingdom no URL given

Friday, 3rd March 2000, 13:47 Electronics


I like your page a lot, it's very OK, well then one of the better electronics pages... I will set up a link to your
site with my next update... I've also written a small program called IPCOMServer that you might find
useful. It's FREE and enables you to control RS232 devices over the Internet with TELNET.
Rudolph Thomas South Africa http://www.iox.co.za

Monday, 28th February 2000, 22:06 Electronics


Very very interesting. Lovely layout.
Bert Kimpe Ooigem Belgium no URL given

http://www.electronic-engineering.ch/guestbook/guestbook.html (28 of 29)12/02/2008 17:13:06


Guestbook of www.electronic-engineering.ch

Saturday, 8th January 2000, 15:30 R/C & Electronics


Final test from home ... Just have a look, if it still works.
Peter Luethi Dietikon Switzerland no URL given

Wednesday, 5th January 2000, 10:28 R/C & Electronics


Wow, my self-written guestbook works ! Perl is really nice, but not that easy. It's now up to you to fill in my
guestbook. Thank you in advance.
Peter Luethi Dietikon Switzerland http://www.electronic-engineering.ch

[Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.electronic-engineering.ch/guestbook/guestbook.html (29 of 29)12/02/2008 17:13:06


About me

About Me

General

Welcome at my website. My name is Peter Luethi. After having been working abroad at AMD Dresden Design Center for nearly 3
years, I have moved back from Dresden, Germany to Urdorf, Switzerland. At November 1, 2003, I have started my Ph.D. thesis back
at the Integrated Systems Laboratory of the Swiss Federal Institute of Technology (ETH Zurich) in Switzerland.
My favourite hobbies are scuba diving, playing volleyball (Height: 1.98m, so do not ask on which position ...), creating convenient
electronic circuits and building and building and building and finally flying RC model airplanes. Take a glance at my "baby"...
I hope you've got some inspiration, useful information or applications to develop your own electronic circuits.

During my study...

In 1999, I have been working for 3 months at Philips Semiconductors Zurich. I have updated and built new cell libraries (pcells) for
the Cadence Design Framework. I was busy with creating Parametrizable on-chip CMOS decoupling Capacitors and
Parametrizable high-voltage CMOS Transistors (0 - 16 V). The aim of my project was to get easy drag and drop cells with
automatic DRC-compliant layout generation, so that the analog design engineers do not have to draw (and match) the layout all the
time by hand. The process was a single poly, 2 metal, 0.6 um CMOS process.
These parametrizable cells are used in CMOS LCD driver chips for mobile phones. The chips are sold as ASSPs (application
specific standard product). Note: In almost every Nokia mobile is a Philips LCD driver chip, and maybe today some of my
parametrizable on-chip capacitors...

I have also participated in a robot contest at our university. Our team consisted of 5 students, 3 electrical engineers and 2 mechanical
engineers. Here are some pictures of the Swiss SmartROB Championships at the Swiss Federal Institute of Technology in Zurich.

We have finished our students project "Parametrizable Hybrid Stack-Register Processor as VHDL Soft Intellectual Property
Module". The processor is designed to handle medium to high interrupt rates very efficiently. Therefore our processor architecture is
based on a mixture between stack and register-based architecture to merge the advantages of both of them. I've written a scientific
paper about this project and presented it at the 13th Annual IEEE International ASIC/SOC Conference, September 2000,
Washington D.C., USA.

We have also finished our second project, a "Low Cost Inertial Navigation System" based on piezo acceleration sensors and piezo
gyros. Our task was to find out, how precise navigation is possible and where the bottle-neck will be. The whole system consists of
three acceleration sensors, three gyros, some filter stages, a PCMCIA data acquisition card and a portable computer. It worked quite
well: The current setup is suitable for measuring and controlling the spatial representation (that means the acceleration and the
angles), but is not able to trace the actual position. First, the accuracy of the sensors have to be improved by a factor of 10 to be able
to calculate a reliable position. And also some more sophisticated algorithms like kalman filters and suitable position feedback/
update mechanisms are necessary, maybe in conjunction with additional GPS data.

At home, when time comes by, I'm busy with the Motorola MPXS4100A absolute pressure sensor.
I try to build a precision digital altimeter with the NSC ADC12130 12 bit A/D converter, two PIC 16F84 microcontroller, a Dot-
LCD display and a wireless transmitter and receiver. The aim is to get the actual altitude of my airplanes in real time, providing the
base for further enhancements such as a variometer,...
When this circuit is working well, I'll maybe interface a Microchip 24C65 IC-EEPROM to get an autonomous data-logger.
Afterwards the logged data will be transmitted to a PC into an Excel worksheet to visualize the route flown.

At the end of my study...

http://www.electronic-engineering.ch/aboutme/me.html (1 of 4)12/02/2008 17:13:08


About me

I have successfully finished my M.Sc. diploma thesis in electrical engineering on the Southbridge of the chipset for the next-
generation AMD 64 bit "hammer series" processors (the powerful "Sledgehammer" and his smaller counterpart, the "Clawhammer")
at AMD Dresden Design Center, Germany.

AMD Fab30 Saxony, Dresden, Germany

My task was to setup a performance analysis, which is capable of revealing possible performance bottlenecks already during
implementation time and addressing solutions to cope with these problems. The performance analysis should cover the entire
Southbridge with all its specific protocols, also the new Lightning Data Transport" (LDT) bus* specified to transmit up to 1600 mtps
(million transactions per second). The LDT bus developed and standardized by a special interest group including AMD is
implemented between North- and Southbridge and will serve the 64 bit / 66 MHz PCI bus bridges and the devices attached to the
Southbridge. So there was and still is enough work to be done...

Preview: AMD Fab30 & Fab36 Saxony, Dresden, Germany

* renamed to official name "HyperTransport" (HT)

After the study...

I have been working at the AMD Dresden Design Center, Germany on RTL-based block- and system-level verification and
performance analysis for next-generation HyperTransport" chipsets for AMDs x86-64 CPUs (see picture of AMD 8111 x86-64
Southbridge "Thor" below).

I checked the correct functionality and interoperability of next-generation HyperTransport" chipsets for AMD's hammer series. I
also received the "AMD Fab 30 Vice President's Award" for outstanding achievements in conjunction with my diploma thesis
"Performance Analysis of AMD Southbridge Zorak". In March 2003, I got the Best Paper Award at "Verisity's Club Verification" for
"Verification Glue: How to compose system-level environments".

http://www.electronic-engineering.ch/aboutme/me.html (2 of 4)12/02/2008 17:13:08


About me

AMD x86-64 Server Setup


AMD x86-64 CPU "Hammer"
consisting of "Hammer" CPU AMD 8111 x86-64 Southbridge
with 2nd level cache on the left side,
and "Thor" Southbridge "Thor"
processing units and 1st level cache
HyperTransport" IO-hub
on the right side

Today...

After having been abroad for nearly 3 years, I have moved back from Dresden, Germany to Urdorf/Zurich, Switzerland in September
2003.

At November 1, 2003, I have started my Ph.D. thesis back at the Integrated Systems Laboratory of the Swiss Federal Institute of
Technology (ETH Zurich) in Switzerland.
My project is in the area of MU-MIMO (Multi-User Multiple Input Multiple Output) for fourth generation (4G) wireless systems.
The main objective of MIMO is to increase the overall data rate by using the same bandwidth but multiple antennas to transmit
multiple data streams simultaneously. MIMO technology allows for significant increase in throughput, range and quality of service
(QoS) at the same overall transmit power and without additional bandwidth expenditure.

MIMO-based communication is only highly beneficial if we have a so-called rich-scattering environment, i.e. numerous signal
reflections, for instance in a large open indoor office environment. When radio signals are travelling across such an environment,
they get their independent spatial signature imposed by different wave reflections and absorbtions. The spatial signatures are affected
by the frequency of the signal, the environment (channel), but very important, also by the location of transmit and receive antennas.

In the case of MIMO communication, we are transmitting different signals from spatially different transmit antennas to spatially
different receive antennas, therefore every received signal has obtained its independent spatial signature. Since all radio signals are
transmitted simultaneously in the same frequency band, the receiver gets a superposition of all signals. The task of the MIMO
receiver is to separate this superposition into different data streams. The spatial signatures can be measured in the receiver (channel
estimation), and afterwards inverted (channel inversion). The subsequent equalization of the received signal is carried out to split the
received signal into different data streams originally sent by the MIMO transmitter. The complexity and performance of channel
inversion and data equalization are heavily related to the underlying MIMO detection algorithm.

Some sophisticated algorithms, demanding data processing, and high-performance digital integrated circuits behind the radio-
frequency (RF) front-end are the pre-requisites for this wireless acquisition methodology. The research focus of our team starts with
algorithm analysis (select suitable candidate algorithms with respect to a subsequent hardware implementation) and MATLAB
programming (assess reduced precision effects, i.e. fixed-point evaluation), includes VHDL coding, synthesis and functional
verification, and finally needs also integration on FPGA prototyping hardware or ASICs. The goal is to demonstrate a dedicated
subset of algorithms (e.g. linear, pseudo-linear or non-linear MIMO detection) on an OFDM based MU-MIMO hardware testbed
with wireless links in real-time. The work serves as assessment of algorithmic- and/or hardware-related issues regarding possible
future industrial high-density integration.

http://www.electronic-engineering.ch/aboutme/me.html (3 of 4)12/02/2008 17:13:08


About me

If you have any comments, hints or suggestions, or even improvements of the provided circuits,
you may contact me at [email protected] (not to be abused by spam)
Please be aware that it may take some time until I answer the question.
In case of too many requests, I won't be able to answer all of them due to limited time.

This site was checked by SiteInspector and, with the exception of popularity, excellent rated !

Last update: 07.05.2006

[Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.electronic-engineering.ch/aboutme/me.html (4 of 4)12/02/2008 17:13:08


Study projects

Theses, Publications & Awards


Table of Contents [Toc]

Study theses
Publications
Awards

Study Theses [Toc] [Top]

Swiss SmartROB Championships

Autonomous mail-collecting robot


The robot contest I've participated in during the
summer semester 1999 at the Swiss Federal Institute
of Technology, Zurich, Switzerland.
Project duration: April 1999 - July 1999

The task was to develop an autonomously navigating robot, which had to be able to detect and collect
letters - also autonomously. The letters were distributed in a square area of 7.9 x 7.9 meters, which
was designed as a labyrinth.

Enhanced RISC Processor "SILVERBIRD"

http://www.electronic-engineering.ch/study/study.html (1 of 5)12/02/2008 17:13:09


Study projects

Parametrizable Hybrid Stack-Register Processor as


VHDL Soft IP-Module
Students project at the Integrated Systems Laboratory
of the Swiss Federal Institute of Technology, Zurich,
Switzerland.
Project duration: October 1999 - July 2000

The aim was to develop a highly parametrizable RISC processor as soft IP (Intellectual Property)
module based on VHDL (Very high speed integrated circuits Hardware Description Language) for
embedded systems.

Features:

Parametrizable hybrid stack-register processor for system-on-a-chip (SOC) applications


Parametrizable RISC instruction set
Special architecture to meet the requirements of efficient interrupt handling without any
pipeline flushs or no-operation cycles
Possibility to easily implement high-level language compiler due to register-bank-like random-
access registers
The processor is designed to manage medium to high interrupt loads easily

Low Cost Inertial Navigation System

Design and characterization of a strapdown inertial


navigation system based on low cost sensors
The students project I've participated in during the
summer semester 2000 at the Swiss Federal Institute
of Technology, Zurich, Switzerland.
Project duration: April 2000 - July 2000

The aim of the project was first to design a complete inertial navigation system and second to find out,
how precise such a platform built from low cost sensors is and how its performance can be improved.

Performance Analysis of next-generation AMD Southbridge "Zorak"

http://www.electronic-engineering.ch/study/study.html (2 of 5)12/02/2008 17:13:09


Study projects

Implementation of a performance test environment


capable of revealing possible performance
bottlenecks already during design time
My diploma thesis at AMD Dresden Design Center,
Dresden, Germany in order to get my master degree
in electrical engineering from the Swiss Federal
Institute of Technology, Zurich, Switzerland.
Project duration: October 2000 - March 2001

The "Zorak" Southbridge is a prototype part of the chipset for the next-generation AMD 64 bit
"hammer series" processors (the powerful "Sledgehammer" and his smaller counterpart, the
"Clawhammer"). My task was to setup a performance analysis environment for the "Zorak"
Southbridge, which is capable of revealing possible performance bottlenecks already during
implementation time in RTL design. The performance analysis covers the entire Southbridge with all
its specific protocols, also the new Lightning Data Transport (LDT)* bus specified to transmit up to
1600 mtps (million transactions per second). One transaction could be done on various data widths: If
we take one byte at maximum clock rate, the resulting bandwidth will be 1.6 GB/s, but allowing for
even more by using larger data widths. The LDT bus developed and standardized by a special
interest group (SIG) including AMD is implemented between North- and Southbridge and will serve
the 64 bit / 66 MHz PCI bus bridges (and other bridges) and the devices attached to the Southbridge.
So there was and still is enough work to be done...

* renamed to the official name HyperTransport

< This project is confidential, therefore no more information available. >

I am now with AMD Dresden Design Center, Germany, working on RTL-based block- and system
level verification and performance analysis. I check the correct functionality and interoperability of
next-generation HyperTransport chipsets for AMD's hammer series.

Publications [Toc] [Top]

Parametrizable Hybrid Stack-Register Processor as Soft Intellectual Property


Module

http://www.electronic-engineering.ch/study/study.html (3 of 5)12/02/2008 17:13:09


Study projects

Paper about our "SILVERBIRD" Processor Soft IP-


Module, Swiss Federal Institute of Technology,
Zurich, Switzerland
written for the 13th Annual IEEE International ASIC/
SOC Conference 2000,
Washington D.C., Virginia USA,
13th - 16th September, 2000

Verification Glue: How to compose system-level environments


Presentation about the verification concept at AMD
Dresden Design Center, Dresden, Germany
written for "Verisity's Club Verification"
3rd Annual European Specman User Group
Conference,
DATE03, Munich, Germany,
3rd March, 2003

Awards [Toc] [Top]

AMD Fab 30 Vice President's Award

Acknowledgment for outstanding achievements at


AMD Fab 30 Saxony

"... for your excellent diploma thesis 'Performance Analysis of AMD Southbridge Zorak' and extensive
documentation of the software structure and its internal blocks - the prerequisite for further usage and
development ..."

Dresden - May 30, 2001


Hans Deppe, Vice President and General Manager AMD Fab 30 Saxony

http://www.electronic-engineering.ch/study/study.html (4 of 5)12/02/2008 17:13:09


Study projects

Best Paper Award "Verisity's Club Verification"

Best Paper Award at "Verisity's Club Verification" for


"Verification Glue: How to compose system-level
environments"
Peter Lthi, Ulrich Hensel
AMD Dresden Design Center, Dresden, Germany

Verisity's Club Verification


3rd Annual European Specman User Group Conference,
DATE03, Munich, Germany,
3rd March, 2003

Last updated: 15.01.2006

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.electronic-engineering.ch/study/study.html (5 of 5)12/02/2008 17:13:09


Links to electronic sites

Links
Table of Contents [Toc]

Electronic Links
Microchip PIC Links
R/C Links
GPS Links
Data Sheets & Application Notes
Colleague's Sites

Electronic Links [Toc] [Top]

Electronics Engineering WebRing


Electronic ressources.
Interfacing the PC (beyondlogic.org)
Craig Peacock's must-known website, if electronics engineering is your business.
The RS232 Standard
Excellent RS232 utorial and data sheet.
How to control HD44780 based LCDs
Describes the basics of the HD44780 based character LCDs.
IP & Ethernet Interfaces
About selfmade Ethernet Interfaces.
CircuitDesign RF devices
Several wireless transmitter and receiver products. Circuit Design specializes in design and
manufacturing of low power radio transmitter, receiver and transceiver modules and modems in the
category of Short Range Devices (SRD) in the license exempt free band.
RF Micro Devices
Several wireless transmitter and receiver products.
Modtronix.com
Modular PIC based hardware and software, e.g. embedded ethernet solutions.

http://www.electronic-engineering.ch/microchip/links.html (1 of 4)12/02/2008 17:13:10


Links to electronic sites

Xsens.com
Embedded inertial navigation solutions.
IO.DLL
Universal Windows I/O driver, IO.DLL allows seamless port I/O operations for Windows 95/98/
NT/2000/XP using the same library
Wireless World AG
Swiss distributor for various wireless components

Microchip PIC Links [Toc] [Top]

The PICmicro WebRing


Collection of PIC resources.
Embedded 10BaseT Ethernet
Excellent page about connecting a PIC to the Ethernet.
PIC Frequency Meter
Frequency measurement up to 80 MHz with PIC16F84.
EEPROM 24LC16
Serial EEPROM routine & various PIC stuff.
PIC Propeller Clocks
Bob Blick's "Propeller Clock" page.
The Embedded WebRing
Collection of PIC and other embedded controller applications.
Microchip Net Ressources
Huge PIC ressource page.

R/C Links [Toc] [Top]

RC data logger with altitude capture


German page about a self-made RC data logger using PIC 16F84 and MPXS 4100A absolute pressure
sensor.

http://www.electronic-engineering.ch/microchip/links.html (2 of 4)12/02/2008 17:13:10


Links to electronic sites

CLONEPACs for Futaba Radios (16 kB CAMPAC)


Self-made memory extension modules for Futaba R/C transmitters. They do work and are currently in
service in my Futaba FC18 V3 Plus radio. One 16 kB CAMPAC clone provides storage capacity for
11 models within the FC18 transmitter. See my own 16 kB ClonePacs here.
Considering more than 16 kB? Then have a look at Model-Gadget's Ultra-PAC-II.

Autonomous Unmanned Aircraft Vehicle (AUAV)


Dave Jones impressive experiences with installing GPS receiver and gyroscopes on a model airplane
to fly autonomously 48 miles or 1 hour 8 min. It worked, although it was very adventurously...

GPS Links [Toc] [Top]

u-blox GPS
Swiss miniature MCM* 12 channel GPS receiver.
* Multi-Chip-Module
Larry's Garmin connector
Interface your GPS to a computer using the RS232 port.
Peter Bennett's GPS and NMEA Site - Garmin Support

Data Sheets & Application Notes [Toc] [Top]

National Semiconductors

Philips Semiconductors Search

Freescale Semiconductors (formerly Motorola Semiconductors)

Freescale Semiconductors Sensor Index (Pressure,...)


Sensor Selector Guide, data sheets and application notes about pressure sensors.
TI Semiconductors Search

TI Product Information & Document Search

Infineon

Maxim Semiconductors

Linear Technology

http://www.electronic-engineering.ch/microchip/links.html (3 of 4)12/02/2008 17:13:10


Links to electronic sites

QuestLink
Free subscription, very good for everything!
Microchip PIC Microcontroller
Manufacturer of my micro-controllers. You can get there all PIC data sheets, many application notes
and the MPLAB Integrated Development Environment for free.
Fairchild Semiconductor

Chip directory

Colleague's Sites [Toc] [Top]

www.tmoser.ch
Thomas Moser has studied electrical engineering together with me. He worked with me on the Swiss
SmartROB Contest and the Low Budget Inertial Navigation System. He is interested in network and
distributed computing, and embedded systems engineering.
www.lka.ch
Lukas Karrer has also studied electrical engineering with me. We did not work together on any
projects, but we had a great time. He is interested in network computing (founder of swiss non-
commercial Unix-dedicated website www.trash.net), and web content usability (start-up www.stimmt.
ch).

www.zwickers.ch
Thomas Zwicker, another study colleague, is interested in network computing and image processing
algorithms. He is busy with developing an autonomous flying radio controlled helicopter.

Last update: 15.01.2006

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.electronic-engineering.ch/microchip/links.html (4 of 4)12/02/2008 17:13:10


Free software for electronic applications - for Windows 95/98/ME/NT/XP

Software
Electronics

Item Size File

RS232 Scope V1.02 (Excel 97 Worksheet with Visual Basic Macro)

RS232 Debug Interface (Excel 97 Worksheet with Visual Basic Macro)

DCF77 Capture & Visualization (Excel 97 Worksheet with Visual Basic Macro)

Automatic Table Generator for MPLAB Assembler (Excel 97 Worksheet with Visual Basic Macro)

AudioAnalyser: It is a realtime audio analyser, the opposite


program to the signal generator below. Works with your PC
soundcard.

Sebastian Dunst, Windows XP

MultiSine: It is an audio signal generator for your PC in


combination with your soundcard.

Sebastian Dunst, Windows XP

Windows 95 HyperTerminal
because Windows 98 HyperTerminal does not echo locally typed 153 kB HyperTerminal95.zip
characters.

2-Channel AC-Oscilloscope for your PC soundcard, that means


20 - 20'000 Hz
68.4 kB scope.zip
Windows 95/98

http://www.electronic-engineering.ch/microchip/software/soft.html (1 of 2)12/02/2008 17:13:10


Free software for electronic applications - for Windows 95/98/ME/NT/XP

Improved 2-Channel AC-Oscilloscope for your PC soundcard,


that means 20 - 20'000 Hz

Windows 95/98
88.4 kB osc251.zip
implemented by a student at Moscows State University, Physic
Dep., Homepage with Versions for Win3.x/Win95

Frequency Analyzer for your PC soundcard, that means 20 -


20'000 Hz
31.9 kB freq.zip
Windows 95/98

Collection of nice Windows Tools

Item Size File

This page has been created using HomeSite V1.2, an excellent HTML source
503 kB hs12.exe
code editor implemented by Nick Bradbury. Windows 95/98

Virtual desktop for Windows 95/98 (to get several desktops like in Unix/
Linux systems, crucial for convenient programming, but presumes enough
234 kB sDesk.zip
RAM for smooth operation, works fine with 128 MB RAM and 500 MHz
CPU)

For Windows XP, use the Microsoft PowerToys to get multiple desktops.

Terragen: A tool to create fascinating pictures of artificial sceneries and


landscapes, ability to create movies of a collection of artificial landscapes
(with additional tool), excellent to unleash the full power of your PC (I have Link: Terragen
made a movie, for which the calculation of all 700 images took 3 days on a
700 MHz Athlon...)

Last updated: 06.08.2006

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.electronic-engineering.ch/microchip/software/soft.html (2 of 2)12/02/2008 17:13:10


Data Sheets: PIC instruction set, LCDs, RS232, AT keyboard, DCF77, pressure sensors,...

Data Sheets
Table of Contents [Toc]

Microchip PIC Controllers


Dot Matrix LCD Displays
Graphic LCD Displays
RS232 Drivers
Connectors
Miscellaneous

Microchip PIC Controllers [Toc] [Top]

PIC Instruction Set Quick Reference Quick reference of all PIC instructions, including special
instruction mnemonics. This data sheet was extracted with
GhostView directly from document DS33014G, MPASM
User's Guide, pp. 196-209.
(PDF, 116 kB)

Dot Matrix LCD Displays [Toc] [Top]

Dot Matrix LCD Display


2 lines x 40 characters

Dot Matrix LCD Display


2 lines x 16 characters

http://www.electronic-engineering.ch/microchip/datasheets/datasheets.html (1 of 4)12/02/2008 17:13:11


Data Sheets: PIC instruction set, LCDs, RS232, AT keyboard, DCF77, pressure sensors,...

This is the standard connection for dot matrix LCD displays. It


fits perfectly and easiest with a 2 x 7 press connector for 14
rods flat band wire.

Hitachi HD44780 Data Sheet Everything about the dot matrix LCD controller IC Hitachi
HD44780.
(PDF, 389 kB)

Samsung KS0073 Data Sheet Everything about the dot matrix LCD controller IC Samsung
KS0073.
(PDF, 673 kB)

HD44780 Controller: Brief overview HTML Webpage (local)


Describes all important commands not explained in "The
Extended Concise LCD Data Sheet":
The standard character set, the programming of the self-defined
characters and the software reset.

The Extended Concise LCD Data Sheet Describes all commands for the Dot Matrix LCD Display.
This document is based on the earlier version "The Concise
LCD Data Sheet" written by Craig Peacock, Australia. Thanks
also to Craig Peacock, who made a smaller PDF 1.2 file with
an original Acrobat PDF Writer.
(PDF, 44 kB)

As Word-Doc 7.0 file, 66 kB


The file has been written by myself and contains NO macro
virus.

As PostScript file, 274 kB

EA-DIP204-4 with KS0073 (PDF, 248 kB, english)


Product specification of 4x20 LCD. Lists the Extended
EA-DIP204-6 with KS0073 (PDF, 182 kB, german only)
Function Set of the Samsung KS0073 LCD controller.
or go directly to the german site Electronic Assembly

Link: How to control HD44780 based LCDs Describes the basics of the Hitachi HD44780 based character
LCDs.
(Peer Ouwehand's LCD pages)

Graphic LCD Displays [Toc] [Top]

http://www.electronic-engineering.ch/microchip/datasheets/datasheets.html (2 of 4)12/02/2008 17:13:11


Data Sheets: PIC instruction set, LCDs, RS232, AT keyboard, DCF77, pressure sensors,...

Principles of Operation Explains the principles of graphic LCD modules, graphic


controllers and shows timing diagrams.
(PDF, 87.5 kB)

Application Notes Application notes concerning contrast regulation, temperature


dependency and compensation.
(PDF, 47 kB)

RS232 Drivers [Toc] [Top]

Max232 Data Sheet RS232 line driver (serial communication)


(PDF, 320 kB)

RS232 terminology of DTE and DCE


RS232 DTE/DCE FAQ
(PDF, 144 kB)

Connectors [Toc] [Top]

Pinout of various Connectors HTML Webpage (local)

Link: The RS232 Standard HTML Webpage (link)


Excellent RS232 Tutorial and Data Sheet !

Miscellaneous [Toc] [Top]

ASCII Character Map ASCII map containing representations in range 33 - 255 of


decimal, binary, hexadecimal, and characters
(PDF, 18.9 kB)

AT Keyboard Specification (PDF, 189 kB)

DCF77 Time and Standard Frequency Station HTML Webpage (local)

MPX4100A Motorola Absolute Pressure Sensor Series MPX4100A


(PDF, 117 kB)

Motorola SensorSelectorGuide Motorola Sensor Selector Guide


(PDF, 166 kB)

AN1646 Noise considerations for integrated pressure sensors


(PDF, 153 kB)

Last updated: 17.04.2005

[Toc] [Top]

http://www.electronic-engineering.ch/microchip/datasheets/datasheets.html (3 of 4)12/02/2008 17:13:11


Data Sheets: PIC instruction set, LCDs, RS232, AT keyboard, DCF77, pressure sensors,...

If you see only this page in your browser window,


click here
to get the entire site.

http://www.electronic-engineering.ch/microchip/datasheets/datasheets.html (4 of 4)12/02/2008 17:13:11


FAQ for Microchip PIC 8 bit microcontroller programming

PIC FAQ Section


Frequently asked questions for Microchip PIC 8 bit microcontroller programming

Table of Contents [Toc]

How I started microcontroller programming


Why I use PIC microcontrollers
How to start with PIC microcontrollers?
PIC16F84
PIC16F77
PIC16F877
Which development environment do I use?
First steps in PIC programming
Common programming questions
How to assemble PIC code in MPLAB
Advanced steps in PIC programming
General
Paging - large code considerations
High level languages
C
Debugging hints
General
RS232 communication issues
LCD communication issues
In case of errors
Compile errors
Page crossings
PIC History
Call it RISC...
Scientific curiosity
From I/O handling to RISC controller

How I started microcontroller programming [Toc] [Top]

I first entered the microcontroller world with a proprietary, mask-programmed controller kit bought from Conrad Electronics, a german electronics distributor. It was a Conrad C-Control Basic kit, a
68HC05B based controller board with RS232 link and an external serial EEPROM as program memory. The user develops its application in a kind of BASIC programming language, which is
afterwards translated by the development software into byte-tokens. The byte tokens are then loaded into the serial EEPROM. During execution, the controller reads these byte-tokens from the
external EEPROM and interprets them using the internal, pre-programmed routines. For first contact with microcontrollers, it was a good approach, although there were some unsatisfying facts:

proprietary solution using mask-programmed routines in the controller


rather slow execution and low performance
very limited data RAM
http://www.electronic-engineering.ch/microchip/faq/faq.html (1 of 12)12/02/2008 17:13:14
FAQ for Microchip PIC 8 bit microcontroller programming

no tight control of hardware resources and its capabilities


an expensive solution if used in pervasive computing (a single and simple mask-programmed controller unit costs about 25 US-$)

These reasons have lead me to change to another controller solution. Finally, I decided to change to the Microchip PIC controllers.

Why I use PIC microcontrollers [Toc] [Top]

The Microchip PIC microcontrollers are a convenient and cost-effective solution for a lot of home-made applications, because:

PIC microcontrollers are widely available (Farnell, Conrad, Disterelec,...)


PIC controllers are cheap and do not require a lot of prerequisites before running in an application (i.e. additional HW blocks such as external EPROM for program memory, external A/D
converter,...)
the PIC development environment is freely available and up-to-date
there is a broad range of different PIC microcontrollers, very likely to fit into your target application
the hardware programming itself is easy and does not require a lot of additional equipment (like JTAG programmer, EPROM/flash programmer)
the various packages available (DIP, SSOP, SOIC, TQFP, PLCC,...), even with low pin counts, allow for convenient prototyping without big initial efforts

Although I use PIC microcontrollers often, I would not consider the PIC microcontroller as high-performance RISC controller - as claimed by the manufacturer. High-performance - compared to
what? There is no reference for comparison given...
On the other hand, I personally would implement a more sophisticated architecture based on one instruction per oscillator cycle, i.e. 1 MIPS @ 1 MHz. This is more power-efficient and would at least
indicate that there is best use made of every clock cycle when using a single execution pipeline. For the core, I would check the requirements carefully and decide whether to use a two, three or four
stage pipeline. And for not loosing any performance, additional delayed-branching would be introduced. A deeper stack for the program counter may also be suitable, especially when serving a lot of
interrupt sources and doing prioritized interrupt handling in software (i.e. another high-priority ISR call during a low-priority ISR call). Finally, an ability to check the stack levels used would also be
welcome, as well as hardware-based context save on entrance and exit of the interrupt service routine.

How to start with PIC microcontrollers? [Toc] [Top]

I started with the PIC16C84 (an early EEPROM version of today's standard flash version 16F84).
Today, I would say, the PIC16F84 is the best-suited Microchip RISC controller to start with:

PIC16F84

reasonable hardware complexity for beginners


only 35 RISC instructions
easy to program, even with self-made PIC programmers (search the web)
sufficient performance for ordinary controller-applications, up to 5 MIPS @ 20 MHz
8-level deep hardware stack (for calling sub-routines)
has internal and external interrupt support (e.g. timers, port change), total of 4 interrupt sources
ability to store non-volatile data in internal EEPROM (64 bytes)
18 pin package (DIP18)

Once you have acquired some experience in PIC programming and you are familiar with the PIC architecture, I suggest to switch to the PIC16F77 (that's what I did also). It offers a lot of peripheral
hardware blocks, so that you don't have to handle this in software (e.g. RS232 transmission and reception):

PIC16F77

http://www.electronic-engineering.ch/microchip/faq/faq.html (2 of 12)12/02/2008 17:13:14


FAQ for Microchip PIC 8 bit microcontroller programming

instruction set is the same as for the PIC16F84


much larger instruction memory (8k words) and data RAM (368 bytes), but no internal EEPROM (non-volatile data storage)
provides many additional hardware resources, e.g.
- universal synchronous asynchronous receiver transmitter (USART) for RS232 or similar interfaces
- synchronous serial port (SPI) with SPI master mode and IC slave mode
- parallel slave port
- capture/compare/PWM blocks
- 8 bit A/D converter (8 channels)
total of 12 interrupt sources (internal and external interrupts)
40 pin package (DIP40)

You can also switch directly to the PIC16F877, which offers additional peripheral interfaces, especially if you want to connect some IC peripheral components:

PIC16F877

same pin-out as the PIC16F77


superior features compared to PIC16F77:
- 10-bit A/D converter (8 channels)
- IC master mode
- internal EEPROM (256 bytes non-volatile memory)
- analog comparators
total of 15 interrupt sources (internal and external interrupts)
self-reprogrammable under software control (boot-loader)
40 pin package (DIP40)

Get the latest data sheets at www.microchip.com

Which development environment do I use? [Toc] [Top]

I started with the PICSTART Plus development programmer from Microchip in 1998, and I still use the same programmer today:

PICSTART Plus Programmer: with firmware v4.30.04 (software-upgradable), RS232,


costs about 200.00 US-$, ordering information
In-Circuit Debugger 2: (ICD2) bought recently, USB1.1 & RS232,
costs about 200.00 US-$ with 40 pin ICD header and power supply, ordering information
Microchip MPLAB IDE v7.10: free development environment using PIC assembler

http://www.electronic-engineering.ch/microchip/faq/faq.html (3 of 12)12/02/2008 17:13:14


FAQ for Microchip PIC 8 bit microcontroller programming

PICSTART Plus Programmer In-Circuit Debugger 2 (ICD2)


from Microchip, incorporates the flash-upgrade kit from Microchip, allowing to debug the current processor state, internal
and latest firmware registers and EEPROM data by setting breakpoints in the program code
(#DV003001, ~200.00 US-$) within the MPLAB IDE development environment
(#DV164005 or #DV164007, #AC162051, ~200.00 US-$)

This setup programs most PIC microcontrollers (PIC12xxx, PIC16xxx, PIC17xxx, PIC18xxx), and allows firmware updates whenever new PIC controllers come out. I have never experienced any
issues using this commercially available programmer with the Windows operating system (Win95, Win98, WinXP). You just have to ensure that the intended RS232 port to use is in the range of
Com1 to Com4.

The latest version of the PICSTART Plus programmer allows instant software-based firmware updates to the internal flash controller. See buy.microchip.com for ordering details.

PICSTART Plus Processor Upgrade Kit


from Microchip, includes flash-based microcontroller for
firmware upgrades
(#UK003010, ~29.00 US-$) PICSTART Plus Programmer PICSTART Plus Programmer
before installing the upgrade kit, just with after installing the PICSTART Plus Processor Upgrade Kit
PIC17C44JW and firmware v3.11

Years ago, I had to buy an extra PIC controller (UV-erasable PIC17C44JW) and had to burn the corresponding firmware to it (HEX-file supplied with MPLAB IDE). But Microchip abandoned this
re-programming procedure of the 17C44JW some times ago. Today, the firmware upgrade of the programmer is performed directly from MPLAB IDE, but only if you have one of the lastest flash-
based PICSTART Plus programmer, or installed the PICSTART Plus Processor Upgrade Kit (containing a PIC18F6720) in your elderly programmer (#UK003010, costs about 29.00 US-$, ordering
information).
http://www.electronic-engineering.ch/microchip/faq/faq.html (4 of 12)12/02/2008 17:13:14
FAQ for Microchip PIC 8 bit microcontroller programming

For ambitious starters, I recommend to order:

In-Circuit Debugger 2 (ICD2): #DV164005 or #DV164007 (additional RS232 cable & power supply)
40 pin ICD header: #AC162051
optional: Universal Programming Module for ICD2: #AC162049

Note that with ICD2:

the PIC16F87x can be both, in-circuit debugged and programmed


the PIC16F7x can only be programmed
the PIC16F84A can only be programmed

Please see also the latest* README text files for PICSTART Plus (17 kB) & ICD2 (32 kB)
* by 19.06.2005

Citing Microchip's readme.txt of PICSTART Plus programmer:

"Program and read problem of PIC16F87X

PIC16F87X devices are shipped with low-voltage programming enabled. PICSTART Plus programmer uses
the high-voltage programming method. Some devices do not exit programming mode properly if low-voltage
programming is enabled, resulting in invalid read and programming operations.

Place a 10 Kohm resistor between the RB3 pin and one of the ground pins on the programming socket. Refer
to the device datasheet for the pinout of the specific device."

First steps in PIC programming [Toc] [Top]

As first step, read the documentation of your controller, especially the memory and register architecture, the instruction set (PIC Instruction Set Quick Reference) and the I/O port section. Then try to
implement a blinking LED application using the PIC16F84 and a busy loop for waiting (you can also use my assembler module m_wait.asm).

If your LEDs are blinking, you certainly want to connect your controller to your PC to exchange some data. Build a RS232 hardware setup with a MAX232 level shifter and a PIC. If you use the
PIC16F84, the RS232 communication must be done by software. You can use the 'Simple RS232 interface'. Try first to burn the provided HEX-file onto the PIC16F84 to check for proper HW-setup.
Once everything is working well, you can get the assembler source code and change the content according to your needs.

Common programming questions [Toc] [Top]

Question: What kind of instructions are BANK1 and BNEQ?

Answer: These are my standard macro definitions declared in the module file m_bank.asm. If you include this module file in your main program, you can make use of these instruction macros. For
instance, the macro BANK1 performs a memory bank change to bank 1. Further, the macro BNEQ 0x23,LAB1 translates to 'branch on not equal w and 0x23' and performs a jump to label LAB1, if
the working register w does not match the value 0x23.

http://www.electronic-engineering.ch/microchip/faq/faq.html (5 of 12)12/02/2008 17:13:14


FAQ for Microchip PIC 8 bit microcontroller programming

Question: What kind of instructions are BNZ and SKPNZ, since they are not listed in the Instruction Set Chapter of my PIC controller?

Answer: These are 'Special Instruction Mnemonics' listed in Table B.11 in the PIC Instruction Set Quick Reference, i.e. built-in mini-macros of the MPLAB assembler. For instance, SKPNDC
translates as 'Skip on no digit carry' and simply assembles BTFSC 3,1.

How to assemble PIC code in MPLAB [Toc] [Top]

Only declare the main assembler file as source file in the MPLAB project. For instance, this is the file PIC_Test.asm in the project PIC_Test.mcp below on the picture. It will generate a HEX-file
named PIC_Test.hex when you execute 'build' or 'build all'. Ensure that the pathes to the include files exist - or remove the pathes and copy the include files to the directory of the main source.

The include files must not be listed for separate compilation under the MPLAB Project. They are just included in the main source through include statements. During assembly time (MPASM), these
files are just inline expanded and treated as normal assembler code. Separate compilation is neither needed nor possible, since I've written the module code for inline compilation (and initially for
simplicity) with no object or linker directives.

Of course, when project size and complexity increases, one may consider to rewrite the code to object-based sources...

MPLAB IDE
showing the project source file (PIC_Test.asm)
to be assembled by MPASM.

Advanced steps in PIC programming [Toc] [Top]

http://www.electronic-engineering.ch/microchip/faq/faq.html (6 of 12)12/02/2008 17:13:14


FAQ for Microchip PIC 8 bit microcontroller programming

General [Toc] [Top]

Once the communication between the PIC controller and the PC is running successfully, I suggest to implement a visual interface on your peripheral device (the PIC controller). This can be done
easiest by using a commonly available dot matrix LCD and one of my LCD assembler modules.

If more sophisticated I/O functionality is desired, you can consider to attach a standard AT keyboard (ordinary PS/2 PC keyboard) to the microcontroller. Look therefore at the AT keyboard projects.

Paging - large code considerations [Toc] [Top]

When your code grows, you will run into the architectural issues of the PIC microcontroller. The PIC instruction set has been defined - in early days - as a natural engineering trade-off between
functionality and program memory requirements. One advantage of a larger instruction word width is the increase in direct addressable space for immediate instructions, e.g. 'CALL Label' with Label
resolved to a program memory location by the linker/assembler. On the contrary, larger instruction word width require more program memory, what results in larger chip area and therefore higher
manufacturing costs.

The PIC16xxx microcontroller series features immediate address instructions (e.g. 'CALL' or 'GOTO'), which support 11 bit immediate values. Using 11 bits for immediate addressing, we can only
address 2k words in the program memory. But what if we want to support larger memory space? One possibility to work around this limitation is to introduce a new instruction in order to jump
between the different 2k memory blocks. That's why we need to deal with the upper two bits ([4:3]) of the PCLATH register. These bits cannot be altered with 'CALL' or 'GOTO' instructions, but
need to be set manually before the jump.

There is quite a good discussion and elaboration of methods to deal with paging for the PIC16xxx microcontrollers on this site.

High-level languages [Toc] [Top]

C [Toc] [Top]

There exist several commercial solutions to program the PIC microcontroller in C. Unfortunately, little of them are available for free.

If you know other free C compilers, you are kindly requested to email me. I will add it to the list below.

List of free C compilers (not exhaustive):

A limited edition of HI-TECH's PIC C compiler is available for free on this site. It is intended to be used with PIC16F84 and 16F877, although with limitations in memory usage and/or code
size. (No personal experience with this compiler so far.)

Debugging hints [Toc] [Top]

General [Toc] [Top]

Write only small pieces of new code, whenever possible within a simplified test program.
Most hobby-developers have no expensive in-circuit debugger tool (real-time debugging in the target application using specific software, with breakpoints and register watches). Use therefore
dot matrix LCD and/or RS232 interface for debugging.
Use encapsulated well-verified blocks, which you put together as parameterizable building blocks in the target application.
For large projects, try to use object code and the linker provided by Microchip MPASM IDE.

http://www.electronic-engineering.ch/microchip/faq/faq.html (7 of 12)12/02/2008 17:13:14


FAQ for Microchip PIC 8 bit microcontroller programming

RS232 communication issues [Toc] [Top]

In case you have built a PIC application including serial communication (RS232), but it does not work properly, try to debug it the following way:

1. Write a simple PIC assembler program for the PIC16F84 @ 4 MHz using the module m_rs096.asm. The program keeps transmitting a dedicated character every second, e.g. something like:

LOOP SEND '@'


WAITX d'16',d'7' ; 1.045 s @ 4 MHz, extended with specific prescaler
goto LOOP

You may also use one of the communication test programs, commtest1.asm or commtest2.asm, which transmit constantly status messages '@' and echo on every received character.

2. Setup the HyperTerminal program (Win9x, WinXP) using the standard settings as follows:

Standard RS232 ComPort settings


(9600-8-N-1)

Start the HyperTerminal application using the standard settings. It should now receive a '@' every second from the PIC microcontroller. If not, check the MAX232 and the RS232 connectors, until
you receive the characters...

http://www.electronic-engineering.ch/microchip/faq/faq.html (8 of 12)12/02/2008 17:13:14


FAQ for Microchip PIC 8 bit microcontroller programming

LCD communication issues [Toc] [Top]

Question: I can not figure out the connection between dot matrix LCD and PIC microcontroller. Do you have a schematic?

Answer: Basically, there is a text description in the header section of each LCD assembler module file. But here is also a PDF schematic to illustrate the connection between display and controller.

Question: I have downloaded from your site the assembler module file 'm_lcd_bf.asm' for my PIC project. The LCD display I use is a 20x4 (CrystalFontz CFAH2004A-TMI-JP), but it does not
work. I dont see any character and the problem is not the contrast

Answer: I've recently adapted some parts of the initialization section of the LCD module files (longer wait delay after display clear). I assume you have a newer type of display controller than the
traditional Hitachi HD44780 (PDF data sheet, 389 kB). In case you have the LCD controller Samsung KS0073 (PDF data sheet, 673 kB), you have to set the constant 'LCDTYPE' to 0x1 in your main
program. This adds specific configuration commands of the new controller type, i.e. the extended function set to set up the line count (PDF data sheet, 186 kB). You may have to adapt the line count
to your KS0073-type display in the extended function set part of the LCD initialization section of the LCD module file (e.g. m_lcde.asm).
If this does not help, try to use longer delays for the initialization procedure.

Below the declarations for the module file m_lcde.asm. First try the circuit with a 4 MHz crystal, later on with 20 MHz. If this does not work, you may have to adapt the initialization section to your
specific display controller (latency, commands). But first try with the standard settings for PIC16F7x and 4 MHz:

LCDtris equ TRISD ; LCD data on low nibble of portD


LCDport equ PORTD
#define LCD_ENtris TRISE,0x00 ; EN on portE,0
#define LCD_EN PORTE,0x00
#define LCD_RStris TRISE,0x01 ; RS on portE,1
#define LCD_RS PORTE,0x01
#define LCD_RWtris TRISE,0x02 ; RW on portE,2
#define LCD_RW PORTE,0x02

CONSTANT BASE = 0x20 ; base address of user file registers

#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcde.asm"

In case of failure, ensure that you do not use the temporary registers at BASE+0 - BASE+3 elsewhere in your code, especially not in your interrupt service routine (ISR)! If this setup works perfectly,
you may upgrade to the more efficient LCD modules m_lcde_bf.asm or m_lcdexbf.asm (busy flag instead of wait loop).

In case of errors [Toc] [Top]

Compile errors [Toc] [Top]

If you cannot compile the projects and errors like below appear, you did not specify the path to your include files correctly. Check the '#include' statements:

http://www.electronic-engineering.ch/microchip/faq/faq.html (9 of 12)12/02/2008 17:13:14


FAQ for Microchip PIC 8 bit microcontroller programming

#include "..\m_bank.asm"
#include "..\m_wait.asm"

The errors generated by wrong '#include'-pathes look like:

Executing: "C:\Tools\Electronics\MPLAB_64\MCHIP_Tools\mpasmwin.exe" /q /p16F84 "LCDx_test.asm" /


l"LCDx_test.lst" /e"LCDx_test.err"
Error[101] ..\..\M_LCD.ASM 113 : ERROR: (Missing include file: m_bank.asm)
Error[101] ..\..\M_LCD.ASM 116 : ERROR: (Missing include file: m_wait.asm)
Error[113] ..\..\M_LCD.ASM 279 : Symbol not previously defined (LCDclk)
Error[113] ..\..\M_LCD.ASM 283 : Symbol not previously defined (LCDclk)
Error[122] ..\..\M_LCD.ASM 290 : Illegal opcode (WAIT)
Error[122] ..\..\M_LCD.ASM 296 : Illegal opcode (LCDWAIT)
Error[116] ..\..\M_LCD.ASM 184 : Address label duplicated or different in second pass (BANK0)
Error[108] ..\..\M_LCD.ASM 189 : Illegal character (4)
Error[113] ..\..\M_LCD.ASM 193 : Symbol not previously defined (LCDclk)
Error[122] ..\..\M_LCD.ASM 194 : Illegal opcode (LCDWAIT)
Error[113] ..\..\M_LCD.ASM 200 : Symbol not previously defined (LCDclk)
Error[122] ..\..\M_LCD.ASM 201 : Illegal opcode (LCDWAIT)
Error[113] ..\..\M_LCD.ASM 205 : Symbol not previously defined (LCDclk)
Error[122] ..\..\M_LCD.ASM 206 : Illegal opcode (LCDWAIT)

Page crossings [Toc] [Top]

Although most of my code is below the critical size of 2k instruction words, page crossings may occur if you extend the assembler source code to your needs. Please read the recommendations about
paging above.

PIC history [Toc] [Top]

Below are some interesting text snippets found on the web about the history of Microchip PIC controllers.

Call it RISC... [Toc] [Top]

Citing John Bayko (Tau), <[email protected]>:

A complete version of John Bayko's interesting 'Great Microprocessors of the Past and Present' may be retrieved at http://www.sasktelwebsite.net/jbayko/cpu.html.

The roots of the PIC originated at Harvard university for a Defense Department project, but was beaten by a simpler (and more reliable at the time) single memory design from Princeton. Harvard
Architecture was first used in the Signetics 8x300, and was adapted by General Instruments for use as a peripheral interface controller (PIC) which was designed to compensate for poor I/O in its 16
bit CP1600 CPU. The microelectronics division was eventually spun off into Arizona Microchip Technology (around 1985), with the PIC as its main product.
The PIC has a large register set (from 25 to 192 8-bit registers, compared to the Z-8's 144). There are up to 31 direct registers, plus an accumulator W, though R1 to R8 also have special functions -
R2 is the PC (with implicit stack (2 to 16 level), and R5 to R8 control I/O ports. R0 is mapped to the register R4 (FSR) points to (similar to the ISAR in the F8, it's the only way to access R32 or
above).
http://www.electronic-engineering.ch/microchip/faq/faq.html (10 of 12)12/02/2008 17:13:14
FAQ for Microchip PIC 8 bit microcontroller programming

The PIC16x is very simple and RISC-like (but less so than the RCA 1802 or the more recent 8-bit Atmel AVR microcontroller which is a canonical simple load-store design - 16-bit instructions, 2-
stage pipeline, thirty-two 8-bit data registers (six usable as three 16-bit X, Y, and Z address registers), load/store architecture (plus data/subroutine stack)). It has only 33 fixed length 12-bit
instructions, including several with a skip-on-condition flag to skip the next instruction (for loops and conditional branches), producing tight code important in embedded applications. It's marginally
pipelined (2 stages - fetch and execute) - combined with single cycle execution (except for branches - 2 cycles), performance is very good for its processor catagory.

The PIC17x has more addressing modes (direct, indirect, and relative - indirect mode instructions take 2 execution cycles), more instructions (58 16-bit), more registers (232 to 454), plus up to 64K-
word program space (2K to 8K on chip). The high end versions also have single cycle 8-bit unsigned multiply instructions.

The PIC16x is an interesting look at an 8 bit design made with slightly newer design techniques than other 8 bit CPUs in this list - around 1978 by General Instruments (the 1650, a successor to the
more general 1600). It lost out to more popular CPUs and was later sold to Microchip Technology, which still sells it for small embedded applications. An example of this microprocessor is a small
PC board called the BASIC Stamp, consisting of 2 ICs - an 18-pin PIC16C56 CPU (with a BASIC interpreter in 512 word ROM (yes, 512)) and 8-pin 256 byte serial EEPROM (also made by
Microchip) on an I/O port where user programs (about 80 tokenized lines of BASIC) are stored.

Scientific curiosity [Toc] [Top]

Citing Len Umina <[email protected]> from http://www.brouhaha.com/~eric/pic/faq.txt:

Actually, the PIC architecture was first integrated by Signetics for a company in San Jose (Scientific Memory Systems as I recall) using Bipolar technology and dubbed the 8X300. Prior to that, the
architecture had been a scientific curiosity since its invention by Harvard University in a Defense Department funded competition that pitted Princeton against Harvard.

Princeton won the competition because the mean time between failure (MTBF) of the simpler single memory architecture was much better, albeit slower, than the Harvard submission. With the
development of the transistor and IC's, the Harvard Architecture is finally coming into its own.

Microchip has made a number of enhancements to the original architecture, and updated the functional blocks of the original design with modern advancements that are in concert with existing
architectural processes and
enabled by the low cost of semiconductors.

From I/O handling to RISC controller [Toc] [Top]

Citing Alex R. Baker <[email protected]> from http://www.brouhaha.com/~eric/pic/faq.txt:

Back in 1965, General Instruments (GI) formed a Microelectronics Division, and indeed used this division to generate some of the earliest viable EPROM and EEPROM memory architectures. As
you may be aware, the GI Microelectronics Division were also responsible for a wide variety of digital and analog functions, in the AY3-xxxx and AY5-xxxx families.

GI also generated a 16 bit microprocessor, called the CP1600, in the early 70s. This was a reasonable microprocessor, but not particularly good at handling I/Os. For some very specific applications
where good I/O handling was needed, GI designed a Peripheral Interface Controller (or PIC for short), in around 1975. It was designed to be very fast, since it was I/O handling for a 16 bit machine,
but didn't need a huge amount of functionality, so its microcoded instruction set was small. Hopefully, you can see what's coming....yes, the architecture designed in '75 is substantially the PIC16C5x
architecture today. Granted, the1975 version was manufactured in NMOS, and was only available in masked ROM versions, but still a good little uC. The market, however, didn't particularly think
so, and the PIC remained designed in at a handful of large customers only.

During the early 80s, GI took a long hard look at their business, and restructured, leaving them to concentrate on their core activities, which is essentially power semiconductors. Indeed they are still
doing this very successfully now. GI Microelectronics Division became GI Microelectronics Inc. (a wholly owned subsidiary), which in 85% was finally sold to venture capital investors, including
the fab in Chandler, Arizona. The venture capital people took a long hard look at the products in the business, and got rid of most of it - all the AY3- and AY5- parts and a whole bunch of other stuff,
leaving the core business of the PIC and the serial and parallel EEPROMs. A decision was taken to restart the new company, named Arizona Microchip Technology, with embedded control as its
differentiator from the rest of the pack.

http://www.electronic-engineering.ch/microchip/faq/faq.html (11 of 12)12/02/2008 17:13:14


FAQ for Microchip PIC 8 bit microcontroller programming

As part of this strategy, the PIC165x NMOS family was redesigned to use one of the other things that the fledgling company was good at, i.e. EPROM - the concept of the CMOS based, one-time-
programmable (OTP) and eraseable EPROM program memory PIC16C5x family was born.

Last updated: 04.12.2005

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.electronic-engineering.ch/microchip/faq/faq.html (12 of 12)12/02/2008 17:13:14


PICmicro Sites

Iron WebMaster Round 2 VOTING is underway. Get in on the action!


Welcome, Guest HOME DIRECTORY HELP SIGN IN

TELL A
SEARCH WEBRING: This WebRing All
FRIEND!
Computers & Internet > Hardware Add this feed:
PICmicro Sites Add Your
Manager: uandmekids Web Site.
Join Here!

SEARCH in This WebRing All

Iron WebMaster
A collection of websites about the Microchip PIC microcontroller and related projects.
example: jonathan's PIC ASM and PC Programming Project - **Updated 5/17/07** On

Round 2 VOTING
this web site you will find code, libraries, programs, and accompanying projects using PIC
Assembly Language. The keynote project is a PC based Oscilloscope I call the
PPMScope. Get in on the Action!
Ads by Google WebRing Rating Survey
Amazing PIC programmer Which of these statements best describes your
Just $32, most devices supported ICSP, SQTP, copy-limit features. experience(s) with this Ring?
www.flexipanel.com Only members who are logged in may register a vote. You
are either not logged in or not a WebRing member. Use the
Automatic code generator Sign In link at top to log in or register for a WebRing User ID.
LPC2xxx embedded systems CAN - Ethernet - PWM - ADC - RTOS.
www.TTE-Systems.com Easy to navigate with interesting sites.

Asian Personals Easy to navigate with OK sites.


Asian singles seek love, dating and marriage. Join free today.. www.
Easy to navigate but poor sites.
AsianEuro.com
hard to navigate with great sites.
Mature Pic
View Mature Pic 1000s of Beautiful Mature Women.. www-My- hard to navigate with OK sites.
OnlineDating.com
hard to navigate and poor sites.

submit my vote
view results without voting

Check out similar sites on


http://o.webring.com/hub?ring=picmicro (1 of 4)12/02/2008 17:13:31
PICmicro Sites

Hub Page Sites Traffic Stats Forum Similar WebRings


Ads by Google
Featured site(s) PIC & AVR C Compilers
Pic Projects - First steps with the PIC Processors Compile, Simulate, Program!
First steps with the 16F876 and other PIC processors, C & Basic, links, projects (LCD, VOIP Desk Phone, IDE's, Programmers &
Add DRAM to 16F876, Cheap Keypad ) etc. Development
www.fored.co.uk
Ring sites Showing 1 - 19 of 174 Next
Procesadores embebidos
19 >
Conexin TCP/IP. Mdulos
Ethernet. Mdulos Radio.
DonTronics - In Business Since 1964 - Home of SimmStick Marca Rabbit.
www.matrix.es
Microcontroller and Electronics related hardware and software.
Programming solutions
Gooligum Electronics for engineering and
Design and supply of electronic kits, mainly based on PIC microcontrollers, with an emphasis on fun. manufacturing Flash,
microcontroller, FPGA, SoC
J.D.Petkov's homesite www.dataio.com
MIDI related hardware applications, based on PIC mcu's (in 'Hardware' section). Luminary Micro Stellaris
The first ARM CortexM3
PicProgrammers hardware and packet radio
MCUs 32bit performance
PCB-design and shematic for ProPic4.2 and ProPic2 starting at $1.00
www.LuminaryMicro.com
Practical PIC Projects @ picprojects.org.uk
Advertise on this Site
An assortment of circuits based on 12F and 16F series PICs including addressable PWM controller for RGB
LEDs. Make MONEY!
Microchip PIC Project resource and guide page Add
picguide.org was made to put all Microchip PIC MCU Projects on one place, to help the beginner get started Pay-Per-Play
and to minimize the time to find useful information and resources related to the PIC MCU. ads to your website
GenerExe: home of XPad Design tool and cross-compilers Make MONEY!
GenerExe developed XPad, a Visual design tool, making it easy to design, program, simulate, document and
compile software for small to medium sized embedded systems. Add
Pay-Per-Play
The Micro Stop ads to your website
The Micro Stop - RS232 and microcontroller schematics and C code, a lot is free! New, inexpensive RS232
C libraries for Hitech/Pic16x8x! A variety of microcontroller projects including a digital thermometer and digital
volt meter.

http://o.webring.com/hub?ring=picmicro (2 of 4)12/02/2008 17:13:31


PICmicro Sites

picsystems
this group is about PIC projects.

Bert's PICmicro and Hardware Development Resources


This is a set of up-to-date links to some of the best PICmicro and hardware development related resources
I've found.

Homepage of Johan Granzier


Jal Editor, Pic16F84 projects made with Jal, Electronics, Etching

Nyholms PIC Site!!


Take a look at my Car Alarm with a PIC16F84 microcontroller.

Dincer's PIC Page


Using Z80 like mnemonics to write PIC programs.

microelectronics info for hobbyist


Informations about microelectronics, microcontrollers and other stuff I found interesting.

Andy Programming
View and get updates of current and future projects, download source code for both windows and dos.

Mat's electronics corner


Place for the electronics enthusiast.

Robotics UK
Welcome to robotics UK, i'll show you how to use a PIC in robotics

Picl by EarthLCD.com "We Make LCD's Work"


The PicL by EarthLCD.com is a low cost PIC16F877 Based 240 x 64 Monochrome - Also ezLCD-001 is the
only COLOR graphic LCD that will work with the Basic Stamp!!! IT features a COLOR 2.7" reflective 256
color TFT

jonathan's PIC ASM and PC Programming Project


**Updated 5/17/07** On this web site you will find code, libraries, programs, and accompanying projects
using PIC Assembly Language.

Ring sites Showing 1 - 19 of 174 Next


19 >

http://o.webring.com/hub?ring=picmicro (3 of 4)12/02/2008 17:13:31


PICmicro Sites

WHAT'S NEW MOST POPULAR BLOGS GET STARTED FORUMS CONTACT US

Copyright 2001-2008 WebRing, Inc. All rights reserved. Terms of Service - Help
Notice: We collect personal information on this site.
To learn more about how we use your information, see our Privacy Policy
WebRing server hosting provided by SimpleNet.

http://o.webring.com/hub?ring=picmicro (4 of 4)12/02/2008 17:13:31


Davshomepage

Back to Last update:

homepage 9/1/2006

Welcome to my site
Decode IR
RC5 code PICmicro Sites
Panasonic code Get this free Prev | Ring Hub | Join | Rate|
software Next
Daewoo protocol
WebRing Inc.
Search
Sony code
Pic sourcecode for
You can find on my site:
Sony IR protocol
JVC protocol Information about infrared light:
Tinyserir-RC5
Decode ir: On this page you can find a description about the basics of using infrared light for remote control,
RC5 receiver
what you need to decode it and what you can do with it: for example control you pc, windows, winamp or mp3
pic18f bootloader player.
PIC sourcecodes
Detailed description of the folowing different remote protocols:
Leds
Constant current RC5 protocol: Originally developed by Phillips and the most popular for hobby projects.
source for Leds Sony SIRC protocol:Also popular for hobby but less than the rc5 protocol
Always winning with Panasonic protocol
roulette JVC protocol
Daewoo protocol
Datasheets
Links
Who am I

http://users.telenet.be/davshomepage/ (1 of 3)12/02/2008 17:13:55


Davshomepage

Control your pc with an infrared remote protocol, Pic sourcecodes and hobby projects:

Pic sourcecode for sony ir protocol: Here you can find the sourcecode and hexfiles to decode infrared signals of
a sony remote control with a pic microcontroller. With the buttons 0..9 you can control the output pins of the
controller.
The code is also serial transmitted on an output pin you can directly connect it to a pc and control windows or
mediaplayer and etc..
Pic sourcecodes:Here you can find different source codes for the microchip pic microcontrollers like the
pic16f84,pic16f628,pic12f629,pic12f675.

Tinyserir chip: A preprogrammed pic microcontroller for decoding RC5 infrared remote controls.

Tinyserirchip: Here you can find the description, the testprogram and datasheets of the tinyserirchip. You can
use this cheap and easy to use chip to control your pc, plc, robot and everything with a serial port. Because
windows is not realtime it can be hard to decode the fast ir signals. Because you need to sample many times it can
also slow down your system many times. But with the use of the tinyserirchip you can solve all these problems.

A microchip pic18f bootloader: The easy way to program your pics.

Bootloader page Yep here you can find how to make your own simple bootloader based on the application note
00851 of microchip, but I changed this a little bit.

Leds and constant current source information.

Leds: On this page you can find out what leds are, how you can connect it properly without troubles. How you
need to calculate the right value of the series resistor.
Constant current source: Here a detailed descripton of a constant current source with a LM317, how to use and
calculate them and of course the schematic (circuit). You can use it to connect white or blue leds, Luxeon
lumileds

http://users.telenet.be/davshomepage/ (2 of 3)12/02/2008 17:13:55


Davshomepage

Always winning in the casino with roulette: it's not about cheating or other illegal actions but a simple trick.

Allways winning with roulette: Here you can read a tip for free how you can allways win with a roulette game
in a casino or online casino's. It's simple and pure mathematical not difficult to understand how it works.

Links and datasheets:

Links: A page with links of other electronic related pages.


Datasheets: Here you can some datasheets of electronic components.

http://users.telenet.be/davshomepage/ (3 of 3)12/02/2008 17:13:55


Talking Electronics Home Page

Click HERE to buy the CD for $9.95 posted!

Our PIC Logic Probe with Pulser is ready!!!


5x7 Display is ready!!!
Multi-Chip Programmer is ready!!!
NEW! Dis-assembler for PIC16F84
NEW! "In-Circuit" Electrolytic Tester - is ready!!
NEW! Dial Alarm-1 - not ready a complete dialing alarm
the size of a pack of cigarettes!
NEW! TAXI PHONE - not ready auto dialing project.
NEW! PICF84 Data!
NEW!
NEW! Testing Transistors Diodes, Zeners, SM database!!
NEW! Circuit Symbols!
Latest News (newsletter) This is where all the latest news is placed.
NEW! 500 Pages of Theory! More than 500 pages of
electronics theory brought to you by Integrated Publishing.
(read 10 pages each time you visit and it will only take 2 months!)
(Do not click the "Message Alert" sign on this site - it is very annoying!)

Welcome to Talking Electronics PIC Programming Course.


This course covers the exciting world of programming PIC microcontrollers.
(Programmable Interface Chips). The two devices we are covering are PIC 12c508A and PIC
16F84.
Before starting this course you should have a good knowledge of basic electronics - especially
Play this game of 21 and see if connecting pick-up devices to the input of a microcontroller.
you win!! If you are starting-out, you should go to our BASIC ELECTRONICS course. It covers the design of
transistor stages (Interface Stages) needed to connect transducers (pick-up devices such as coils,
microphones, glass breakage detectors, etc) to PIC micro-controllers.
Once you know about Interfacing, you can go to PIC Theory section (covers the programming of
the two PIC chips), then the PIC Projects section, where you will find lots of applications for these
amazingly versatile chips. The first PIC project in this section is a Logic Probe with Pulser and
then a 5x7 Display project. You will also need our Multi-Chip Programmer to burn a PIC12c508A
for the Logic Probe. We have just designed an "add-on" for the 5x7 Display, an "In-Circuit"
Electrolytic Tester and are presently in the process of preparing the article for a '508A Dialing
Alarm. All the software for the projects can be downloaded via .zip files: 5x7 Display
Start New Game Experiments. The software for the multi-Chip programmer is: IC-PROG, (it's 500k!) see also: IC-
The dealer
Prog help-line and IC-Prog message Board To compile your .asm files to .hex you will need:
Deal me! MPASM.
always wins!!
Stand All our projects are designed to teach you both the theory of how the circuit works and how the
program for the microcontroller works. Never before has so much detail gone into a set of
projects. After you build a few of them you will have a good grounding in the basics of designing
and programming. Kits are available for everything and it's just a matter of getting started.

NEW BOOK 15th July

http://users.tpg.com.au/users/talking/ (1 of 3)12/02/2008 17:14:23


Talking Electronics Home Page

I am in the process of putting all the theory in the Library of Terms and Routines into a 400
page book with 4 main projects plus a number of other articles. This is a major undertaking and
although most of the information is available on the website, the convenience of having it in a
single reference source is driving me to complete the task - mainly because I want to have it as a
reference source myself. In the process, the work is being revised, updated and corrected.
The book will be published by TAB books and will cost US$24.95 It is still 2 months from
completion, then two more months for publishing and printing.
I will let you know when the release date comes closer.

New Things have happened! 30th September 2001


Some radical changes have occurred recently. I have been asked to start a new e-magazine for
POPTRONICS called POPTRONICS Interactive Edition. Read the full details in the
Newsletter.
After one year of writing for the site, I have removed my services and started my own interactive
site: TALKING ELECTRONICS Interactive.
The arrangement was quite simple. I was to provide an interactive site for the largest paper
magazine in the USA - POPTRONICS. All they had to do was put an article in their magazine
each month with a link to the site so the remainder of my detailed projects could be downloaded
from the web.
I sent them an article and waited. I sent them another article and waited. I sent them another
article and waited. I waited one year for a response! Not once did they reply!
The next thing I heard was the collapse of the magazine POPTRONICS!
How could you fail to be successful in the largest country IN THE WORLD?
Since I have not had a reply from the projects manager or the CEO of POPTRONICS, I have
decided to put all my projects on my own site: TALKING ELECTRONICS Interactive.
I have finally taken my own advice. Do everything yourself and don't rely on anyone to
do anything for you.

I think you will like my new site.

All the best


Colin.

100,000
hits plus:

Powered
by
counter. [Skip Prev] [Prev] [Next] Previous 5 Sites | Skip Previous |
bloke. [Skip Next] [Random] [Next 5] Previous | Next
com [List Sites] [Join Ring] Skip Next | Next 5 Sites | Random Site
| List Sites

PREV RANDOM LIST NEXT


<- 2 JOIN ABOUT 2 ->

Contact Information:

http://users.tpg.com.au/users/talking/ (2 of 3)12/02/2008 17:14:23


Talking Electronics Home Page

If you like this site, please recommend it!

Colin Mitchell
To (email): Talking Electronics
PO Box 486
Your e-mail:
Cheltenham,
Victoria, 3192
You can add your comments TOO! Australia

Talking Electronics,
Take a look at Talking Electronics 35 Rosewarne Avenue,
site: http://www4.tpg.com.au/users/ Cheltenham 3192
talking/index.html It has PICF84 Victoria Australia
micro programming and lots of Basic
Electronics Theory, with circuits that Tel: (03) 9584 2386
"move" on thesend
page! Also try their Fax: (03) 9583 1854
"easy" address: http://all.at/te
Website address: www4.tpgi.com.au/users/talking/ email: [email protected]

Not Copyright 2003 Colin Mitchell - you can copy anything - in fact you should copy all the projects and data
sheets.

http://users.tpg.com.au/users/talking/ (3 of 3)12/02/2008 17:14:23


internet services hosting talk the at theempirenet.com

Welcome to theempirenet.com

Internet Services

Hosting Talk

The Empirenet

Empirenet

Way International

MS

Home Shopping

Next

Catalog

Staples

Comet

Pets and Pet SuppliesWeddingRetailUtilities SupplierFoodWeddings

http://theempirenet.com/eewebring/index.html12/02/2008 17:14:28
Electronics Engineering

Iron WebMaster Round 2 VOTING is underway. Get in on the action!


Welcome, Guest HOME DIRECTORY HELP SIGN IN

TELL A
SEARCH WEBRING: This WebRing All
FRIEND!
Engineering > Electrical Add this feed:
Electronics Engineering Add Your
Manager: uandmekids Web Site.
Join Here!

SEARCH in This WebRing All

Iron WebMaster
The Electronics Engineering Web Ring is dedicated to all web sites and users that
participate in the world of electronic engineering. Only sites that are seen to be

Round 2 VOTING
contributing to the community will be added to the ring. Sites purely advertising goods or
filled with links to other sites will unfortunately be rejected. This web ring is completely
open to the public. Get in on the Action!
example: Electronics 2000 - Electronics 2000, for electronics hobbyists, engineers and
students. Online calculators, software downloads, technical data, beginners guide, WebRing Rating Survey
pinouts, forum, links and more. Which of these statements best describes your
experience(s) with this Ring?
Ads by Google Only members who are logged in may register a vote. You
are either not logged in or not a WebRing member. Use the
USB Instruments Sign In link at top to log in or register for a WebRing User ID.
USB PC Scopes, Logic Analyzers Data Loggers, Waveform
Generators. www.usb-instruments.com Easy to navigate with interesting sites.
Hytronic Electronics Easy to navigate with OK sites.
Electronic Transformer Various Ballasts and Motion Sensors. www.
hytronik.com Easy to navigate but poor sites.

PC based instruments hard to navigate with great sites.


Data Acquisition, Signal Generation and Digital I/O with Matlab driver. hard to navigate with OK sites.
www.spectrum-instrumentation.com
hard to navigate and poor sites.
PC Oscilloscope for $495
80 Ms/s oscope, logic analyzer, and waveform generator via USB for
$495. www.dynoninstruments.com submit my vote
view results without voting

Check out similar sites on


http://q.webring.com/hub?ring=eewebring (1 of 3)12/02/2008 17:14:48
Electronics Engineering

Hub Page Sites Traffic Stats Similar WebRings


Ads by Google
Featured site(s) School or Factory Bells
Pic Projects - First steps with the PIC Processors School Bell, Ring Class
First steps with the 16F876 and other PIC processors, C & Basic, links, projects (LCD, VOIP Desk Phone, Change Factory Break or
Add DRAM to 16F876, Cheap Keypad ) etc. School Bells
www.ats-usa.com
Ring sites < Prev 9 | Next
Madell Oscilloscopes
9>
Analog, digital, NT
oscilloscopes, 10Mhz and
Free electronic projects for hobby and not only.. up, start from $150.
http://www.madelltech.com
Electronic stuff, my projects, from ISA-bus expanded board, ISA-bus AD converter, thermometer and
thermostat, PIC16x84 and PIC16F877 applications, audio application, to high efficiency bulb schematics and osciloscopios Yokogawa
radar detector project. Nuevos gama 200MHz hasta
1,5 GHz osciloscopio 1GHz
K&I Electronics 4 ch 9900
Electronic Engineering Hobby Website for electronic and embedded enthusiasts. yokogawa.com/tm
Digital Oscilloscopes
Ben's HobbyCorner
High quality test equipment.
Home-made 80C535/C515/AT89C2051- microcontroller system with I2c, LCD-display, steppermotors on We sell to vendors who sell
single-sided PCB's. to you.
www.celutek.com
alfredo alfonsi electronics pages
Advertise on this Site
various interesting schematics such as: IR system for your room, homemade smt reworking station,
programmers, vga -tv converter, tutorial, tips and tricks.......have a look ! Make MONEY!
Welcome to Electriciansparadise.com Add
Website dedicated to knowledge and expertise for electricians Pay-Per-Play
ads to your website
DH MicroSystems, Inc. PIC Prototyping PCBs.
DHMicroSystems, Inc. Make MONEY!

CIRSIM - Electronic Circuit Simulation Program Add


CIRSIM is a software package for designing, simulating and analysing analogue electronic circuits. Pay-Per-Play
ads to your website
Electronique et microcontroleur 8051
Site d'lectronique gnrale et microcontroleurs 8051 en particulier

Electronics 2000
Electronics 2000, for electronics hobbyists, engineers and students.

http://q.webring.com/hub?ring=eewebring (2 of 3)12/02/2008 17:14:48


Electronics Engineering

Ring sites < Prev 9 | Next


9>

WHAT'S NEW MOST POPULAR BLOGS GET STARTED FORUMS CONTACT US

Copyright 2001-2008 WebRing, Inc. All rights reserved. Terms of Service - Help
Notice: We collect personal information on this site.
To learn more about how we use your information, see our Privacy Policy
WebRing server hosting provided by SimpleNet.

http://q.webring.com/hub?ring=eewebring (3 of 3)12/02/2008 17:14:48


Technical Homepage of Mike Ellis

Office Cam The Multimedia Electronic Literature & Learning Internet Site Cam Page
This web site is dedicated to the advancement of electronic engineering skills.

Home Projects Audio Amp Nothing Box Whistle Switch


Power Supplies Constant Current Dual Tracking Switching
Two-Day Projects Oscilloscope 68HC11 Function Generator

Karaoke Live TV
Netzero Free dial-up
Videos Unreleased Episode of Star-Trek Hotmail Free email
Visit Microsoft EE Community Center Tripod Free web pages
Electronics Search Engine

EE Software & EE Jobs Application


Links CATV Magazines Misc
Circuits Links Notes

Information on Atlanta, GA
AltaVista - WebCrawler- HotBot- Lycos- Infoseek- Excite-- Image Surfer - Starting Point - DejaNews-
More...
Yellow Pages - People Search - City Maps - Get Local - Today's Web Events & Chats - Whowhere - More
Yahoos

The Live WebCams Ring


[SKIP -] [PREVIOUS] [NEXT] [SKIP ]
[PREV 5] [NEXT 5] [RANDOM] [LIST]
Do you have a WebCam? JOIN the Ring! PREV RANDOM LIST NEXT
This site is owned by Mike Ellis <- 2 JOIN ABOUT 2 ->

[ Skip Previous | Previous | LIST SITES | Next | Skip Next | Random Site ]

You are visitor


number

http://www.mellis.net/12/02/2008 17:14:58
roboDNA - Robotic modules and software - Free Lego NXT PC Remote Software - Lego NXT Direct Commands

Version 2.0 Released!

RoboDNA's Dashboard Designer allows you to quickly and easily


build PC Dashboard Interfaces to remotely operate and monitor
robotic type devices over RS-232, USB, TCP-IP and 802.11.

It provides a visual drag-and-drop environment using Dashboard


Controls such as gauges, buttons and sliders, and provides the
following functions:

Drive-by-wire Operations
Autonomous State Operations
Piloted-Autonomous Operations
Telemetry Feedback
Monitoring Sessions

Beta Testers Sign-Up Here

RoboDNA's iRobot Create


Workspace allows you to
RoboDNA's Lego NXT Workspace allows
quickly and easily build
you to quickly and easily build
Dashboard Interfaces to
Dashboard Interfaces to remotely
remotely operate your
operate your Lego NXT robot over
Create robot over RS-232
bluetooth from your PC.
and WiFi from your PC.
Send Lego NXT Direct Commands to
Send Open Interface
operate all of your robot designs.
commands to operate all
of Create's sensors and actualtors.

http://robodna.com/roboDNA/ (1 of 2)12/02/2008 17:15:13


roboDNA - Robotic modules and software - Free Lego NXT PC Remote Software - Lego NXT Direct Commands

RoboDNA's Dashboard Designer allows engineers and robot builders to quickly and easily build libraries
of Dashboard Interfaces to remotely operate prototypes from a PC.

The PicDem 2 Sample Workspace provides sample C code and a dashboard to interact with 8 bit PIC
parts.

roboDNA 2003-2007 Copyright - All Rights Reserved

Electronics Engineering
Prev | Ring Hub | Join | Rate|
Next
WebRing Inc.
Search
Visit a complete list of WebRing memberships here
Sponsored Link: Ashton Pub Ottawa

http://robodna.com/roboDNA/ (2 of 2)12/02/2008 17:15:13


Embedded Technology

Iron WebMaster Round 2 VOTING is underway. Get in on the action!


Welcome, Guest HOME DIRECTORY HELP SIGN IN

TELL A
SEARCH WEBRING: This WebRing All
FRIEND!
Programming Languages > C and C++ Add this feed:
Embedded Technology Add Your
Manager: michaelanburaj Web Site.
Join Here!

SEARCH in This WebRing All

Iron WebMaster
Microprocessors, controllers, RTOS, Networking / Communication
Protocols & Embedded technology related sites

Round 2 VOTING
Get in on the Action!
Ads by Google

Flowchart from C/C++ code


Visual browser, Cross reference For the new member of software team.
www.sgvsarc.com
Check out similar sites on
Manufacturers RFID Reader
Leader in embedded RFID for OEMs. reader modules, antennas &
more. www.skyetek.com
Bluetooth Serial Modules
Wireless Cable Replacement for Industrial & Medical Applications. www.
sena.com

TDI Power Systems


Global Supplier of AC and DC Power Conversion Products for OEMs.
www.tdipower.com

http://a.webring.com/webring?ring=embedded;home (1 of 4)12/02/2008 17:15:22


Embedded Technology

Hub Page Sites Traffic Stats Forum Similar WebRings


Ring sites Showing 1 - 20 of 95 Next Ads by Google
20 > MEN cPCI Blade Server
Rugged Quad Core Xeon
SBC for telco medical &
RISC processors & Microcontrollers industrial communication
1) Embedded Technology - RTOS, Real-time Single-chip solutions, Telecom protocols & Virtual Peripherals www.menmicro.com
2) Microcontrollers - ARM, MIPS, MCS-51/251, PIC 12/14/16, SX, AVR,... Embedded Tech Journal
Be the Embedded Expert
AVR Microcontroller Resources
Free Subscription
A list of links to Atmel AVR information on the web that also includes some projects of my own. www.embeddedtechjournal.com

Sage Telcommunications Electronic India


Sage Telecommunications ( Hardware / Software Engineers and distributers of Dontronic's SimmStick Custom electronic design
products )and Sage Pages Republishers of Fred Hoinville's classic 'Halfway to Heaven' ) and development service in
India.
PMB Electronics www.mansi.ws
Embedded micros and electronic component supply. x86 Embedded uControllers
ADC/DAC, motion, LCD, I/O,
Embedded Systems Development Nexus Ethernet Low-Cost, Flexible,
A resource for embedded systems developers. C/C++ Program
www.tern.com
Welcome to Aru's Abode
Advertise on this Site
Has lots of learning stuff.
Make MONEY!
Ben's HobbyCorner
A home-made 80C535/C515/AT89C2051/ AT89C4051 microcontroller system on single sided PCB's, with Add
LCD-display, keyboard, steppermotors, I2c etc. Pay-Per-Play
ads to your website
Jesstec Micros Website
Jesstec Micros are manufacturers of low cost 8032/80320 based credit card sized controller boards. Make MONEY!

The world according to I.R.Bot Add


Pay-Per-Play
About robotics, AVR, Basic Stamp and other electronic stuff.
ads to your website
FREE Circuits & Sample C Code for AVR/PIC/ 89C2051
Complete resources for 8-bit Microcontrollers - I/O interface Circuits, sample C code, C compilers tools,
programmers, resources and info.

http://a.webring.com/webring?ring=embedded;home (2 of 4)12/02/2008 17:15:22


Embedded Technology

Bamberg & Monsees GbR


Bamberg & Monsees GbR develops and produces Microcontrollerboards and tools for the ATMEL AVR-
series and other Controller like the 80C5x and Microchip PIC.

Celestial Horizons
Basic Compilers for PIC microcontrollers.

Electronic Circuits & Radio Controlled Modeling


PIC Microcontroller page about: RS232 (software- & hardware-) communication routines, Dot matrix LCD
driver routines , LCD data sheets & references, AT keyboard interface.

Innovative Design Solutions


IDS manufactures 8051 based microcontroller development products (both hardware and software), and
provides complete electronic design services.

Bamberg&Monsees GbR Systeme fuer Wissenschaft u.Technik


Development and production of microcontroller-modules, embedded applications, power-supplies, battry-
chargers and programmers

PIC Ethernet Web Server


Information on web-enabling your PIC by using a standard NE2000 ethernet card as the physical interface.

Pic 12c508 programmer


En esta pgina aprenderas a como fabricar tu propio programador de pics y como programar tu pic.

Berty's Home Page


Just some projects and pinouts for mobile phone lcd.

Beginners PIC and AVR page


A useful PIC and AVR microcontroller starting place containing simple code examples, hardware setup and
tools to use and the virtual notebook

optiCompo Electronics - ATmega based boards


We produce an ethernet add-on for the Agenda VR3 PDA , an ATmega 103 mikroboard with RESET IC,
STK300 compatible ISP etc. In cooperation with egnite we work on the EtherNut.

Ring sites Showing 1 - 20 of 95 Next


20 >

http://a.webring.com/webring?ring=embedded;home (3 of 4)12/02/2008 17:15:22


Embedded Technology

WHAT'S NEW MOST POPULAR BLOGS GET STARTED FORUMS CONTACT US

Copyright 2001-2008 WebRing, Inc. All rights reserved. Terms of Service - Help
Notice: We collect personal information on this site.
To learn more about how we use your information, see our Privacy Policy
WebRing server hosting provided by SimpleNet.

http://a.webring.com/webring?ring=embedded;home (4 of 4)12/02/2008 17:15:22


Embedded Technology

Iron WebMaster Round 2 VOTING is underway. Get in on the action!


Welcome, Guest HOME DIRECTORY HELP SIGN IN

TELL A
SEARCH WEBRING: This WebRing All
FRIEND!
Programming Languages > C and C++ Add this feed:
Embedded Technology Add Your
Manager: michaelanburaj Web Site.
Join Here!

SEARCH in This WebRing All

Iron WebMaster
Microprocessors, controllers, RTOS, Networking / Communication
Protocols & Embedded technology related sites

Round 2 VOTING
Get in on the Action!
Ads by Google

Bluetooth Serial Modules


Easy to use serial Bluetooth adapters for embedded devices. www.sena.
com
Check out similar sites on
Manufacturers RFID Reader
Leader in embedded RFID for OEMs. reader modules, antennas &
more. www.skyetek.com
Flowchart from C/C++ code
Visual browser, Cross reference For the new member of software team.
www.sgvsarc.com

Free - Embedded Journal


Be the Embedded Expert Articles, Webcasts, News. www.
embeddedtechjournal.com

http://s.webring.com/hub?ring=embedded (1 of 3)12/02/2008 17:15:33


Embedded Technology

Hub Page Sites Traffic Stats Forum Similar WebRings


Ring sites < Prev 10 | Next Ads by Google
10 > CuTouch Combined PLC
+HMI
PLC and Operator Interface
AVR Microcontroller Resources in one. Run Ladder logic &
A list of links to Atmel AVR information on the web that also includes some projects of my own. BASIC. Low Cost.
www.audon.co.uk
Sage Telcommunications
x86 Embedded uControllers
Sage Telecommunications ( Hardware / Software Engineers and distributers of Dontronic's SimmStick
ADC/DAC, motion, LCD, I/O,
products )and Sage Pages Republishers of Fred Hoinville's classic 'Halfway to Heaven' )
Ethernet Low-Cost, Flexible,
PMB Electronics C/C++ Program
www.tern.com
Embedded micros and electronic component supply.
Embedded System Design
Embedded Systems Development Nexus Intrinsyc Customizable
A resource for embedded systems developers. Solutions - Embedded
Reference Devices
Welcome to Aru's Abode www.Intrinsyc.com
Has lots of learning stuff. Electronic India
Custom electronic design
Ben's HobbyCorner and development service in
A home-made 80C535/C515/AT89C2051/ AT89C4051 microcontroller system on single sided PCB's, with India.
LCD-display, keyboard, steppermotors, I2c etc. www.mansi.ws
Advertise on this Site
Jesstec Micros Website
Jesstec Micros are manufacturers of low cost 8032/80320 based credit card sized controller boards. Make MONEY!
The world according to I.R.Bot Add
About robotics, AVR, Basic Stamp and other electronic stuff. Pay-Per-Play
ads to your website
FREE Circuits & Sample C Code for AVR/PIC/ 89C2051
Complete resources for 8-bit Microcontrollers - I/O interface Circuits, sample C code, C compilers tools, Make MONEY!
programmers, resources and info.
Add
Bamberg & Monsees GbR Pay-Per-Play
Bamberg & Monsees GbR develops and produces Microcontrollerboards and tools for the ATMEL AVR- ads to your website
series and other Controller like the 80C5x and Microchip PIC.

Ring sites < Prev 10 | Next


10 >
http://s.webring.com/hub?ring=embedded (2 of 3)12/02/2008 17:15:33
Embedded Technology

WHAT'S NEW MOST POPULAR BLOGS GET STARTED FORUMS CONTACT US

Copyright 2001-2008 WebRing, Inc. All rights reserved. Terms of Service - Help
Notice: We collect personal information on this site.
To learn more about how we use your information, see our Privacy Policy
WebRing server hosting provided by SimpleNet.

http://s.webring.com/hub?ring=embedded (3 of 3)12/02/2008 17:15:33


Links to websites related to microcontrollers, IT and other technologies

Links to websites related to microcontrollers, IT and other technologies.

PICmicro and Atmel hardware & Software.

PIC programmers, compilers, robotics projects.

PIC Micro kits and components.

Versatile group of well trained experts in different fields:


computer science, computer modeling, electronics,
mathematics, web development and economics

Active Robots - Educational and Amateur Robotics

CCS offers optimized Microchip PICmicro C compilers for Windows and


Linux as well as embedded development tools. CCS is an engineering
company specializing in embedded software/firmware and hardware systems.

http://www.celestialhorizons.com/links/links.htm (1 of 2)12/02/2008 17:15:41


Links to websites related to microcontrollers, IT and other technologies

The Electronics Web Directory.

Previous 5 Sites | Skip Previous | Previous | Next


Skip Next | Next 5 Sites | Random Site | List Sites

[ Previous 5 Sites | Previous | Next | Next 5 Sites ]


[ Random Site | List Sites | Join Ring ]

The Celestial Horizons Home Page.

http://www.celestialhorizons.com/links/links.htm (2 of 2)12/02/2008 17:15:41


Innovative Design Solutions

About Us What's New Our Services Our Products Contact Us Links

This web site is dedicated to the memory of James Leonard Callaghan (Cal)

January 5, 1956 to July 20, 2000

IDS Innovative Design Solutions

"Bringing Ideas to Life"

Complete Electronic Design Services Embedded Microcontroller Products


UPDATED DECEMBER 5, 2005

Graphics by Elated

Embedded Technology
Prev | Ring Hub | Join | Rate|
Next
Search
WebRing Inc.
Visit a complete list of WebRing memberships here

http://www.indeso.com/12/02/2008 17:15:49
Microchip PIC Project resource and guide page

April 1st, 2006

Object Detector, PIC16F877

Project description:
This is a very small program to try the Sharp GP2Y0D340K infrared object detector.

Electronics used:
Sharp GP2Y0D340K

Link: Object Detector

hrefik | Uncategorized | No Comments | #

April 1st, 2006

A system to record and/or play sound in a bit stream format, PIC16F877

http://www.picguide.org/ (1 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
This is a sound playback system for a PIC or any other microcontroller. It uses a clever encoding system
to mathematically model the actual performance of the RC filter when the signal is encoded. This allows
playback of good quality sound with the absolute minimum software and hardware. The RC filter
modeling (encoding algorithm) has been refined to be PIC friendly in binary math, giving the ability to
playback AND RECORD in real time even on a PIC, even with high rates up to 150+ kbit/sec.

Electronics used:
LM741
Link: A system to record and/or play sound in a bit stream format

hrefik | Uncategorized | No Comments | #

April 1st, 2006

Ultrasonic Radar, PIC16F877

http://www.picguide.org/ (2 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
The Devantech SFR04 Ultrasonic Range Finder indicates the distance to the closest object within range.
Echos that arrive later are received and processed, but subsequently ignored. For a true radar all signals
should be taken into account.

Electronics used:
Devantech SFR04

Link: Ultrasonic Radar, PIC16F877

hrefik | Uncategorized | No Comments | #

April 1st, 2006

Climate Controller, PIC16F873

http://www.picguide.org/ (3 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
Climate Controller. This controller uses the Sensirion SHT11 combined temperature and humidity
sensor. Measurement and Display:
Scale selectable between Centigrade and Fahrenheit
Humidity 0 - 100% temperature compensated
Temperature -40 to 123 C (-40 to- 254 F)

Electronics used:
SHT11

Link: Climate Controller, PIC16F873

hrefik | Uncategorized | No Comments | #

March 31st, 2006

PIC based guitar tuner and preamp, PIC16F73

http://www.picguide.org/ (4 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
I recently had to make a guitar amplifier and thought it would be cool to include a PIC based guitar
tuner. I had an AIWA 3-disc stereo lying around with a non-functioning CD player. The tuner and tape
deck still worked fine, and it was rated for I think 30 watts/channel.

Electronics used:
AD620
LM10

Link: PIC based guitar tuner and preamp

hrefik | Uncategorized | No Comments | #

March 31st, 2006

Nixie clock, PIC16F73

http://www.picguide.org/ (5 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
These tubes were originally in a Wang desktop calculator, manufactured in 1969. A PIC16F73 is the
only IC used, although it was a stretch with all 22 IO being used. The timing reference is obtained from
the 60 HZ AC line, although during a power outtage a 9 volt NiCad keeps the CPU powered and the
timing is generated by an interrupt routine (10 MHZ clock crystal). A 5 pin header on the main circuit
board is used for ISP and allowed for easy debugging.

Link: Nixie clock, PIC16F73

hrefik | Uncategorized | No Comments | #

March 31st, 2006

8-PIN PONG, PIC12F675

http://www.picguide.org/ (6 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
This project is based on ideas from Rickards electronic projects page and David B. Thomas VCR Pong.
However, I have developed the simplicity even further, eliminating most of the external components.
Using microcontrollers with internal 4MHz clock generator there is no need for the xtal. The 12f675 part
also operates on wide voltage range, and the regulator can be removed. For game controller, I plan on
using the old Commodore 64 style paddless. They include firing buttons, which I plan on using as power
switch and game reset. 16F675 has a low power sleep mode with 1nA current consumption, so I plan on
using that to switch off.

Link: 8-PIN PONG

hrefik | Uncategorized | No Comments | #

March 31st, 2006

DCF controlled time switch, PIC16F876

Project description:
I needed a way to automatically control the main heating of our house. The basic idea is to start the
heating at a certain time in the morning, and to switch it off at night. The switching points are different
on various weekdays.

Link: DCF controlled time switch

hrefik | Uncategorized | No Comments | #

http://www.picguide.org/ (7 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

March 29th, 2006

Dual Thermometer with serial output, PIC16F876

Project description:
This one is using a 16F876 PIC, MCP1047A temperature sensor ( X2 ), MCP1541 voltage reference and
MCP6022A opamp. The display is a 2 row HD74780 based 2X16 char, SII L1652BIJ2 but any other
display based on HD74780 can be used.

Electronics used:
MCP1047A
MCP6022A
MCP1541
HD74780
Link: Dual Thermometer with serial output

hrefik | Uncategorized | No Comments | #

March 29th, 2006

The Internet Plug II, PIC16F877

http://www.picguide.org/ (8 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
Some time ago I use to create an Internet Plug - it was useful except one aspect - no password
protection was available for the Site Player. In order to solve this problem I have attached a 16F877
processor to the Site Player. Now the Internet Plug is Password Protected and also the status of the exits
is saved in EEPROM so is not lost in case of a power failure. One of the simplest applications will be to
control the lights from the distance, meaning from any computer connected to the Internet.

Electronics used:
SitePlayer Moule

Link: The Internet Plug II

hrefik | Uncategorized | No Comments | #

March 29th, 2006

DTMF Remote control, PIC16F87X

http://www.picguide.org/ (9 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
This project is a simple DTMF Remote control. The DTMF detector is integrated in software. All the
logic requested to receive and decode DTMF Commands over the phone line is integrated in the 16F877
chip, only few external components are used.

Electronics used:
MCP6022
Link: DTMF Remote control

hrefik | Uncategorized | No Comments | #

March 29th, 2006

Rocket timer, PIC16F84

http://www.picguide.org/ (10 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
A co-worker of mine wanted a small timer that ranged from 1s to 15s depending on what the user
selected. They wanted to use a set of 4 dip switches to select the time. Needed to be as small as possible
(weight being very critical) and run off of a 9V battery. Needed 2 failsafes to prevent accidental ignition
of the second stage of the rocket.

Electronics used:
TC4422
Link: Rocket timer

hrefik | Uncategorized | 1 Comment | #

March 28th, 2006

Temperature recoding device, PIC16F628A

http://www.picguide.org/ (11 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
This project uses 16F628A as the microprocessor, TC-77 for temperature sensing and 24LC64 as storage
device. The objective is to create a low power temperature recoding device. The entire device consumes
400uA of current. The power is supplied by a standard battery pack (3.6V) for cordless phone. Lower
power comsumption is possible if the shutdown code is implemented for the TC-77 temperature sensor,
however, due to the time limitation, it is not available in this version of the code.

Electronics used:
TC-77
24LC64

Link: Temperature recoding device

hrefik | Uncategorized | No Comments | #

March 27th, 2006

Palm <-> PIC bidirectional IR communication, PIC16f877

http://www.picguide.org/ (12 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
The main thing I want to do in this bit is build a data communication system from a Palm to a PIC using
IRDA (Infra Red). At first I was going to use just raw IR transmission with no protocol, so all the error
correction would have to be taken care of by the software -no real problem there- but I found out than
the newer Palms dont support raw IR mode, apparently they are hard wired that way, the other option
was to use the IRcomm protocol, it acts like a virtual serial port -you send a in you get a out.

Electronics used:
Palm Pilot

Link: Palm & PIC bidirectional IR communication

hrefik | Uncategorized | No Comments | #

March 22nd, 2006

SED1300 LCD, PIC16F628

http://www.picguide.org/ (13 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project descrition:
Description how to use the PIC microcontroller to control a LCD with the SED 1300 controller.
Link: SED 1300 LCD

hrefik | Uncategorized | 1 Comment | #

March 22nd, 2006

Timer, PIC16F628

Project description:
This is a cyclic timer (24 hours clock) which may be programmed to turn on and off some device at
programmed time. I made it because Im too lazy to turn light in my aquarium in the morning and turn it
off in the evening.

Electronics used:
74164N

Link: Timer

hrefik | Uncategorized | 1 Comment | #

March 21st, 2006

Ethernet to Serial module, EM202, PIC16F628

http://www.picguide.org/ (14 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
This is a how-to project that shows you how to connect your PIC to the EM202, ethernet to serial
module. Now you can communicate over the ethernet to serial port.

Electronics used:
EM202
Link: Ethernet to Serial module, EM202, PIC16F628

hrefik | Uncategorized | 1 Comment | #

March 21st, 2006

IR Remote Control Repeater, PIC12F675 and PIC12F629

http://www.picguide.org/ (15 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

Project description:
This circuit receives the signal from a IR remote control, like those used to control your TV or DVD
player and allows the signal to be repeated in another location.

Electronics used:
TSUS5400 Vishay

Link: IR Remote Control Repeater

hrefik | Uncategorized | No Comments | #

March 21st, 2006

RGB LED Colour wash light, PIC12F675

Project description:
This PIC based circuit uses Red, Green and Blue high brightness LEDs that are pulse width modulated
(PWM) to vary the intensity of each colour LED. This allows effectively any colour to be generated. The
circuit is designed to fit into a low voltage Halogen light fitting.

Link: RGB LED Colour wash light

hrefik | Uncategorized | No Comments | #

http://www.picguide.org/ (16 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

March 15th, 2006

CPU Cooler Fan Speed Tester, PIC16F627

Project description:
The main reason I built this is because someone I knew wanted a stand alone device that is capable of
measuring/test CPU Cooler Fans independent of the computer. And here it is, a PIC16F627 based CPU
Cooler Fan Speed Tester. The speed is displayed on 4 units of 7 segment display as shown.

Link: CPU Cooler Fan Speed Tester

hrefik | Uncategorized | No Comments | #

Previous Entries

SEND TO A FIREND

Send to a friend:

NAVIGATION

Home
PIC Books & Articles
PIC Code library

http://www.picguide.org/ (17 of 18)12/02/2008 17:16:00


Microchip PIC Project resource and guide page

PIC Compilers
PIC Forums
PIC Vendors
Submit your project
What is a PIC?

Search

Search

Uncategorized (79)

Add to favorites

Subscribe

Entries (RSS)
Comments (RSS)

picguide.org was made to put all Microchip PIC MCU Projects on one place, to help the beginner get
started and to minimize the time to find useful information and resources related to the PIC MCU.

Embedded Technology
Prev | Ring Hub | Join | Rate|
Next

WebRing Inc.
Search
Visit a complete list of WebRing memberships here

http://www.picguide.org/ (18 of 18)12/02/2008 17:16:00


Precision Digital Altimeter using Motorola MPXS4100 and Microchip PIC16F84

Precision Digital Altimeter


with Motorola MPXS4100 A and PIC16F84

Table of Contents [Toc]

Concept
Transmitter
Resolution
Note
So far...
Documents
Receiver
Components
Technical Data of Wireless Transmitter and Receiver
Remarks
Evaluation Board
Initial Test Setup
PCB Evaluation Board
Schematics of Evaluation Board
Available PIC Assembler Code
Software
Measurements
Further Information
Documents
Sensor Ordering Information
Other Circuits and Utilities
Links
Future Steps

Concept [Toc] [Top]

The current concept incorporates a wireless transmitter and receiver and is thought to be used for remote controlled airplanes or
appliances with two seperate parts. In other words, we have one dedicated transmitter (acquisition, filtering) and one dedicated
receiver part (user-interface, look-up table, calibration, storage), capable of being connected together with any physical layer, e.g.
wired, wireless, infrared. If you want to build a standalone altimeter/variometer just for hiking or mountaineering, this setup can
obviously be simplified by omitting the wireless components.
So far, only the transmitter part with all its analog circuitry has been completed entirely - the digital receiver part has still to be done,
but does not necessarily have to be a PIC microcontroller. For instance, it could also be a personal computer, connected through the
standardized RS232 protocol and a wired/wireless interface to the transmitter part.

The (pending) challenge of the receiver implementation is the field evaluation of the most suitable and accurate temperature and non-
linear pressure-altitude correction algorithms. There is maybe need for adding a temperature sensor to the transmitter part.

http://www.trash.net/~luethi/microchip/projects/alti/alti.html (1 of 11)12/02/2008 17:16:05


Precision Digital Altimeter using Motorola MPXS4100 and Microchip PIC16F84

Transmitter [Toc] [Top] Resolution [Toc] [Top]

I reached 56 cm per unit, so the whole range is :

2270 meters using a 12 bit A/D converter


142 meters using an 8 bit A/D converter

Increase the range by taking a better A/D converter or decrease the Amplifier-
Gain (reduction of resolution).

In practice, I'll set the resolution to 1 meter, so a total range of 4096 meters will
be available. This is enough precise for my R/C models, but allows to use this
altimeter also for hiking and mountaineering.

Note [Toc] [Top]

The microcontroller builds an average value of 64 A/D samples to reduce any


noise to a minimum.

So far ... [Toc] [Top]

I've developed the following routines in PIC Assembler code:

RS 232 Interrupt handled interface for PICs without USART. I like a


clean design, so I take an interrupt capable PIC microcontroller !
Although the PIC 16C73 has one USART, this routine is necessary
because the USART is already used for the AD Converter and the
EEPROM. Because the RS 232 interface is not used during data logging
operation, the performance of the USART is completely present to the
communication with the AD Converter.
Serial 4 Bit standard Dot-LCD interface
8 Bit & 16 Bit binary to decimal conversion routine for LCD output.
NSC ADC12130 test interface with Auto-Calibration, Auto-Zero and
Data-Fetch
Data Capture from an Excel Worksheet.

Documents [Toc] [Top]

See related stuff at the document section below.

http://www.trash.net/~luethi/microchip/projects/alti/alti.html (2 of 11)12/02/2008 17:16:05


Precision Digital Altimeter using Motorola MPXS4100 and Microchip PIC16F84

Receiver [Toc] [Top]

Components [Toc] [Top]

The following components have been used: Analog to digital converter NSC ADC12130, a Microchip PIC16F84 controller, a quad
op-amp NSC LMC660, a Maxim MAX232 RS232 level shifter, and the Motorola MPXS4100A absolute pressure sensor.

Circuit Design CDP-RX-01 wireless


receiver, 434 MHz, up to 7.5 kb/s, uni-
Removable module containing Motorola absolute directional
pressure sensor MPXS 4100A, 10nF and 100nF
ceramic and 10uF tantalum capacitors.

http://www.trash.net/~luethi/microchip/projects/alti/alti.html (3 of 11)12/02/2008 17:16:05


Precision Digital Altimeter using Motorola MPXS4100 and Microchip PIC16F84

Top view of removable pressure sensor module. Circuit design CDP-TX-01 wireless
transmitter, 434 MHz, up to 7.5 kb/s, uni-
directional

Technical Data of Wireless Transmitter and Receiver [Toc] [Top]

Manufacturer: Circuit Design Inc.


Very small and compact integrated device with robust metal housing.
Low current consumption, ideal for mobile, battery-powered applications.
Filter technique using Super-SAW filters.

Additional information is available at Circuit Design Inc. -> Products

Data sheets of wireless transmitter and receiver:

previous version CDP-TX01 (PDF) discontinued


current version CDP-TX02 (PDF)

General
Oscillator type: Crystal
Frequency: 433.920 MHz, 434.075 MHz (Europe)
458.650 MHz (United Kingdom)
Frequency stability: +/- 2.5 kHz (-10 up to +55 C)
HF channels: single (fixed channel)
Range: up to 1000 m (free distance, line of sight)
Baud rate (specified): 300 - 4800 baud
Bit rate (measured at short up to 7500 bits/s
distance):
Operating conditions: -10 up to +60 C
Type approval: I-ETS 300 220 / Germany, France, Switzerland, Sweden, UK, Holland, Austria, EMC

Transmitter
HF power output: 10 mW +/- 3 dB @ 50 Ohm
Modulation: FM narrow band
Start-up time: 30 ms
Input signal type: digital, 5 Volt
Deviation: 2.5 kHz
Supply voltage: 5.5 - 10 Volt
Power consumption: 18 mA typ.
Dimensions: 36 x 26 x 10 mm
Weight: 9.8 g

http://www.trash.net/~luethi/microchip/projects/alti/alti.html (4 of 11)12/02/2008 17:16:05


Precision Digital Altimeter using Motorola MPXS4100 and Microchip PIC16F84

Receiver
Type: double superheterodyne, crystal oscillator
Sensitivity: -120 dBm (12 dB/SINAD, CCITT filter)
Selectivity: +/- 5 kHz @ -6 dB
Demodulation: FM narrow band
Distortion: < 5 % @ 1 kHz
Output signal type: digital, open collector
Other outputs: RSSI and AF
Supply voltage: 4.5 - 14 Volt
Power consumption: 10 mA typ.
Dimensions: 50 x 30 x 7.5 mm
Weight: 19 g

Remarks [Toc] [Top]

A lot of people have asked me where I got the Motorola absolute pressure sensor from.

Please see the section Sensor Ordering Information below.

By the way, Motorola distinguishes the sensor characteristics, feature set and package type by the sensor name, so you can also get
4100 sensor types similar to mine with different naming, e.g. MPXT 4100A or PPXA 4100A:

M Qualified standards
PX Pressure sensor
S Small outline package

See Motorola Sensor Selector Guide at the section Documents below.

Evaluation Board [Toc] [Top]

The Circuit Design wireless transmitter and receiver are not necessary to use the evaluation board, since there exists a direct RS232
link to the PC.

Initial Test Setup [Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/alti/alti.html (5 of 11)12/02/2008 17:16:05


Precision Digital Altimeter using Motorola MPXS4100 and Microchip PIC16F84

Test setup to check the initial concept

An initial test setup for checking the mixed signal design: A significant problem was the digital noise in the analog circuitry supply
voltages. Finally the noise could be minimized by splitting up the power supplies to three independent sources: one digital power
supply voltage, one for the sensor and A/D converter, and one supply with slightly higher voltage for the operational amplifiers of
the filter stages. The above test setup contains no wireless transmitter, the data is directly transmitted to the computer using the
RS232 protocol and a MAX232 level shifter.
In this setup, I have used the LMC660 / LMC662 low-power rail-to-rail quad operational amplifiers for the fourth order Chebyshev
filter stages.

PCB Evaluation Board [Toc] [Top]

Moving from the test board to the first PCB, I have only made slight adaptations in the analog part of my design: I have altered the
filter characteristics from Chebyshev to Butterworth - but as a consequence, I had to replace the LMC660 operational amplifier by a
LM324 type, due to oscillating filters. Conclusion: In the analog world, nothing runs properly if it has not been tested.

If someone knows a good single supply, low-power, rail-to-rail operational amplifier with clean and linear output characteristics in
the entire input range, please let me know! The LMC660 is exactly specified this way, but showed up a really bad non-linear
characteristic in the upper input range. Bob Krech suggested the LMC6064 precision quad OP amplifier with pin-for-pin
replacement for the LM324.

http://www.trash.net/~luethi/microchip/projects/alti/alti.html (6 of 11)12/02/2008 17:16:05


Precision Digital Altimeter using Motorola MPXS4100 and Microchip PIC16F84

PCB-based evaluation board suitable for first field measurements

Description of the above PCB layout

The PCB-based evaluation board consists of analog circuitry at the left side and digital components at the right side of the board. In
the upper left corner are the three independent power supplies (5 V analog, 6.8 V analog, 5 V digital), all served from one battery
(8 - 10 V). The evaluation board contains further the active Butterworth filter stages built of one LM324 (left side), the NSC
ADC12130 A/D converter (center), the PIC 16F84 microcontroller (at right from A/D converter), a dot LCD display and a PORTB
connector (lower right corner), a direct RS232 interface with MAX232 level shifter (upper right corner), and an interface for the
wireless transmitter allowing for first field measurements (bottom center). The system owns two oscillators. A 4 MHz crystal
oscillator provides the conversion clock for the A/D converter, and a separate 4 MHz crystal for the microcontroller allows to
increase processor performance easily if necessary. This setup provides two A/D converter input channels: Channel 0 is already used
for the pressure sensor, but channel 1 can be used freely, e.g. for voltage surveillance of the R/C receiver battery. If two channels are
not sufficient, this system can easily be upgraded to eight channels by integrating the NSC ADC12138 A/D converter. The LCD
connector and the RS232 interface serve only for evaluation and debugging purposes in this setup. Finally, the noise characteristics
of my approach are very promising!

Although this board is now ready, a suitable R/C plane - my Piper Cherokee - has to be finished first for 'air evaluation'...

Schematics of Evaluation Board [Toc] [Top]

Latest version 1.03 from April 23rd, 2001:

Top.pdf (8.5 kB)


Sensor.pdf (4.0 kB)
Filter1.pdf (6.5 kB) (replaced LMC660 with LM324, due to oscillating filters)
Filter2.pdf (6.3 kB) (replaced LMC660 with LM324, due to oscillating filters)
Digital.pdf (12.6 kB)
LCD.pdf (4.6 kB) (corrected some errors)
RS232.pdf (7.7 kB)
PowerSupply.pdf (8.9 kB)

Available Microchip PIC Assembler Code [Toc] [Top]

Main File HEX Files

http://www.trash.net/~luethi/microchip/projects/alti/alti.html (7 of 11)12/02/2008 17:16:05


Precision Digital Altimeter using Motorola MPXS4100 and Microchip PIC16F84

View assembler source code: alti_tx.html alti_tx.hex


Download assembler source code: alti_tx.asm (16.7 kB)

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_rs096.
asm

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Software [Toc] [Top]

An Excel worksheet has been used to visualize the captured data.


With the NSC ADC12130 A/D converter, there are two channels available.

Download Excel worksheet and drivers: alti_2channel.zip (203 kB)

Measurements [Toc] [Top]

I've done some measurements to see whether LSB toggling is sufficient low using the Excel RS232 data capture interface. All
measurements have been carried out at room temperature (without any temperature compensation) and without moving the test
board. The test period has been one hour with adequate warm-up time for the sensitive analog circuitry (pressure sensor, A/D
converter and op-amp).

Note: Because the entire design is laid out very sensitive in order to get a high resolution (in the range of one meter), the
accumulated drift could also originate from natural barometric variations.

http://www.trash.net/~luethi/microchip/projects/alti/alti.html (8 of 11)12/02/2008 17:16:05


Precision Digital Altimeter using Motorola MPXS4100 and Microchip PIC16F84

Test setup: Drift of 2 bits during one hour (with a single spike).

Test setup: Drift of 4 bits during one hour.

Test setup: Drift of 3 bits during half an hour. The strange curve comes
possibly from temperature variations.

http://www.trash.net/~luethi/microchip/projects/alti/alti.html (9 of 11)12/02/2008 17:16:05


Precision Digital Altimeter using Motorola MPXS4100 and Microchip PIC16F84

PCB-based evaluation board: The yellow curve represents the pressure


sensor, the blue curve is only a test voltage for comparision purposes. The
pressure sensor behaves quite stable in conjunction with the PCB setup, only
LSB toggling during one hour. The comparision voltage - originating from a
simple voltage divider - is even more toggling. This toggling may result from a
voltage just reaching the A/D converter LSB threshold.

Further Information [Toc] [Top]

Documents [Toc] [Top]

Data sheet of Motorola Absolute Pressure Sensor Series MPX4100A: MPX4100A (PDF, 117 kB)
Motorola Sensor Selector Guide (Acceleration, Pressure, and Smoke): SensorSelectorGuide (PDF, 166 kB)
Noise considerations for integrated pressure sensors: AN1646 (PDF, 153 kB)

Data sheets of wireless transmitter and receiver:

previous version CDP-TX01 (PDF) discontinued


current version CDP-TX02 (PDF)

Sensor Ordering Information [Toc] [Top]

A lot of people have asked me, where they could get the Motorola absolut pressure sensor from. I bought it from www.conrad.com
years ago, but now, these sensors may occassionally not be available there. Don't ask me where you can get them elsewhere, I don't
know...

As of 08.04.2005, there was one pressure sensor model from Motorola available at www.conrad.com:

Item: SMD-DRUCKSENSOR MPXA4100A6U


Ordering#: 150110 - 13
Price: about 25.00 Euro/pc.

Other Circuits and Utilities [Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/alti/alti.html (10 of 11)12/02/2008 17:16:05


Precision Digital Altimeter using Motorola MPXS4100 and Microchip PIC16F84

NSC ADC12130 Test Interface


Dot LCD Interface
RS232 Interface
Excel Data Capture
Automatic Table Generator for MPLAB Assembler

Links [Toc] [Top]

RC data logger V2.5 with altitude capture


German page about a self-made RC data logger using PIC 16F84 and MPXS 4100A absolute pressure sensor.
Previous version with nice Palm interface pictures: RC data logger V1.x

Future Steps [Toc] [Top]

Field measurements and evaluation of the most suitable temperature and non-linear pressure-altitude correction algorithms,
maybe with portable computer to be ready for quick alterations.
Design of the microcontroller-based receiver circuit.
Put all code together and create user-interface and calibration menu with liquid crystal display.
If applicable, a 24C65 EEPROM interface for storage.
If having not enough challenges, real time clock interface to Dallas DS1302.

This work is currently on hold due to limited time.

Last update: 09.11.2005

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/alti/alti.html (11 of 11)12/02/2008 17:16:05


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

AT Keyboard Interface V1.04


for Microchip PIC16F84 (without LCD)

Table of Contents [Toc]

Introduction
Possible Applications
Concept
How it works
Specifications
Features
Limitations
AT Keyboard Theory
Keyboard Scan Codes
Keyboard to Host Protocol
Keyboard Commands
Host to Keyboard Protocol
Host Commands
Project Resources
Available PIC Assembler Code
Schematic, Data Sheets, Pinout
User-specific Customization / FAQ
How do I use the AT Keyboard Input?
How does the Scan Pattern Decoding work exactly?
My own Key Customization
My own Key Sequence
Confusion about Sweden and Switzerland...?

Introduction [Toc] [Top]

Sometimes you only need a simple and cheap RS232 terminal to get sufficient control over a PC or a RS232 device. There is no need, no space or even no power
to place a monitor, a computer case and a keyboard. Maybe there exists also the problem, that the PC or the device is located somewhere else and you want to
interact with it over a short distance.

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (1 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

The cheapest way to obtain a complete user interface is the use of standard components, such as LCD modules and PC keyboards. A standard PC keyboard (PS/2
type) costs about US-$ 12, a 2 lines by 40 characters dot matrix LCD module around US-$ 20.
To connect these items to the serial port by cable, a microcontroller and a RS232 level shifter are necessary. For longer distance control, there exists also the
possibility to interconnect the terminal with the other device by a wireless physical transmission layer.

Possible Applications [Toc] [Top]

The RS232 terminal for instance is very convenient in conjunction with a PC based Juke-Box playing MP3 files. You only need a command line programmable
MP3 player (or a player with a supplied Active-X interface) and a software-based connection between player and RS232 port. This software 'connection' could be
realized using Visual Basic and the often supplied Active-X interfaces of the various Windows based MP3 players.

Another possible area for applications is PC observed access control. Therefore, the RS232 terminal is placed at the entrance to the supervised area.

A further enhancement to be able to satisfy todays needs for network-based communication would be a complete TCP/IP based communication layer together with
an Ethernet front-end. Then it would be possible to control simple Ethernet appliances, e.g. your coffee maker, electrical rolling shutters, autonomous net-based
lawn mower,... ;-) by this remote terminal. Brave new world ...

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (2 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

Concept [Toc] [Top]

The routine below contains no support for an LCD display. It only shows the complete fetch and decoding of AT keyboard scan patterns and RS232 transmission
of ASCII characters to the RS232 client. If you want a PIC 16F84 based solution with additional LCD, have a look at the keyboard v2xx project.

The problem with the PIC 16F84 is the lack of RS232 hardware. The whole keyboard scan pattern fetch, decode and RS232 data transmission is done by software.
Additional RS232 data reception has also to be carried out by software - based on interrupts - but is not implemented within this project. The current
implementation features a preemptive interrupt-based keyboard scan pattern acquisition.

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (3 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

A recent picture of my workplace connecting a Microsoft PS/2 AT An elderly picture of my workplace, at which the initial
keyboard to the PIC16F84. development took place.

How it works [Toc] [Top]

Any key stroke on the local keyboard will send the corresponding scan patterns from the keyboard to the PIC microcontroller. Afterwards, the microcontroller
converts the keyboard scan patterns to ASCII characters and transmits them to the RS232 target device.
The keyboard scan code capture is done by an interrupt service routine (ISR). The event, which triggers the interrupt is a falling edge on the keyboard clock line
(PORTB,0). Keyboard scan pattern acquisition takes place at the keyboard data line (PORTA,4). After 11 clocks (i.e. 11 external interrupts on RB0/INT), the
interrupt service routine has completely captured an 8 bit element of the entire scan pattern and sets a ready flag. The decoding of this 8 bit element is then carried
out during normal operation mode, activated by a valid ready flag whilst keeping the keyboard stalled (keyboard clock line low).

The fact, that the scan pattern acquisition is carried out using an interrupt service routine and the decoding thereof is done during normal operation mode allows for
performing other tasks concurrently: That's why I call the acquisition methodology preemptive, it does not block the processor in the main loop while acquiring
keyboard data - therefore passing processing resources to other services. Explicitely, it works as follows:
After proper acquisition, the corresponding flag KBDflag is set (at the end of the ISR) and the decoded keyboard character resides in the register KBD. The
KBDflag is cleared at the end of the service routine KBDdecode.

Infinitive main loop to acquire keyboard input (keyboard_v1xx.asm), keyboard data is in register KBD:

;******************************
_MLOOP btfsc KBDflag ; check scan pattern reception flag
call KBDdecode ; if set, call decoding routine
;btfsc your_other_flag
;call your_other_service
goto _MLOOP
;******************************

Only RS232 transmission is supported by this program, since PORTB,0 interrupt is already used by the keyboard clock line. There exists no possibility to
implement also RS232 reception using my modules m_rsxxx.asm, because they require PORTB,0 as well and are laid out as non-preemptive data acquisition
routines (see also 'Limitations').

For dedicated code adaptations, please refer to the section 'User-specific Customization' below.

Specifications [Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (4 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

Processor: Microchip PIC 16F84


Clock Frequency: 4 MHz crystal
Throughput: 1 MIPS
RS232 Baud Rate: 9600 baud, 8 bit, no parity, 1 stopbit
Code Size of entire Program: 523 instruction words
Keyboard Routine Features: Capability of uni-directional communication between microcontroller and keyboard
Acquisition Methodology: Preemptive, interrupt-based keyboard scan pattern acquisition, decoding to ASCII characters
during normal operation mode activated by ready flag
Required Hardware: AT keyboard, PS/2 connector, MAX232
Required Software: RS232 terminal software (or Excel 97 RS232 Debug Interface)

Features [Toc] [Top]

Uni-directional communication between microcontroller application and remote RS232 client.


Uni-directional communication between microcontroller and keyboard.
Support for all keyboard characters typed with shift button active and inactive.
English and modified Swiss-German 'codepages' available (QWERTY and QWERTZ)
Caps Lock implemented
Num Lock always active
Possibility to implement short-cuts or user defined characters for 'Esc', 'Num Lock', 'Scroll Lock' and 'F1' - 'F12' keys.
Further enhancement, not implemented: Support of ASCII conversion from direct ALT-DEC and CTRL-HEX entries, e.g. ALT + 6 + 4 = @ or CTRL + 3 +
F=?

To visualize the ASCII data sent by this microcontroller application, use a terminal program like the Windows Hyperterminal. Below an example session, which
proves the correct functionality of the keyboard interface. This terminal program and the Excel 97 RS232 Debug Interface have been used to debug the interface
during implementation time.

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (5 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

Example of a session using the Windows HyperTerminal. The entire contents was sent by the PIC controller.

Limitations [Toc] [Top]

In case you want RS232 reception and keyboard decoding simultaneously on a single PIC 16X84, you'll have to configure either the keyboard clock line or the
RS232 reception data line (both targeting PORTB,0 interrupt) to another separate interrupt source (e.g. PORTB,4 - PORTB,7 change interrupt) and to alter the
RS232 data fetch routine to a preemptive one. But then you'll also run into troubles by using the LCD modules, because they are written to work on entire 8 bit
ports (such as PORTB on 16X84, and PORTC & PORTD on 16X74).
So if you really appreciate to run the RS232 terminal entirely on a PIC 16X84 - from a technical perspective it is possible - you'll have to rewrite the LCD modules
and the software RS232 reception routine. Be aware that there won't be a lot of code space remaining for other enhancements after putting all terminal related stuff
onto the 16X84.

A workaround to get RS232 reception on the PIC 16X84 using this software could be a solution based on polling. But make sure you are polling fast enough, also
in worst case.

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (6 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

Important note from Jason Plumb:

Hey,

First, lemme say that I like your site and thank you for providing excellent reference material for us home-hobbyist microcontroller geeks. I am currently
working on a music/noise project that uses a PS/2 keyboard interfaced to a PIC16F84, and I used your page at http://www.electronic-engineering.ch/microchip/
projects/keyboard/v1xx/keyboard_v1xx.html heavily as a reference when designing hardware and writing code. Anyway, I just thought that I would mention
that I ran into a problem that I have since solved. The problem involved sending bytes *TO* the keyboard from the PIC (in order to light NumLock and
ScrollLock). Your "Host To Keyboard Protocol" section indicates that the keyboard will take the data line low for a clock after the byte is sent to create an ACK
bit. Apparently, the PS/2 keyboard that I have (generic $10 comp-USA brand) doesn't send an ACK bit, but rather sends a whole byte. If my code attempted to
wait for the ACK bit, it hung indefinitely. I changed the wait to look for a byte (by calling my existing function) and everything worked perfectly. I stumbled on
this idea by looking at other online references (most notably, some Linux kernel code at http://www.mscs.mu.edu/~georgec/Classes/207.1998/14Minix_book/S/
src%20kernel%20keyboard.c.html#307). I have seen this ACK *byte* mentioned elsewhere too. I *think* the keyboard sends back 0xFA as an ACK byte, but I
have not personally confirmed this. Perhaps your excellent documentation could just use a quick note of clarification so that other don't run into the same
problem. Maybe something as simple as: "NOTE: Some keyboards send an ACK byte (value 0xFA) instead of an ACK bit.".

Thanks again,
Jason

Note from the author:

The comment above refers to bi-directional communication between PIC microcontroller and AT keyboard, i.e. to the source code of the AT Keyboard Interface
V2.xx and higher versions. The bi-directional communication between host and keyboard is designed to support both Ack bits and Ack bytes.

Every command sent from the host to the keyboard needs to have an Odd Parity bit and an Ack bit at the end.
Every command received by the keyboard from the host needs to be acknowledged by the keyboard by sending an Ack byte (0xFA) to the host. See also
section 'Host to Keyboard Protocol'.

A corresponding PIC assembler code example is shown below:

;*** switch keyboard LEDs on (default status) ***


KBDcmd 0xED ; keyboard LEDs' control command
KBDexp 0xFA ; expect keyboard acknowledge (FA)
movfw KBDleds ; load keyboard LEDs' status
KBDcmdw ; send keyboard LEDs' control data
KBDexp 0xFA ; expect keyboard acknowledge (FA)

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (7 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

However, some AT keyboards may behave different and may need code adaptations to get bi-directional communication working properly.

AT Keyboard Theory [Toc] [Top]

A complete functional description and timing diagram of the AT keyboard is available at Craig Peacock's website. Please refer to his website Interfacing the PC's
Keyboard for an excellent and comprehensive description of all features and commands of the AT keyboard. At this place, I want to thank Craig Peacock for his
outstanding work with his website.
Below I only want to sketch the most important technical aspects to be known when interfacing a PC's keyboard. Small parts of the introduction below are more or
less copied from Craig Peacock's tutorial.

Keyboard Scan Codes [Toc] [Top]

The diagram below shows the scan codes assigned to the individual keys for the english keyboard layout. The keys' corresponding scan codes are the numbers on
the keys, for example the scan code of the ESC key is 0x76. All scan codes are shown in hexadecimal representation.

The scan code assignments are quite random (thanks to IBM and other early computer manufacturers) and appear to be really weird sometimes, for instance the
break key. In many cases the easiest way to convert the scan code to ASCII characters would be to use a lookup table. Below are the scan codes shown for the
extended part of the keyboard and the numeric keypad.

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (8 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

Cite of Craig Peacock: "How about E1,14,77,E1,F0,14,F0,77! Now that can't be a valid scan code? Wrong again. It happens to be sent when you press the pause/
break key. Don't ask me why they have to make it so long! Maybe they were having a bad day or something?"

By the way, AT stands for Advanced Technology...

The AT keyboard sends different scan codes on pressing, holding and releasing of each button. An example is given at the table below:

Press & Hold Down Scan Code Release Scan Code

Normal Scan Code 73 F0 73

Extended Scan Code E0 4A E0 F0 4A

All scan patterns can easily be visualized and verified with the AT Scan Code Debug Routine and the RS232 Debug Interface.

Keyboard to Host Protocol [Toc] [Top]

The data transfer is implemented as bi-directional protocol: The keyboard can send data to the host (microcontroller) and the host can send commands and data to
the keyboard. The host has the ultimate priority over the direction. It can at anytime (although not recommended) send a command to the keyboard.

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (9 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

The keyboard is free to send data to the host when both KBD data and KBD clock lines are high (idle). The serial clock is generated by the keyboard, but the host
can also use it as a clear-to-send line: If the host takes the KBD clock line low, the keyboard will buffer any data until the KBD clock is released, i.e. goes high.
Should the host take also the KBD data line low, then the keyboard will prepare to accept a command from the host.

The transmission of data in the forward direction, i.e. keyboard to host, is done with a frame of 11 bits. The first bit is a start bit (logic 0) followed by 8 data bits
(LSB first), one parity bit (odd parity) and a stop bit (logic 1). Each bit has to be read on the falling edge of the clock.

AT keyboard to host protocol, with odd parity bit

Keyboard Commands [Toc] [Top]

Once the host commands are sent from the host to the keyboard, the keyboard commands must be
sent from the keyboard to the host. If you think this way, you must be correct. Below details of some of
the commands which the keyboard is able to send.

FA Acknowledge
AA Power on self test passed (BAT completed)
EE See echo command (host commands)
FE Resend - upon receipt of the resend command the host should re-transmit the last byte sent.
00 Error or buffer overflow
FF Error or buffer overflow

Host to Keyboard Protocol [Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (10 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

The host to keyboard protocol is initiated by taking the KBD data line low. However to prevent the keyboard from sending data at the same time that you attempt
to send the keyboard data, it is common to take the KBD clock line low for more than 60 us. This is more than one bit length. Then the KBD data line is taken low,
while the KBD clock line is released. The keyboard will start generating a clock signal on its KBD clock line. This process can take up to 10 ms. After the first
falling edge has been detected, you can load the first data bit on the KBD data line. This bit will be read into the keyboard on the next falling edge, after which you
can place the next bit of data. This process is repeated for all 8 data bits. After the data bits comes an odd parity bit.

Host to AT keyboard protocol, with odd parity bit and acknowledge

Odd parity = NOT(XOR(bits[0..7]))

Once the parity bit has been sent and the KBD data line is in a idle state (high) for the next clock cycle, the keyboard will acknowledge the reception of the new
data. The keyboard does this by taking the KBD data line low for the next clock transition. If the KBD data line is not idle after the 10th bit (start, 8 data bits, and
parity bit), the keyboard will continue to send a KBD clock signal until the KBD data line becomes idle (Note: see also Limitations).

Host Commands [Toc] [Top]

These commands are sent by the host to the keyboard. The most common command would be the setting/resetting of the status indicators (i.e. the Num lock, Caps
Lock & Scroll Lock LEDs). The more common and useful commands are shown below.

ED Set status LED's - This command can be used to turn on and off the Num Lock, Caps Lock & Scroll Lock LED's. After sending ED, keyboard will reply
with ACK (FA) and wait for another byte which determines their status. Bit 0 controls the Scroll Lock, bit 1 the Num Lock and bit 2 the Caps lock. Bits 3
to 7 are ignored.
EE Echo - upon sending an echo command to the keyboard, the keyboard should reply with an echo (EE).
F0 Set scan code set. Upon sending F0, keyboard will reply with ACK (FA) and wait for another byte, 01-03 which determines the scan code used. Sending 00
as the second byte will return the scan code set currently in use.
F3 Set typematic repeat rate. Keyboard will acknowledge command with FA and wait for a second byte, which determines the typematic repeat rate.

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (11 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

F4 Keyboard enable - clears the keyboard's output buffer, enables keyboard scanning and returns an acknowledgment.
F5 Keyboard disable - resets the keyboard, disables keyboard scanning and returns an acknowledgment.
FE Resend - upon receipt of the re-send command, the keyboard will re-transmit the last byte sent.
FF Reset - resets the keyboard.

Please refer to Craig Peacock's website for more information: Interfacing the PC's Keyboard

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Code [Toc] [Top]

Main File Main Keyboard Decode Lookup Table SHIFT Keyboard Decode Lookup Table HEX Files

Latest version: English 'codepage' (QWERTY) English 'codepage' (QWERTY) QWERTY 'codepage':
kbd_1xx.asm View: eng_main.html View: eng_shif.html kbd_104_eng.hex
Download: eng_main.asm Download: eng_shif.asm
QWERTZ 'codepage':
Modified Swiss German Modified Swiss German kbd_104_sg.hex
'codepage' (QWERTZ) 'codepage' (QWERTZ)
View: ger_main.html View: ger_shif.html
Download: ger_main.asm Download: ger_shif.asm

The above programs need additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_rs096.asm

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Schematic, Data Sheets and Pinout [Toc] [Top]

AT Keyboard Specification (PDF, 189 kB)

The schematic of the AT keyboard interface using the PIC 16F84: Keyboard_V1xx.pdf.

You don't know how a dot matrix LCD is working? Have a look at my data sheets page.

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (12 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

Download ASCII Character Map: ASCII-Map.pdf

You can get the pinout and a description of the various keyboard connectors <here>.

User-specific Customization / FAQ [Toc] [Top]

This section covers important details of the code structure. For a high level view, please refer to the section 'How it works' above. Basically, I have written this
keyboard project in such a way that it is completely customizable depending on your programming/PIC assembler skills.

How do I use the AT Keyboard Input? [Toc] [Top]

Question: I'm running your AT Keyboard code. But how do I use the decoded input of the AT keyboard...?

Answer: The decoded content resides usually in the register KBD. You can use the content of this register in the main routine in the infinitive loop. Please see the
section 'How it works' above.

How does the Scan Pattern Decoding work exactly? [Toc] [Top]

Question: How does your AT scan pattern decoding work exactly? You are using two strange look-up tables...

Answer: Have a look at some parts of the 'AT Keyboard Lookup Table', e.g. the eng_main.asm (QWERTY):

The simple lookup table decoding is done with retlw x and DT x. These directives just return the corresponding ASCII character. The more sophisticated decoding
is done with subroutines, i.e. goto _XYZ. This means for instance that for a ENTER/RETURN key hit on the keyboard, the subroutine _CRLF is executed (carriage
return, line feed) and for ALT, CTRL, SHIFT and CAPS_LOCK, the corresponding flags are set in their corresponding subroutines.

goto _ALT ; ALT (set/clear ALT flag)


goto _SHIFT ; SHIFT (set/clear SHIFT flag)
retlw 0 ;
goto _CTRL ; CTRL (set/clear CTRL flag)
DT "q1" ; DT: MPASM directive to create a table (retlw x)
goto _CRLF ; CR, LF 0x5A

Because the keyboard sends slightly different scan patterns for both, key hit and key release, there is need for a key release handling. This is done with the so-
http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (13 of 18)12/02/2008 17:16:09
AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

called release flag. So for every single character typed, the interrupt service routine is called twice (due to two different scan codes for hit and release) and the scan
pattern decoding routine is executed twice.

#define RELflag FLAGreg,0x00 ; release flag (0xF0)


#define SHIflag FLAGreg,0x01 ; shift flag (0x12 / 0x59)
#define SPEflag FLAGreg,0x02 ; special code flag (0xE0)
#define CAPflag FLAGreg,0x03 ; caps lock flag (0x0D)
#define ALTflag FLAGreg,0x04 ; ALT flag (0x11)
#define CTRLflag FLAGreg,0x05 ; CTRL flag (0x14)
#define KBDflag FLAGreg,0x06 ; keyboard data reception flag

There are these four main code blocks in the keyboard assembler source:

1. Interrupt based keyboard scan pattern acquisition


2. Keyboard scan code pre-decoding, set / clear flags
3. Scan code range checking (consistency checks)
4. Scan code decoding (look-up tables) & ASCII character conversion and output (LCD, RS232)

To save code space, I've implemented the two look-up tables (main and shift) as follows:

Small letters (a-z) are translated directly with the main look-up table, capital letters (A-Z) are obtained by simply adding d'224' (8 bit unsigned wrap-
around) to the main look-up table results of small letters. Active shift button of the keyboard is only tracked by the shift flag.
Shift table is only used for special character conversion, e.g. +, %, &, (, ), ?
Compression is also applied to lookup sections, where scan patterns are quite distant, e.g. for the entire keyboard num-block (keypad).

If you apply changes to the existing code, you may need to change the ORG directives in order to realign the assembler code properly, due to the different lookup
tables and the PIC page boundaries.

My own Key Customization [Toc] [Top]

Question: I have built successfully your AT keyboard project and it is running very well.
Now I want to customize my code such as to print out a predefined phrase e.g. 'Hello World' whenever I hit a specific key...?

Answer: This is not a difficult task, if you just use one specific key, for instance F9.
(For sequences like 'asdf', you must write your own detection routine for the main loop by checking the values in register KBD.) First look at the look-up tables
(LUT), for instance the eng_main.asm (QWERTY):

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (14 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

It is essentially a LUT which performs the decoding of the acquired keyboard scan codes into characters. At the top, the entries for the F1-F12 function keys are
located.
If you want a specific text to be displayed by pressing F9, change the line
retlw A'9' ; F9 -> 9 0x01

KBDtable ; (not used for characters typed with shift button active)
addwf PCL,F
retlw 0 ; invalid entry
retlw A'9' ; F9 -> 9 0x01
retlw 0 ;
retlw A'5' ; F5 -> 5

to
goto _MyRoutine

KBDtable ; (not used for characters typed with shift button active)
addwf PCL,F
retlw 0 ; invalid entry
goto _MyRoutine ; NEW: user-specific decoding for F9
retlw 0 ;
retlw A'5' ; F5 -> 5

Then you implement your own key-specific handler/subroutine _MyRoutine in the main file (section sub-routines), which displays your string, e.g. something like:

_MyRoutine
SENDw 'H' ; send to RS232
SENDw 'e'
SENDw 'l'
SENDw 'l'
SENDw 'o'
SENDw ' '
SENDw 'W'
SENDw 'o'
SENDw 'r'
SENDw 'l'
RETLW 'd' ; return with last character in w
http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (15 of 18)12/02/2008 17:16:09
AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

; alternative termination:
; SENDw 'd'
; RETLW 0 ; clear w to obtain invalid entry

You can do anything in this routine, just terminate with a RETLW 0 and ensure not to change any reserved registers...
If you want to alter the output for the keyboard characters in general, look at the the '_OUTP' section in the assembler source file kbd_1xx.asm:

_OUTP ;*** RS232 ***


movfw KBD
SENDw ; send actual pressed keyboard character
goto _ClrStall

There, the acquired keyboard character (in KBD) is sent to the RS232 interface.
If having a LCD display, the value of KBD might also be displayed using:

_OUTP ;*** LCD & RS232 ***


movfw KBD
LCDw ; display keyboard character on LCD
movfw KBD
SENDw ; send actual pressed keyboard character
goto _ClrStall

This is roughly what is done in the '_OUTP' section in the assembler source file kbd_2xx.asm.

My own Key Sequence [Toc] [Top]

Question: I have built successfully your AT keyboard project and it is running very well.
Now I want to customize my code such as to detect a specific key sequence, e.g. 'asdf'. Is this feasible...?

Answer: This is a more challenging task. (Alternatively, consider to just use one specific key e.g. F9 as described above.)
You need to write your own subroutine in the main loop in order to detect the desired character sequence. The keyboard character is usually passed within the
register KBD.

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (16 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

;******************************
_MLOOP btfsc KBDflag ; check scan pattern reception flag
call KBDdecode ; if set, call decoding routine
;btfsc your_other_flag
;call your_other_service
goto _MLOOP
;******************************

Confusion about Sweden and Switzerland...? [Toc] [Top]

Do you know Microsoft? Are you a global player, too? Or do you travel sometimes to Europe?
Did it happen to you, that you ended up in Stockholm instead of Zurich?

Don't worry, even Microsoft is confused by the two european countries, Sweden and Switzerland.
You are excused as well if you mix this up...

Microsoft Wired Keyboard 500


I recently bought two cheap, but nice Microsoft PS/2 keyboards - before PS/2 products are fading out. Microsoft obviously does not know the
difference between Sweden and Switzerland: They supplied a skandinavian manual (swedish, norwegian, danish, finnish) instead of a central
europe one (german, french, italian, english). Ok, it could have been worse: they could have shipped a japanese keyboard layout...

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (17 of 18)12/02/2008 17:16:09


AT Keyboard Interface V1.04 for Microchip PIC 16F84 Microcontroller

Last updated: 23.04.2006

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/keyboard/v1xx/keyboard_v1xx.html (18 of 18)12/02/2008 17:16:09


AT Keyboard Interface V2.04 for Microchip PIC16F84 Microcontroller

AT Keyboard Interface V2.04


with Dot-Matrix LCD Display for Microchip PIC16F84

Table of Contents [Toc]

Concept
How it works
Specifications
Features
Limitations
Project Resources
Available PIC Assembler Code
Schematic, Data Sheets, Pinout
User-specific Customization

Concept [Toc] [Top]

This implementation contains the complete fetch and decoding of AT keyboard scan patterns as well as RS232 transmission of ASCII characters to the RS232
target device. It also features an interface to a dot matrix LCD display to visualize the characters typed on the locally attached keyboard.

http://www.trash.net/~luethi/microchip/projects/keyboard/v2xx/keyboard_v2xx.html (1 of 5)12/02/2008 17:16:10


AT Keyboard Interface V2.04 for Microchip PIC16F84 Microcontroller

An elderly picture of my workplace, at which the initial


A recent picture of my workplace connecting a Microsoft
development took place.
PS/2 AT keyboard to the PIC16F84.

How it works [Toc] [Top]

Any key stroke on the local keyboard will send the corresponding scan patterns from the keyboard to the PIC microcontroller. Afterwards, the microcontroller
converts the keyboard scan patterns to ASCII characters, shows them on the LCD display and transmits them to the RS232 target device.
The keyboard scan code capture is done by an interrupt service routine. The event, which triggers the interrupt is a falling edge on the keyboard clock line
(PORTB,0). Keyboard scan pattern acquisition takes place at the keyboard data line (PORTA,4). After 11 clocks (i.e. 11 external interrupts on RB0/INT), the
interrupt service routine has completely captured an 8 bit element of the entire scan pattern and sets a ready flag. The decoding of this 8 bit element is then carried
out during normal operation mode, activated by a valid ready flag whilst keeping the keyboard stalled (keyboard clock line low).

The fact, that the scan pattern acquisition is carried out using an interrupt service routine and the decoding thereof is done during normal operation mode allows for
performing other tasks concurrently: That's why I call the acquisition routine preemptive. It does not block the processor while acquiring data.

Only RS232 transmission is supported by this program, since PORTB,0 interrupt is already used by the keyboard clock line. There exists no possibility to
implement also RS232 reception using my modules m_rsxxx.asm, because they require PORTB,0 as well and are laid out as non-preemptive data acquisition
routines (see also 'Limitations').

For dedicated code adaptations, please refer to the section 'User-specific Customization' below.

If you don't know the theory of AT keyboards, have a look at my short introduction or at Craig Peacocks tutorial about Interfacing the PC's Keyboard.

http://www.trash.net/~luethi/microchip/projects/keyboard/v2xx/keyboard_v2xx.html (2 of 5)12/02/2008 17:16:10


AT Keyboard Interface V2.04 for Microchip PIC16F84 Microcontroller

Specifications [Toc] [Top]

Processor: Microchip PIC16F84


Clock Frequency: 4 MHz crystal
Throughput: 1 MIPS
RS232 Baud Rate: 9600 baud, 8 bit, no parity, 1 stopbit
Code Size of entire Program: 984 instruction words
Keyboard Routine Features: Capability of bi-directional communication between microcontroller and keyboard
Acquisition Methodology: Preemptive, interrupt-based keyboard scan pattern acquisition, decoding to ASCII characters
during normal operation mode activated by ready flag
Required Hardware: AT keyboard, PS/2 connector, MAX232, HD44780 compatible dot matrix LCD (2x16, 2x20 or
2x40 characters)
Required Software: RS232 terminal software (or Excel 97 RS232 Debug Interface)

Features [Toc] [Top]

Uni-directional communication between microcontroller application and remote RS232 client.


Bi-directional communication between microcontroller and keyboard.
Bi-directional communication between microcontroller and LCD display.
Visualization of transmitted characters on local LCD.
Parametrizable LCD display width: constant 'LCDwidth'
Support for all keyboard characters typed with shift button active and inactive.
English and modified Swiss-German 'codepages' available (QWERTY and QWERTZ)
Caps Lock implemented
Num Lock always active
Support of ASCII conversion from direct ALT-DEC entries, e.g. ALT + 6 + 4 = @ (ALT + [1..3] numbers)
Support of ASCII conversion from direct CTRL-HEX entries, e.g. CTRL + 3 + F = ? (CTRL + [1..2] letters/numbers)
ALT-DEC and CTRL-HEX features work for both, keypad and keyboard numbers, as well as with upper and lower case letters [a..f]
Possibility to implement short-cuts or user defined characters for 'Esc', 'Num Lock', 'Scroll Lock' and 'F1' - 'F12' keys.

http://www.trash.net/~luethi/microchip/projects/keyboard/v2xx/keyboard_v2xx.html (3 of 5)12/02/2008 17:16:10


AT Keyboard Interface V2.04 for Microchip PIC16F84 Microcontroller

Limitations [Toc] [Top]

Basically the same limitations as for AT Keyboard Interface V1.xx.

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Code [Toc] [Top]

Main File Main Keyboard Decode Lookup Table SHIFT Keyboard Decode Lookup Table HEX Files

Latest version: English 'codepage' (QWERTY) English 'codepage' (QWERTY) QWERTY 'codepage':
kbd_2xx.asm View: eng_main.html View: eng_shif.html kbd_204_eng.hex
Download: eng_main.asm Download: eng_shif.asm
Slim version without ALT- QWERTZ 'codepage':
DEC & CTRL-HEX feature: Modified Swiss German Modified Swiss German kbd_204_sg.hex
kbd_202b.asm 'codepage' (QWERTZ) 'codepage' (QWERTZ)
View: ger_main.html View: ger_shif.html
Download: ger_main.asm Download: ger_shif.asm

The above programs need additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_rs096.asm, m_lcd_bf.asm
Important: Due to bi-directional communication between controller and keyboard as well as between controller and LCD display, the above programs only
work if both components are connected and are working properly!

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Schematic, Data Sheets and Pinout [Toc] [Top]

AT Keyboard Specification (PDF, 189 kB)

The schematic of the AT keyboard interface using the PIC 16F84: Keyboard_V2xx.pdf.

You don't know how a dot matrix LCD is working? Have a look at my data sheets page.

http://www.trash.net/~luethi/microchip/projects/keyboard/v2xx/keyboard_v2xx.html (4 of 5)12/02/2008 17:16:10


AT Keyboard Interface V2.04 for Microchip PIC16F84 Microcontroller

Download ASCII Character Map: ASCII-Map.pdf

You can get the description of the various keyboard connectors <here>.

User-specific Customization [Toc] [Top]

For a high level view, please refer to the section 'How it works' above.
Basically the same customization as for AT Keyboard Interface V1.xx applies to this implementation.

If you apply changes to the existing code, you may need to change the ORG directives in order to realign the assembler code properly.

Last updated: 17.04.2006

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/keyboard/v2xx/keyboard_v2xx.html (5 of 5)12/02/2008 17:16:10


AT Keyboard Interface V3.05 for Microchip PIC 16C74A Microcontroller

AT Keyboard Interface V3.05


with LCD Display for Microchip PIC16F77 / PIC16C74A

Table of Contents [Toc]

Concept
How it works
Specifications
Features
Limitations
Project Resources
Available PIC Assembler Code
Schematic, Data Sheets, Pinout
User-specific Customization

Concept [Toc] [Top]

This implementation contains the complete fetch and decoding of AT keyboard scan patterns as well as RS232 transmission and reception of ASCII characters to
and from the remote RS232 client. This microcontroller application also features an interface to a dot matrix LCD display to visualize the the data received from
the RS232 client on the first line, and the characters typed on the locally attached keyboard on the second line.

http://www.trash.net/~luethi/microchip/projects/keyboard/v3xx/keyboard_v3xx.html (1 of 6)12/02/2008 17:16:12


AT Keyboard Interface V3.05 for Microchip PIC 16C74A Microcontroller

How it works [Toc] [Top]

Any key stroke on the local keyboard will send the corresponding scan patterns from the keyboard to the PIC microcontroller. Afterwards, the microcontroller
converts the keyboard scan patterns to ASCII characters, shows them on the LCD display and transmits them to the RS232 target device.
The keyboard scan code capture is done by an interrupt service routine. The event, which triggers the interrupt is a falling edge on the keyboard clock line
(PORTB,0). Keyboard scan pattern acquisition takes place at the keyboard data line (PORTA,4). After 11 clocks (i.e. 11 external interrupts on RB0/INT), the
interrupt service routine has completely captured an 8 bit element of the entire scan pattern and sets a ready flag. The decoding of this 8 bit element is then carried
out during normal operation mode, activated by a valid ready flag whilst keeping the keyboard stalled (keyboard clock line low).

http://www.trash.net/~luethi/microchip/projects/keyboard/v3xx/keyboard_v3xx.html (2 of 6)12/02/2008 17:16:12


AT Keyboard Interface V3.05 for Microchip PIC 16C74A Microcontroller

The fact, that the scan pattern acquisition is carried out using an interrupt service routine and the decoding thereof is done during normal operation mode allows for
performing other tasks concurrently: That's why I call the acquisition routine preemptive. It does not block the processor while acquiring data.

This program features also the capability of bi-directional communication between controller and keyboard for configuration purposes and to control the keyboard
LEDs. RS232 data exchange is carried out by using the internal USART of the PIC 16C74A. RS232 data reception is done on an interrupt-based acquisition
scheme, provided by the USART.

For dedicated code adaptations, please refer to the section 'User-specific Customization' below.

If you don't know the theory of AT keyboards, have a look at my short introduction or at Craig Peacocks tutorial about Interfacing the PC's Keyboard.

Specifications [Toc] [Top]

Processor: PIC16C74 A
Clock Frequency: 4.00 / 8.00 MHz crystal
Throughput: 1 / 2 MIPS
RS232 Baud Rate: 9600 / 19200 baud with BRGH = 1
Keyboard Routine Features: Capability of bi-directional communication between controller and
keyboard
Acquisition Methodology: Preemptive, interrupt-based keyboard scan pattern acquisition,
decoding to ASCII characters during normal operation mode
activated by ready flag
Code Size of entire Program: 964 instruction words
Required Hardware: AT keyboard, PS/2 connector, MAX232, HD44780 compatible dot
matrix LCD (2x16, 2x20 or 2x40 characters)
Required Software: RS232 terminal software (or Excel 97 RS232 Debug Interface)

Features [Toc] [Top]

Bi-directional communication between microcontroller application and remote RS232 client.


Bi-directional communication between microcontroller and keyboard.
Bi-directional communication between microcontroller and LCD display.
Visualization of received and transmitted characters on local LCD.
Parametrizable LCD display width: constant 'LCDwidth'
Support for all keyboard characters typed with shift button active and inactive.

http://www.trash.net/~luethi/microchip/projects/keyboard/v3xx/keyboard_v3xx.html (3 of 6)12/02/2008 17:16:12


AT Keyboard Interface V3.05 for Microchip PIC 16C74A Microcontroller

English and modified Swiss-German 'codepages' available (QWERTY and QWERTZ)


Caps Lock implemented
Num Lock always active
Support of ASCII conversion from direct ALT-DEC entries, e.g. ALT + 6 + 4 = @ (ALT + [1..3] numbers)
Support of ASCII conversion from direct CTRL-HEX entries, e.g. CTRL + 3 + F = ? (CTRL + [1..2] letters/numbers)
ALT-DEC and CTRL-HEX features work for both, keypad and keyboard numbers, as well as with upper and lower case letters [a..f]
Possibility to implement short-cuts or user defined characters for 'Esc', 'Num Lock', 'Scroll Lock' and 'F1' - 'F12' keys.

Limitations [Toc] [Top]

Important note from Jason Plumb:

Hey,

First, lemme say that I like your site and thank you for providing excellent reference material for us home-hobbyist microcontroller geeks. I am currently
working on a music/noise project that uses a PS/2 keyboard interfaced to a PIC16F84, and I used your page at http://www.electronic-engineering.ch/microchip/
projects/keyboard/v1xx/keyboard_v1xx.html heavily as a reference when designing hardware and writing code. Anyway, I just thought that I would mention
that I ran into a problem that I have since solved. The problem involved sending bytes *TO* the keyboard from the PIC (in order to light NumLock and
ScrollLock). Your "Host To Keyboard Protocol" section indicates that the keyboard will take the data line low for a clock after the byte is sent to create an ACK
bit. Apparently, the PS/2 keyboard that I have (generic $10 comp-USA brand) doesn't send an ACK bit, but rather sends a whole byte. If my code attempted to
wait for the ACK bit, it hung indefinitely. I changed the wait to look for a byte (by calling my existing function) and everything worked perfectly. I stumbled on
this idea by looking at other online references (most notably, some Linux kernel code at http://www.mscs.mu.edu/~georgec/Classes/207.1998/14Minix_book/S/
src%20kernel%20keyboard.c.html#307). I have seen this ACK *byte* mentioned elsewhere too. I *think* the keyboard sends back 0xFA as an ACK byte, but I
have not personally confirmed this. Perhaps your excellent documentation could just use a quick note of clarification so that other don't run into the same
problem. Maybe something as simple as: "NOTE: Some keyboards send an ACK byte (value 0xFA) instead of an ACK bit.".

Thanks again,
Jason

Note from the author:

The comment above refers to bi-directional communication between PIC microcontroller and AT keyboard, i.e. to the source code of the AT Keyboard Interface
V2.xx and higher versions. The bi-directional communication between host and keyboard is designed to support both Ack bits and Ack bytes.

Every command sent from the host to the keyboard needs to have an Odd Parity bit and an Ack bit at the end.
Every command received by the keyboard from the host needs to be acknowledged by the keyboard by sending an Ack byte (0xFA) to the host. See also
section 'Host to Keyboard Protocol' at the AT Keyboard Interface V1.xx page.
http://www.trash.net/~luethi/microchip/projects/keyboard/v3xx/keyboard_v3xx.html (4 of 6)12/02/2008 17:16:12
AT Keyboard Interface V3.05 for Microchip PIC 16C74A Microcontroller

A corresponding PIC assembler code example is shown below:

;*** switch keyboard LEDs on (default status) ***


KBDcmd 0xED ; keyboard LEDs' control command
KBDexp 0xFA ; expect keyboard acknowledge (FA)
movfw KBDleds ; load keyboard LEDs' status
KBDcmdw ; send keyboard LEDs' control data
KBDexp 0xFA ; expect keyboard acknowledge (FA)

However, some AT keyboards may behave different and may need code adaptations to get bi-directional communication working properly.

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Code [Toc] [Top]

Main File Main Keyboard Decode Lookup Table SHIFT Keyboard Decode Lookup Table HEX Files

Latest version: English 'codepage' (QWERTY) English 'codepage' (QWERTY) QWERTY 'codepage':
kbd_3xx.asm View: eng_main.html View: eng_shif.html kbd_3xx_eng.hex
Download: eng_main.asm Download: eng_shif.asm
Slim version without ALT- QWERTZ 'codepage':
DEC & CTRL-HEX feature: Modified Swiss German Modified Swiss German kbd_3xx_sg.hex
kbd_301.asm 'codepage' (QWERTZ) 'codepage' (QWERTZ)
View: ger_main.html View: ger_shif.html
Download: ger_main.asm Download: ger_shif.asm

The above programs need additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd_bf.asm
Important: Due to bi-directional communication between controller and keyboard as well as between controller and LCD display, the above programs only
work if both components are connected and are working properly!

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Schematic, Data Sheets and Pinout [Toc] [Top]

AT Keyboard Specification (PDF, 189 kB)


http://www.trash.net/~luethi/microchip/projects/keyboard/v3xx/keyboard_v3xx.html (5 of 6)12/02/2008 17:16:12
AT Keyboard Interface V3.05 for Microchip PIC 16C74A Microcontroller

The schematic of the AT keyboard interface using the PIC 16C74A: Keyboard_V3xx.pdf.

You don't know how a dot matrix LCD is working? Have a look at my data sheets page.

Download ASCII Character Map: ASCII-Map.pdf

You can get the description of the various keyboard connectors <here>.

User-specific Customization [Toc] [Top]

For a high level view, please refer to the section 'How it works' above.
Basically the same customization as for AT Keyboard Interface V1.xx applies to this implementation.

If you apply changes to the existing code, you may need to change the ORG directives in order to realign the assembler code properly.

Last updated: 30.12.2004

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/keyboard/v3xx/keyboard_v3xx.html (6 of 6)12/02/2008 17:16:12


AT Keyboard Box V2.05 for Microchip PIC 16C74A Microcontroller

AT Keyboard Box V2.05


with LCD Display for Microchip PIC16F77

Table of Contents [Toc]

Concept
How it works
Specifications
Parts order information
Features
Limitations
Project Resources
Available PIC Assembler Source Code
Schematics, Data Sheets, Pinout
User-specific Customization

Concept [Toc] [Top]

This implementation contains the complete fetch and decoding of AT keyboard scan patterns as well as RS232 transmission and reception of ASCII characters to
and from the remote RS232 client. This microcontroller application also features an interface to a dot matrix LCD display to visualize the the data received from
the RS232 client on the first line, and the characters typed on the locally attached keyboard on the second line. Further, the application has also a small numeric
foil-keypad and a piezo-beeper for acoustic feedback.
Dynamic configuration of RS232 baud rate setting at start-up (user-customization with 1200 baud - 115200 baud), with 12 seconds inactivity time-out. In case the
time-out applies, the user-customization process terminates with the current setting. Default setting after power-up is 9600 baud.

http://www.trash.net/~luethi/microchip/projects/keyboard/kbd_box/kbd_box.html (1 of 10)12/02/2008 17:16:14


AT Keyboard Box V2.05 for Microchip PIC 16C74A Microcontroller

PIC16F77 development board


with MAX232, serial port (and RS232 to USB1.1 Workplace
connector) and dot matrix LCD connection with numeric foil-keypad, interrupt generation circuit,
PIC16C74A development board, and laptop

Interrupt generator
for numeric foil-keypad: Whenever a key is hit, a key-
specific analog voltage is put on the first line to the A/
AT Keyboard Box V2.05 setup D converter. At the same time an interrupt is
with numeric foil-keypad, dot matrix LCD display and generated by this comparator circuit and put on the
AT keyboard second IRQ line.
http://www.trash.net/~luethi/microchip/projects/keyboard/kbd_box/kbd_box.html (2 of 10)12/02/2008 17:16:14
AT Keyboard Box V2.05 for Microchip PIC 16C74A Microcontroller

Front view
Numeric foil-keypad Microchip PIC16C74A microcontroller and piezo-
Connection topology: 1x12 beeper on the left side.

Screen shot of the HyperTerminal Program


showing the start-up message of the AT Keyboard Box V2.05
and some keyboard and keypad entries

How it works [Toc] [Top]

Basically it works in the same way as the AT Keyboard Interface V3.xx.

http://www.trash.net/~luethi/microchip/projects/keyboard/kbd_box/kbd_box.html (3 of 10)12/02/2008 17:16:14


AT Keyboard Box V2.05 for Microchip PIC 16C74A Microcontroller

Here is only the description of the additional small numeric foil-keypad. The numeric foil-keypad is equipped with a specific resistor cascade to decode the values
through direct 8 bit A/D conversion using the PIC-internal A/D converter. The advantage is a very low pin usage: Only two pins are necessary for proper detection
and decoding of all keypad entries. One pin provides the analog value, the other pin serves for interrupt generation whenever a key of the keypad is touched. The
interrupt is used to start the A/D conversion.

During the interrupt service routine, only a short busy wait (analog settling time) and the A/D conversion - using the internal RC oscillator - is carried out. Before
leaving the ISR, the 8 bit A/D result is stored in a specific register and a dedicated flag is set.

Decoding of the A/D value is done during normal operation (activated by the flag) using two look-up tables. The first look-up table (LUT1) contains the expected
8 bit values of the keypad to check for valid entries. A numeric window of 3 allows for slight analog deviations during matching. The matching algorithm just
scans the entire LUT1 until the received keypad A/D result matches a LUT1 entry. The amount of loops carried out in LUT1 determines the position of the
corresponding symbol/character in LUT2. At the end, RS232 transmission and LCD display update are carried out.

Dynamic configuration of RS232 baud rate setting at start-up (user-customization with 1200 baud - 115200 baud). A watchdog timer implemented using TMR1
checks for inactivity during the customization process. After 12 seconds of inactivity, the user-customization process terminates with the current setting. At power-
up, the default setting is 9600 baud, which will be configured after the time-out - unless no user-customization takes place.

This setup works also without attached foil-keypad, even if the corresponding code is assembled and loaded into the microcontroller.

LCD display after power-up, ready for customization of RS232


User customization is done by pressing 'a' on the AT keyboard
or '*' on the numeric foil-keypad

http://www.trash.net/~luethi/microchip/projects/keyboard/kbd_box/kbd_box.html (4 of 10)12/02/2008 17:16:14


AT Keyboard Box V2.05 for Microchip PIC 16C74A Microcontroller

LCD display after first alteration


(pressed button 'a' or '*' once)

LCD display after third alteration


(pressed again button 'a' or '*')

LCD display with completed user customization of RS232


(pressed button 's' or '#' once)

http://www.trash.net/~luethi/microchip/projects/keyboard/kbd_box/kbd_box.html (5 of 10)12/02/2008 17:16:14


AT Keyboard Box V2.05 for Microchip PIC 16C74A Microcontroller

LCD display showing locally entered data on second line


(i.e. entered on local AT keyboard or foil-keypad)

LCD display showing both remote and locally entered data


(upper line was entered on remote host, lower line was entered
on local AT keyboard or foil-keypad)

Specifications [Toc] [Top]

Processor: PIC16F77 (PIC16C74A)


Clock Frequency: 14.745600 MHz (HS mode)
Throughput: 3.7 MIPS
RS232 Baud Rate: Customizable by user (BRGH = 0),
any setting from 1200 baud - 115200 baud
Serial Output: default setup: 9600 baud, 8 bit, no parity, 1 stopbit
Keyboard Routine Features: Capability of bi-directional communication between controller and
keyboard
Numeric Keypad Features: Interrupt-based acquisition, direct 8 bit A/D conversion
Acquisition Methodology: Preemptive, interrupt-based keyboard scan pattern acquisition,
decoding to ASCII characters during normal operation mode
activated by ready flag (including LCD display and RS232
activities)
Code Size of entire Program: 1463 instruction words
http://www.trash.net/~luethi/microchip/projects/keyboard/kbd_box/kbd_box.html (6 of 10)12/02/2008 17:16:14
AT Keyboard Box V2.05 for Microchip PIC 16C74A Microcontroller

Required Hardware: AT keyboard, PS/2 connector, MAX232 level shifter, dedicated


foil-keypad, LM393 comparator circuity for interrupt generation,
HD44780 compatible dot matrix LCD (2x16, 2x20 or 2x40
characters)
Optional Hardware: Piezo beeper with decoupling capacitor
Required Software: RS232 terminal software (or Excel 97 RS232 Debug Interface)

Note that every change in microprocessor clock frequency needs a re-calibration and/or re-design of the analog foil-keypad decoding circuitry.

Parts order information [Toc] [Top]

Numeric foil-keypad order information and technical specifications:


www.conrad.de: FOLIENTASTATUR 1x12, Part-Nr. 709948-14

Features [Toc] [Top]

Dynamic configuration of RS232 baud rate setting at start-up.


Bi-directional communication between microcontroller application and remote RS232 client.
Bi-directional communication between microcontroller and keyboard.
Bi-directional communication between microcontroller and LCD display.
Supports foil-keypad input through direct 8 bit A/D conversion and look-up table.
Piezo-beeper for acoustic feedback of keypad entries.
Visualization of received and transmitted characters on local LCD.
Parametrizable LCD display width: constant 'LCDwidth'
Support for all keyboard characters typed with shift button active and inactive.
English and modified Swiss-German 'codepages' available (QWERTY and QWERTZ)
Caps Lock implemented
http://www.trash.net/~luethi/microchip/projects/keyboard/kbd_box/kbd_box.html (7 of 10)12/02/2008 17:16:14
AT Keyboard Box V2.05 for Microchip PIC 16C74A Microcontroller

Num Lock always active


Support of ASCII conversion from direct ALT-DEC entries, e.g. ALT + 6 + 4 = @ (ALT + [1..3] numbers)
Support of ASCII conversion from direct CTRL-HEX entries, e.g. CTRL + 3 + F = ? (CTRL + [1..2] letters/numbers)
ALT-DEC and CTRL-HEX features work for both, keypad and keyboard numbers, as well as with upper and lower case letters [a..f]
Possibility to implement short-cuts or user defined characters for 'Esc', 'Num Lock', 'Scroll Lock' and 'F1' - 'F12' keys.

Limitations [Toc] [Top]

Basically the same limitations as for AT Keyboard Interface V3.xx.

The analog foil-keypad decoding approach deserves dedicated design and calibration: If a key on the keypad is hit, an interrupt is generated to start the A/D
conversion. The analog value built by the keypad resistor cascade needs some settling time until stable and reproduceable A/D values can be read out by the PIC
microprocessor (overshoots, undershoots).

This means that the PIC microprocessor clock frequency (related to the A/D conversion speed), output drive strength of the keypad resistor cascade and both
debounce capacitors on IRQ line and analog value pin affect the proper function of the keypad circuit. Whenever the PIC clock frequency is changed, (slight)
adaptations on the analog circuitry may have to be expected.
For calibration of the numeric foil-keypad, please refer to the page 'Numeric Foil-Keypad Calibration V0.04'.

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Source Code [Toc] [Top]

Main File Main Keyboard Decode Lookup Table SHIFT Keyboard Decode Lookup Table HEX Files

Fully functional version English 'codepage' (QWERTY) English 'codepage' (QWERTY) QWERTY 'codepage':
V2.05: View: eng_main.html View: eng_shif.html kbd_box_eng.hex
kbd_box.asm Download: eng_main.asm Download: eng_shif.asm
QWERTZ 'codepage':
See also 'Numeric Foil- Modified Swiss German Modified Swiss German kbd_box_sg.hex
Keypad Calibration V0.04' 'codepage' (QWERTZ) 'codepage' (QWERTZ)
View: ger_main.html View: ger_shif.html
Download: ger_main.asm Download: ger_shif.asm

http://www.trash.net/~luethi/microchip/projects/keyboard/kbd_box/kbd_box.html (8 of 10)12/02/2008 17:16:14


AT Keyboard Box V2.05 for Microchip PIC 16C74A Microcontroller

The above programs need additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd_bf.asm
Important: Due to bi-directional communication between controller and keyboard as well as between controller and LCD display, the above programs only
work if both components are connected and are working properly!

Schematics, Data Sheets and Pinout [Toc] [Top]

AT Keyboard Specification (PDF, 189 kB)

The schematics of the AT Keyboard Box using the PIC16F77:

Top view: kbd_box_top.pdf (with outdated 4 MHz crystal, now 14.7456 MHz)
LCD connection: kbd_box_lcd.pdf
Numeric foil-keypad: kbd_box_keypad.pdf
RS232 circuitry: kbd_box_max232.pdf
Power supply: kbd_box_power.pdf
Simulation of interrupt generation circuit (positive IRQ pulses): kbd_box_sdf.pdf

You don't know how a dot matrix LCD is working? Have a look at my data sheets page.

Download ASCII Character Map: ASCII-Map.pdf

You can get the description of the various keyboard connectors <here>.

User-specific Customization [Toc] [Top]

For a high level view, please refer to the section 'How it works' above.
Basically the same customization as for AT Keyboard Interface V1.xx applies to this implementation.

If you apply changes to the existing code, you may need to change the ORG directives in order to realign the assembler code properly.

Last updated: 26.12.2004


http://www.trash.net/~luethi/microchip/projects/keyboard/kbd_box/kbd_box.html (9 of 10)12/02/2008 17:16:14
AT Keyboard Box V2.05 for Microchip PIC 16C74A Microcontroller

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/keyboard/kbd_box/kbd_box.html (10 of 10)12/02/2008 17:16:14


AT Keyboard Interface with Morse Code Support V1.02 for Microchip PIC16F84 Microcontroller

AT Keyboard Interface with Morse Code Support V1.02


for Microchip PIC16F84

Table of Contents [Toc]

Concept
How it works
Specifications
Supported Morse Alphabet
Features
Limitations
Project Resources
Available PIC Assembler Code
Schematic, Data Sheets, Pinout
User-specific Customization

Concept [Toc] [Top]

This implementation contains the complete fetch and decoding of AT keyboard scan patterns as well as RS232 transmission of ASCII characters to the RS232
target device.
Additional Morse port for pulse-width modulated (PWM) Morse code output. Further, there is also the ability to enable acoustic Morse code feedback through a
Piezo beeper (parameterizable feature).

How it works [Toc] [Top]

Basically, it works in the same way as the AT Keyboard Interface V1xx.

Morse code feature:


All legal ASCII characters specified within the Morse alphabet are translated to a 16 bit pattern through a look-up table. Within these bit patterns, two consecutive
ones followed by a zero indicate a dash, a dot is encoded as single one followed by a zero.
The Morse code has different lengths for encoding, e.g. e = . b = -... 1 = .---- ? = ..--.. therefore 16 bits are necessary to support all of them. For
instance, 'b' is encoded in 16 bits as b'1101_0101_0000_0000'. Subsequent zeros at the end within a pattern are considered as termination and are ignored. The
Morse pattern is signaled as pulse-width modulated stream at the Morse port, active high.
http://www.trash.net/~luethi/microchip/projects/keyboard/morse_1x/morse_1x.html (1 of 6)12/02/2008 17:16:15
AT Keyboard Interface with Morse Code Support V1.02 for Microchip PIC16F84 Microcontroller

Parameterization of Piezo beeper support (acoustic Morse code feedback) with constant BEEP_ENABLE within section 'Parameterization' in program code.

Customization of Morse code speed at assemble time (length of dot, length of dash, wait period in between dash and dot, wait period in between two characters)
can be done using constants within section 'Constant declaration' in program code. No dynamic speed control during run time (not yet).

Since Morse code transmission needs some time for each character - especially numbers - multiple typed characters at the AT keyboard are stalled within the
keyboard internal TX buffer whenever the PIC microcontroller pulls down the open-collector clock line (between keyboard and PIC) for stalling. With this
scheme, up to 7 keyboard characters can be queued up without data loss (in my no-name 10$ keyboard). This queuing mechanism is maybe keyboard-dependent.

Translation from keyboard ASCII characters to Morse code is done using a look-up table. The look-up table for the ASCII to 16 bit Morse pattern conversion has
been created using an Excel 97 work sheet (MorseTableGenerator.zip) and Visual Basic macros. The supported Morse alphabet is listed in this table below.

The 16 bit Morse code look-up table for Microchip PIC assembler has been
http://www.trash.net/~luethi/microchip/projects/keyboard/morse_1x/morse_1x.html (2 of 6)12/02/2008 17:16:15
AT Keyboard Interface with Morse Code Support V1.02 for Microchip PIC16F84 Microcontroller

created automatically using an Excel 97 work sheet and Visual Basic macros.

Specifications [Toc] [Top]

Processor: Microchip PIC 16F84


Clock Frequency: 4 MHz crystal
Throughput: 1 MIPS
RS232 Baud Rate: 9600 baud, 8 bit, no parity, 1 stopbit
Keyboard Routine Features: Capability of uni-directional communication between microcontroller and keyboard
Acquisition Methodology: Preemptive, interrupt-based keyboard scan pattern acquisition, decoding to ASCII characters
during normal operation mode activated by ready flag
Code Size of entire Program: 800 instruction words
Required Hardware: AT keyboard, PS/2 connector, MAX232
Optional Hardware: Piezo beeper with decoupling capacitor
Required Software: RS232 terminal software

Supported Morse Alphabet [Toc] [Top]

Char Morse code Char Morse code Char Morse code Char Morse code
A .- N -. 0 ----- " .-..-.
B -... O --- 1 .---- ' .----.
C -.-. P .--. 2 ..--- () -.--.-
D -.. Q --.- 3 ...-- , --..--
E . R .-. 4 ....- - -....-
F ..-. S ... 5 ..... . .-.-.-
G --. T - 6 -.... : ---...
H .... U ..- 7 --... ? ..--..
I .. V ...- 8 ---..
J .--- W .-- 9 ----.

http://www.trash.net/~luethi/microchip/projects/keyboard/morse_1x/morse_1x.html (3 of 6)12/02/2008 17:16:15


AT Keyboard Interface with Morse Code Support V1.02 for Microchip PIC16F84 Microcontroller

K -.- X -..-
L .-.. Y -.--
M -- Z --..

Supported Morse alphabet within this Microchip PIC project.

Features [Toc] [Top]

Uni-directional communication between microcontroller application and remote RS232 client.


Uni-directional communication between microcontroller and keyboard.
Support for all keyboard characters typed with shift button active and inactive.
English and modified Swiss-German 'codepages' available (QWERTY and QWERTZ)
Caps Lock implemented
Num Lock always active
Possibility to implement short-cuts or user defined characters for 'Esc', 'Num Lock', 'Scroll Lock' and 'F1' - 'F12' keys.
Morse code translation and PWM output at Morse port, active high
Acoustic feedback through Piezo beeper, default enabled

Limitations [Toc] [Top]

Same as within AT Keyboard Interface V1.03.

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Code [Toc] [Top]

Main File Main Keyboard Decode Lookup Table SHIFT Keyboard Decode Lookup Table HEX Files

Latest version: English 'codepage' (QWERTY) English 'codepage' (QWERTY) QWERTY 'codepage':
morse_1x.asm View: eng_main.html View: eng_shif.html morse_1x_eng.hex
Download: eng_main.asm Download: eng_shif.asm
http://www.trash.net/~luethi/microchip/projects/keyboard/morse_1x/morse_1x.html (4 of 6)12/02/2008 17:16:15
AT Keyboard Interface with Morse Code Support V1.02 for Microchip PIC16F84 Microcontroller

QWERTZ 'codepage':
Modified Swiss German Modified Swiss German
morse_1x_sg.hex
'codepage' (QWERTZ) 'codepage' (QWERTZ)
View: ger_main.html View: ger_shif.html
Download: ger_main.asm Download: ger_shif.asm

The above programs need additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_rs096.asm, m_lcd_bf.asm.

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Schematic, Data Sheets and Pinout [Toc] [Top]

AT Keyboard Specification (PDF, 189 kB)

Basically, the schematic of the AT Keyboard Interface with Morse Code Support V1.02 is the same as the AT Keyboard Interface V1.04: Keyboard_V1xx.pdf
The only additional features:

PWM Morse code output at PortA1 (RA1), active high


Acoustic feedback through Piezo beeper at PortA3 (RA3)

The 16 bit Morse code look-up table for Microchip PIC assembler as Excel 97 work sheet with Visual Basic macros: MorseTableGenerator.zip

You don't know how a dot matrix LCD is working? Have a look at my data sheets page.

Download ASCII Character Map: ASCII-Map.pdf

You can get the description of the various keyboard connectors <here>.

User-specific Customization [Toc] [Top]

For a high level view, please refer to the section 'How it works' above.
Basically the same customization as for AT Keyboard Interface V1xx applies to this implementation.

If you apply changes to the existing code, you may need to change the ORG directives in order to realign the assembler code properly.

http://www.trash.net/~luethi/microchip/projects/keyboard/morse_1x/morse_1x.html (5 of 6)12/02/2008 17:16:15


AT Keyboard Interface with Morse Code Support V1.02 for Microchip PIC16F84 Microcontroller

Last updated: 19.04.2004

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/keyboard/morse_1x/morse_1x.html (6 of 6)12/02/2008 17:16:15


AT Keyboard Interface with Morse Code Support V2.02 for Microchip PIC16F84 Microcontroller

AT Keyboard Interface with Morse Code Support V2.02


with dot matrix LCD Display for Microchip PIC16F84

Table of Contents [Toc]

Concept
How it works
Specifications
Supported Morse Alphabet
Features
Limitations
Project Resources
Available PIC Assembler Code
Schematic, Data Sheets, Pinout
User-specific Customization

Concept [Toc] [Top]

This implementation contains the complete fetch and decoding of AT keyboard scan patterns as well as RS232 transmission of ASCII characters to the RS232
target device. It also features an interface to a dot matrix LCD display to visualize the characters typed on the locally attached keyboard.
Additional Morse port for pulse-width modulated (PWM) Morse code output. Further, there is also the ability to enable acoustic Morse code feedback through a
Piezo beeper (parameterizable feature).

How it works [Toc] [Top]

Basically, it works in the same way as the AT Keyboard Interface V2.03, although this program does not support direct Ctrl-Hex and Alt-Dec entry, and no bi-
directional communication between keyboard and PIC microcontroller. Further, there is also no RS232 data reception.

Morse code feature:


All legal ASCII characters specified within the Morse alphabet are translated to a 16 bit pattern through a look-up table. Within these bit patterns, two consecutive
ones followed by a zero indicate a dash, a dot is encoded as single one followed by a zero.
The Morse code has different lengths for encoding, e.g. e = . b = -... 1 = .---- ? = ..--.. therefore 16 bits are necessary to support all of them. For
instance, 'b' is encoded in 16 bits as b'1101_0101_0000_0000'. Subsequent zeros at the end within a pattern are considered as termination and are ignored. The
http://www.trash.net/~luethi/microchip/projects/keyboard/morse_2x/morse_2x.html (1 of 6)12/02/2008 17:16:16
AT Keyboard Interface with Morse Code Support V2.02 for Microchip PIC16F84 Microcontroller

Morse pattern is signaled as pulse-width modulated stream at the Morse port, active high.

Parameterization of Piezo beeper support (acoustic Morse code feedback) with constant BEEP_ENABLE within section 'Parameterization' in program code.

Customization of Morse code speed at assemble time (length of dot, length of dash, wait period in between dash and dot, wait period in between two characters)
can be done using constants within section 'Constant declaration' in program code. No dynamic speed control during run time (not yet).

Since Morse code transmission needs some time for each character - especially numbers - multiple typed characters at the AT keyboard are stalled within the
keyboard internal TX buffer whenever the PIC microcontroller pulls down the open-collector clock line (between keyboard and PIC) for stalling. With this
scheme, up to 7 keyboard characters can be queued up without data loss (in my no-name 10$ keyboard). This queuing mechanism is maybe keyboard-dependent.

Translation from keyboard ASCII characters to Morse code is done using a look-up table. The look-up table for the ASCII to 16 bit Morse pattern conversion has
been created using an Excel 97 work sheet (MorseTableGenerator.zip) and Visual Basic macros. The supported Morse alphabet is listed in this table below.

http://www.trash.net/~luethi/microchip/projects/keyboard/morse_2x/morse_2x.html (2 of 6)12/02/2008 17:16:16


AT Keyboard Interface with Morse Code Support V2.02 for Microchip PIC16F84 Microcontroller

The 16 bit Morse code look-up table for Microchip PIC assembler has been
created automatically using an Excel 97 work sheet and Visual Basic macros.

Specifications [Toc] [Top]

Processor: Microchip PIC 16F84


Clock Frequency: 4 MHz crystal
Throughput: 1 MIPS
RS232 Baud Rate: 9600 baud, 8 bit, no parity, 1 stopbit
Acquisition Methodology: Preemptive, interrupt-based keyboard scan pattern acquisition, decoding to ASCII characters
during normal operation mode activated by ready flag
Code Size of entire Program: 973 instruction words
Required Hardware: AT keyboard, PS/2 connector, MAX232, HD44780 compatible dot matrix LCD (2x16, 2x20 or
2x40 characters)
Optional Hardware: Piezo beeper with decoupling capacitor
Required Software: RS232 terminal software

Supported Morse Alphabet [Toc] [Top]

Char Morse code Char Morse code Char Morse code Char Morse code
A .- N -. 0 ----- " .-..-.
B -... O --- 1 .---- ' .----.
C -.-. P .--. 2 ..--- () -.--.-
D -.. Q --.- 3 ...-- , --..--
E . R .-. 4 ....- - -....-
F ..-. S ... 5 ..... . .-.-.-
G --. T - 6 -.... : ---...
H .... U ..- 7 --... ? ..--..
I .. V ...- 8 ---..

http://www.trash.net/~luethi/microchip/projects/keyboard/morse_2x/morse_2x.html (3 of 6)12/02/2008 17:16:16


AT Keyboard Interface with Morse Code Support V2.02 for Microchip PIC16F84 Microcontroller

J .--- W .-- 9 ----.


K -.- X -..-
L .-.. Y -.--
M -- Z --..

Supported Morse alphabet within this Microchip PIC project.

Features [Toc] [Top]

Uni-directional communication between microcontroller application and remote RS232 client.


Uni-directional communication between microcontroller and keyboard.
Bi-directional communication between microcontroller and LCD display.
Visualization of transmitted characters on local LCD.
Parametrizable LCD display width: constant 'LCDwidth'
Support for all keyboard characters typed with shift button active and inactive.
English and modified Swiss-German 'codepages' available (QWERTY and QWERTZ)
Caps Lock implemented
Num Lock always active
Possibility to implement short-cuts or user defined characters for 'Esc', 'Num Lock', 'Scroll Lock' and 'F1' - 'F12' keys.
Morse code translation and PWM output at Morse port, active high
Acoustic feedback through Piezo beeper, default enabled

Limitations [Toc] [Top]

Same as within AT Keyboard Interface V1xx.

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Code [Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/keyboard/morse_2x/morse_2x.html (4 of 6)12/02/2008 17:16:16


AT Keyboard Interface with Morse Code Support V2.02 for Microchip PIC16F84 Microcontroller

Main File Main Keyboard Decode Lookup Table SHIFT Keyboard Decode Lookup Table HEX Files

Latest version: English 'codepage' (QWERTY) English 'codepage' (QWERTY) QWERTY 'codepage':
morse_2x.asm View: eng_main.html View: eng_shif.html morse_2x_eng.hex
Download: eng_main.asm Download: eng_shif.asm
QWERTZ 'codepage':
Modified Swiss German Modified Swiss German morse_2x_sg.hex
'codepage' (QWERTZ) 'codepage' (QWERTZ)
View: ger_main.html View: ger_shif.html
Download: ger_main.asm Download: ger_shif.asm

The above programs need additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_rs096.asm, m_lcd_bf.asm
Important: Due to bi-directional communication between controller and LCD display, the above programs only work if both components are connected and
are working properly!

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Schematic, Data Sheets and Pinout [Toc] [Top]

AT Keyboard Specification (PDF, 189 kB)

Basically, the schematic of the AT Keyboard Interface with Morse Code Support V2.02 is the same as the AT Keyboard Interface V2.04: Keyboard_V2xx.pdf
The only additional features:

PWM Morse code output at PortA1 (RA1), active high


Acoustic feedback through Piezo beeper at PortA3 (RA3)

The 16 bit Morse code look-up table for Microchip PIC assembler as Excel 97 work sheet with Visual Basic macros: MorseTableGenerator.zip

You don't know how a dot matrix LCD is working? Have a look at my data sheets page.

Download ASCII Character Map: ASCII-Map.pdf

You can get the description of the various keyboard connectors <here>.

http://www.trash.net/~luethi/microchip/projects/keyboard/morse_2x/morse_2x.html (5 of 6)12/02/2008 17:16:16


AT Keyboard Interface with Morse Code Support V2.02 for Microchip PIC16F84 Microcontroller

User-specific Customization [Toc] [Top]

For a high level view, please refer to the section 'How it works' above.
Basically the same customization as for AT Keyboard Interface V1.xx applies to this implementation.

If you apply changes to the existing code, you may need to change the ORG directives in order to realign the assembler code properly.

Last updated: 30.12.2004

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/keyboard/morse_2x/morse_2x.html (6 of 6)12/02/2008 17:16:16


Fully software controlled RS232 communication test routine for PIC16F84

RS232 Communication Test Routine (1)


fully software controlled RS232 transmission and reception for PIC16F84

Table of Contents [Toc]

Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code

Concept [Toc] [Top]

Fully software controlled RS232 reception and transmission for PIC16F8x.


Display of received ASCII characters sent from PC via RS232 and their corresponding decimal value on the LCD. Microcontroller sends
feedback of received characters back to the terminal window. When the PIC terminal is idle, it sends a status message '@' to the PC every
2.75 seconds.
Shows the implementation and function of the modules m_wait.asm, m_rs096.asm, m_lcd.asm and m_lcdv08.asm on the PIC 16F84.

PCB test board for PIC16F84 PIC16F84 test board with MAX232
using a dot matrix LCD display and a MAX232 for RS232 Test setup using LCD display on PortB and asynchronous RS232
transmission. connection (RX on PortB0, TX on PortA0). RS232 to USB1.1
connector in the back.

http://www.trash.net/~luethi/microchip/projects/rs232/commtest1/commtest1.html (1 of 3)12/02/2008 17:16:17


Fully software controlled RS232 communication test routine for PIC16F84

LCD display after reset LCD display output during operation


shows welcome screen of this program. after sending 'A' from the PC across the RS232 line. The
character sent is echoed back to the PC by the microcontroller.

Screen shot of the HyperTerminal Program


showing the start-up message of this RS232 test routine.

Specifications [Toc] [Top]

Processor: Microchip PIC 16F84


Clock Frequency: 4 MHz crystal
Throughput: 1 MIPS

http://www.trash.net/~luethi/microchip/projects/rs232/commtest1/commtest1.html (2 of 3)12/02/2008 17:16:17


Fully software controlled RS232 communication test routine for PIC16F84

RS232 Baud Rate: 9600 baud, 8 bit, no parity, 1 stopbit


Code Size of entire Program: approx. 566 instruction words
Acquisition Methodology: Interrupt-based RS232 data acquisition, with LCD display output and RS232 echo during normal
operation
Required Hardware: MAX 232, dot matrix LCD display
Required Software: RS232 terminal software (or Excel 97 RS232 Debug Interface)

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Source Code [Toc] [Top]

Main File HEX Files

Download assembler source code: Download Hex File:


commtest1.asm commtest1.hex

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_rs096.
asm

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Download ASCII Character Map: ASCII-Map.pdf

Last updated: 16.01.2005

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/rs232/commtest1/commtest1.html (3 of 3)12/02/2008 17:16:17


Fully hardware controlled RS232 communication test routine for PIC16F77

RS232 Communication Test Routine (2)


with LCD display and MAX232 for PIC16F77 / PIC16C74A

Table of Contents [Toc]

Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code

Concept [Toc] [Top]

Fully hardware controlled RS232 reception and transmission for PIC16F7x.


Display of received ASCII characters sent from PC via RS232 and their corresponding decimal value on the LCD. Microcontroller
sends feedback of received characters back to the terminal window. When the PIC terminal is idle, it sends a status message '@' to
the PC every 2.75 seconds.
Shows the implementation and function of the modules m_wait.asm, m_lcd.asm and m_lcdv08.asm on the PIC16F77 (or
PIC16C74A).

Dot matrix LCD display


LCD display output after sending '@' from the PC
across the RS232 line. The character sent is echoed PIC16F77 test board with MAX232
by the microcontroller. Test setup using LCD display on PortB and RS232
connection (built-in HW USART of PIC16C74A in
asynchronous mode).

http://www.trash.net/~luethi/microchip/projects/rs232/commtest2/commtest2.html (1 of 3)12/02/2008 17:16:18


Fully hardware controlled RS232 communication test routine for PIC16F77

Screen shot of the HyperTerminal Program


HyperTerminal output using this RS232 test routine.
The four consecutive letters 'asfd' at the end shows the
successful RX FIFO buffering in the microcontroller.

Specifications [Toc] [Top]

Processor: Microchip PIC 16F77


Clock Frequency: 4 MHz crystal
Throughput: 1 MIPS
RS232 Configuration: 9600 with BRGH = 1
RS232 Baud Rate: 9600 baud, 8 bit, no parity, 1 stopbit
Code Size of entire Program: approx. 566 instruction words
Acquisition Methodology: Preemptive, interrupt-based RS232 data acquisition, with LCD display output and
RS232 echo during normal operation
Required Hardware: MAX 232, dot matrix LCD display
Required Software: RS232 terminal software (or Excel 97 RS232 Debug Interface)

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Source Code [Toc] [Top]

Main File HEX Files

http://www.trash.net/~luethi/microchip/projects/rs232/commtest2/commtest2.html (2 of 3)12/02/2008 17:16:18


Fully hardware controlled RS232 communication test routine for PIC16F77

Download assembler source code: Download Hex File:


commtest2.asm commtest2.hex

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.asm

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Download ASCII Character Map: ASCII-Map.pdf

Last updated: 16.01.2005

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/rs232/commtest2/commtest2.html (3 of 3)12/02/2008 17:16:18


Dual RS232 communication routine for PIC16F77

Dual RS232 Communication Routine


with LCD display and two MAX232 for PIC16F77

Table of Contents [Toc]

Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code

Concept [Toc] [Top]

Two independent RS232 interfaces, with display of received ASCII characters and corresponding decimal values on the dot matrix LCD.
ASCII values entered on one terminal window are transmitted by the first RS232 link to the controller, displayed on the LCD, and further
transmitted across the second RS232 link to the other terminal window. The microcontroller sends feedback of received characters back to
the issueing terminal window. When the PIC terminal is idle, it sends a status message '@' to both terminals every 2.75 seconds.

This program incorporates two independent RS232 interfaces, one hardware-based and one software-based. The HW-based RS232
interface uses the PIC-internal USART (and interrupts), configured to standard 9600 baud @ 4 MHz PIC clock. The SW-based RS232
interface is based on the module file m_rs096.asm, which performs interrupt-based RS232 reception on PortB0 (INTCON,INTF) at 9600
baud @ 4 MHz PIC clock.

The program shows the implementation and function of the modules m_bank.asm, m_wait.asm, m_lcd.asm, m_lcdv08.asm, and m_rs096.
asm on the PIC16F77.

Dot matrix LCD display


showing output after having received 'a' from the first RS232
terminal and 'b' from the second RS232 terminal. Every
character received is displayed in both ASCII and decimal
value, and then transmitted to the other RS232 terminal across
the second communication link. PIC16F77 test board with two MAX232
Test setup using onboard MAX232 and additional external
MAX232 to serve both RS232 links. The PIC controller now serves
two asynchronous RS232 connections, one in software mode using
interrupts and one using the hardware USART of the PIC16F77.

http://www.trash.net/~luethi/microchip/projects/rs232/dual_rs232/dual_rs232.html (1 of 3)12/02/2008 17:16:19


Dual RS232 communication routine for PIC16F77

Screen shot of the two HyperTerminal Programs


using the dual RS232 communication routine. The left window configured to ComPort 5 represents the first link, the right window
configured to ComPort 7 represents the second link. After power-up and welcome message, the message 'Hello World' was entered at the
left terminal window, then the message 'I say also hello' was transmitted using the right terminal window.

Specifications [Toc] [Top]

Processor: Microchip PIC 16F77


Clock Frequency: 4 MHz crystal
Throughput: 1 MIPS
RS232 Configuration: 9600 with BRGH = 1
RS232 Baud Rate: 9600 baud, 8 bit, no parity, 1 stopbit
Code Size of entire Program: approx. 733 instruction words
Acquisition Methodology: SW-based RS232: Interrupt-based RS232 data acquisition
HW-based RS232: Preemptive, interrupt-based RS232 data acquisition,
LCD display output and RS232 echo during normal operation
Required Hardware: two MAX 232 for two RS232 interfaces, dot matrix LCD display
Required Software: RS232 terminal software (or Excel 97 RS232 Debug Interface)

Project Resources [Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/rs232/dual_rs232/dual_rs232.html (2 of 3)12/02/2008 17:16:19


Dual RS232 communication routine for PIC16F77

Available Microchip PIC Assembler Source Code [Toc] [Top]

Main File HEX Files

Download assembler source code: Download Hex File:


16F77dual.asm 16F77dual.hex

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.asm

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Download ASCII Character Map: ASCII-Map.pdf

Last updated: 16.01.2005

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/rs232/dual_rs232/dual_rs232.html (3 of 3)12/02/2008 17:16:19


RS232 Scope V1.02 Test Interface

RS232 Scope V1.02 Test Interface


with 16 bit Table Read, for Excel 97

Table of Contents [Toc]

Concept
Project Resources
Available Microchip PIC Assembler Source Code

Concept [Toc] [Top]

This routine has been written to check the Excel Worksheet RS232scopeV102.xls.
It reads 16 bit values from a table, proceeds framing and sends the data to the PC.
The table was built with the "Automatic Table Generator for MPLAB Assembler"

Project Resources [Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/rs232/scope/scope.html (1 of 2)12/02/2008 17:16:20


RS232 Scope V1.02 Test Interface

Available Microchip PIC Assembler Source Code [Toc] [Top]

Main File HEX Files

Download assembler source code: Download Hex File:


scope.asm scope.hex

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.asm

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Last updated: 23.01.2005

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/rs232/scope/scope.html (2 of 2)12/02/2008 17:16:20


Dot matrix LCD test routine for Microchip PIC16F84

LCD Test Routine


with user-defined characters and LCD display animation for PIC16F84

Table of Contents [Toc]

Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code
Schematics

Concept [Toc] [Top]

This test application demonstrates the usage of the LCD assembler module files for dot matrix LCDs. It works for LCD controllers such
as Hitachi HD44780 (PDF data sheet, 389 kB), Samsung KS0073 (PDF data sheet, 673 kB), and compatibles.

It initializes the LCD display to the 4 bit transfer mode, loads two user-defined characters to the CGRAM,
and displays both of them together with some other special characters. Afterwards, an animation using
stars is shown, followed by a forth-and-back shift animation of a 'Hello World' string.

Shows the implementation and functionality of the modules m_wait.asm and m_lcd.asm on the PIC16F84. For the Samsung KS0073
controller type, the constant 'LCDTYPE' must be set to 0x1 to include also the extended function set features for configuration. If this
does not help, see also the FAQ section concerning LCD communication issues.

To see a schematic of the connection between LCD and PIC microcontroller, please refer to the schematic section below. Basically, the
connection is described in the header section of each LCD assembler module file.

LCD display after reset


shows two user-defined characters and other special characters of
the LCD

PCB test board for PIC16F84


using a dot matrix LCD display and a MAX232 for RS232
transmission

http://www.trash.net/~luethi/microchip/projects/LCDx_test/LCDx_test.html (1 of 3)12/02/2008 17:16:21


Dot matrix LCD test routine for Microchip PIC16F84

LCD display output during operation LCD display output during operation
shows animation with stars shows forth-and-back shifting 'Hello World'

Specifications [Toc] [Top]

Processor: Microchip PIC 16F84


Clock Frequency: 4 MHz crystal (HS mode)
Throughput: 1 MIPS
Code Size of entire Program: approx. 557 instruction words
LCD Transmission Mode: 4 Bit on D4 - D7 (MSB), uses high nibble of the LCD port
LCD Connections: 7 wires (4 Data, 3 Command)
Total LCD Connections: 10 wires (4 Data, 3 Command, 1 Vdd, 1 GND, 1 Contrast)
Required Hardware: HD44780 compatible dot matrix LCD (2x16, 2x20 or 2x40 characters)

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Source Code [Toc] [Top]

Main File HEX Files

Download assembler source code: Download Hex File:


LCDx_test.asm LCDx_test.hex

Specifications:
- used module m_lcdx.asm for building HEX-file with portB as LCD port
LCD port connections:
B0: not used, still available for INTB
B1: D4
B2: D5
B3: D6
B4: D7
B5: E
B6: R/W
B7: RS

http://www.trash.net/~luethi/microchip/projects/LCDx_test/LCDx_test.html (2 of 3)12/02/2008 17:16:21


Dot matrix LCD test routine for Microchip PIC16F84

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.asm

Schematics [Toc] [Top]

Download the PDF schematic to illustrate the connectivity of both 'classes' of LCD driver routines:

Modules m_lcd.asm, m_lcdx.asm, m_lcd_bf.asm, m_lcdxbf.asm: working only on entire ports ([1..7], without [0]),
e.g. PortB[1..7] on PIC16F84,
or PortB[1..7], PortC[1..7], PortD[1..7] on PIC16F77
Modules m_lcde.asm, m_lcde_bf.asm, m_lcdexbf.asm: working on separate, customizable ports,
e.g. PortB[0..2] for control lines & PortA[0..3] for data lines on PIC16F84, PIC16F7x,
or PortC[5..7] for control lines & PortD[0..3] for data lines on PIC16F77, or ...
Note that the data lines have to be on the low nibble of the port.

Last updated: 06.06.2005

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/LCDx_test/LCDx_test.html (3 of 3)12/02/2008 17:16:21


Binary to Decimal Test Routine for PIC16F84

Binary to Decimal Test Routine


shows the output of 16 bit binary to decimal conversion on a dot matrix LCD

Table of Contents [Toc]

Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code

Concept [Toc] [Top]

This test application demonstrates the usage of the LCD assembler module files m_lcdv16.asm and m_lcdb16.asm on a PIC 16F84. These
module files are suitable for displaying decimal and binary information on a dot matrix LCD. Together with the module file m_lcd.asm,
they work with LCD controllers such as Hitachi HD44780 (PDF data sheet, 389 kB), Samsung KS0073 (PDF data sheet, 673 kB), and
compatibles.

The program initializes the LCD display to 4 bit transfer mode, clears two 8 bit registers (LO, HI) for the 16 bit counter, and displays
every counter step as decimal and binary value on the LCD display.

Shows the implementation and functionality of the modules m_wait.asm, m_lcd.asm, m_lcdv16.asm and m_lcdb16.asm on the PIC16F84.
For the Samsung KS0073 controller type, the constant 'LCDTYPE' must be set to 0x1 to include also the extended function set features for
configuration. If this does not help, see also the FAQ section concerning LCD communication issues.

LCD display PCB test board for PIC16C84/PIC16F84


shows the use of the binary to decimal conversion module with attached dot matrix LCD display on PortB
(m_lcdv16asm) and the bitstream visualization module (m_lcdb16.
asm)

Specifications [Toc] [Top]

Processor: Microchip PIC 16F84


Clock Frequency: 4 MHz crystal (XT mode)

http://www.trash.net/~luethi/microchip/projects/counter/counter.html (1 of 2)12/02/2008 17:16:22


Binary to Decimal Test Routine for PIC16F84

Throughput: 1 MIPS
Code Size of entire Program: approx. 203 instruction words
LCD Transmission Mode: 4 Bit on D4 - D7 (MSB), uses high nibble of the LCD port
LCD Connections: 7 wires (4 Data, 3 Command)
Total LCD Connections: 10 wires (4 Data, 3 Command, 1 Vdd, 1 GND, 1 Contrast)
Required Hardware: HD44780 compatible dot matrix LCD (2x16, 2x20 or 2x40 characters)

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Source Code [Toc] [Top]

Main File HEX Files

Download assembler source code: Download Hex File:


counter.asm counter.hex

Specifications:
- used module m_lcd.asm for building HEX-file with portB as LCD port
LCD port connections:
B0: not used, still available for INTB
B1: D4
B2: D5
B3: D6
B4: D7
B5: E
B6: R/W
B7: RS

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.
asm, m_lcdb16.asm

Last updated: 05.01.2005

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/counter/counter.html (2 of 2)12/02/2008 17:16:22


Debugging Routine / Bitstream Visualization for PIC16F84

Debugging Routine / Bitstream Visualization


shows 16 bit binary output on a dot matrix LCD

Table of Contents [Toc]

Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code

Concept [Toc] [Top]

This test application demonstrates the usage of the LCD assembler module file m_lcdb16.asm on a PIC 16F84. This module file is
suitable for displaying binary information on a dot matrix LCD. Together with the module file m_lcd.asm, it works with LCD controllers
such as Hitachi HD44780 (PDF data sheet, 389 kB), Samsung KS0073 (PDF data sheet, 673 kB), and compatibles.

The program initializes the LCD display to 4 bit transfer mode, clears two 8 bit registers (LO, HI) for the 16 bit counter, and displays
every counter step as binary value on the LCD display.

Shows the implementation and functionality of the modules m_wait.asm, m_lcd.asm, and m_lcdb16.asm on the PIC16F84. For the
Samsung KS0073 controller type, the constant 'LCDTYPE' must be set to 0x1 to include also the extended function set features for
configuration. If this does not help, see also the FAQ section concerning LCD communication issues.

LCD display PCB test board for PIC16C84/PIC16F84


shows the use of the bitstream visualization module m_lcdb16.asm with attached dot matrix LCD display on PortB

Specifications [Toc] [Top]

Processor: Microchip PIC 16F84


Clock Frequency: 4 MHz crystal (XT mode)
Throughput: 1 MIPS
Code Size of entire Program: approx. 146 instruction words

http://www.trash.net/~luethi/microchip/projects/debug/debug.html (1 of 2)12/02/2008 17:16:23


Debugging Routine / Bitstream Visualization for PIC16F84

LCD Transmission Mode: 4 Bit on D4 - D7 (MSB), uses high nibble of the LCD port
LCD Connections: 7 wires (4 Data, 3 Command)
Total LCD Connections: 10 wires (4 Data, 3 Command, 1 Vdd, 1 GND, 1 Contrast)
Required Hardware: HD44780 compatible dot matrix LCD (2x16, 2x20 or 2x40 characters)

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Source Code [Toc] [Top]

Main File HEX Files

Download assembler source code: Download Hex File:


debug.asm debug.hex

Specifications:
- used module m_lcd.asm for building HEX-file with portB as LCD port
LCD port connections:
B0: not used, still available for INTB
B1: D4
B2: D5
B3: D6
B4: D7
B5: E
B6: R/W
B7: RS

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.
asm, m_lcdb16.asm

Last updated: 05.01.2005

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/debug/debug.html (2 of 2)12/02/2008 17:16:23


AT Keyboard Scan Code Debug Routine for Microchip PIC16F84 Microcontroller

AT Keyboard Scan Code Debug Routine


RS232 based Scan Code Debugging for Microchip PIC16F84

Table of Contents [Toc]

Concept
Project Resources
Available Microchip PIC Assembler Source Code

Concept [Toc] [Top]

The Scan Code Debug Routine provides the ability to verify the scan patterns sent by the keyboard. The visualization can be done
with the RS232 Debug Interface, an Excel 97 Worksheet.
A screen shot from a debugging session is given below:

http://www.trash.net/~luethi/microchip/projects/keyboard/scan_deb/scan_deb.html (1 of 2)12/02/2008 17:16:24


AT Keyboard Scan Code Debug Routine for Microchip PIC16F84 Microcontroller

At the picture above, you can see the strange scan pattern sent by the
AT keyboard when pushing the Pause/Break key:
E1 14 77 E1 FO 14 FO 77

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Source Code [Top]

Main File HEX Files

Download assembler source code: Download Hex File:


scan_deb.asm scan_deb.hex

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_rs192.
asm

For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232: RS232-Interface.pdf (9.7 kB)

Download ASCII Character Map: ASCII-Map.pdf

Last updated: 18.04.2004

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/keyboard/scan_deb/scan_deb.html (2 of 2)12/02/2008 17:16:24


AT Keyboard Box V0.04 - Debug and Calibration for Microchip PIC 16C74A Microcontroller

Numeric Foil-Keypad Calibration V0.04


with LCD Display for Microchip PIC16F77

Table of Contents [Toc]

Concept
How the numeric foil-keypad works
Specifications
Parts order information
Project Resources
Available Microchip PIC Assembler Source Code
Schematics, Data Sheets, Pinout

Concept [Toc] [Top]

This application has entirely the same setup as the AT Keyboard Box V2.05.

This program refers to the calibration of the numeric foil-keypad of the AT Keyboard Box. The analog foil-keypad decoding approach deserves dedicated design
and calibration: If a key on the foil-keypad is hit, an interrupt is generated to start the A/D conversion. The analog value built by the keypad resistor cascade needs
some settling time until stable and reproduceable A/D values can be read out by the PIC microprocessor (overshoots, undershoots). For a detailed description,
please refer to the section 'How the numeric foil-keypad works' and the schematics below.

AT Keyboard Box V0.04 - Debug and Calibration


Debug and calibration for numeric foil-keypad on PIC16F77. Dedicated
output on the second line: Acquired A/D value from numeric foil-keypad and
corresponding symbol from look-up table (# has been hit).
http://www.trash.net/~luethi/microchip/projects/keyboard/box_dbg/box_dbg.html (1 of 7)12/02/2008 17:16:25
AT Keyboard Box V0.04 - Debug and Calibration for Microchip PIC 16C74A Microcontroller

Numeric foil-keypad
Connection topology: 1x12

Interrupt generator
for numeric foil-keypad: Whenever a key is hit, a key-
specific analog voltage is put on the first line to the A/
AT Keyboard Box V0.04 setup D converter. At the same time an interrupt is
with numeric foil-keypad, dot matrix LCD display and generated by this comparator circuit and put on the
AT keyboard second IRQ line.

http://www.trash.net/~luethi/microchip/projects/keyboard/box_dbg/box_dbg.html (2 of 7)12/02/2008 17:16:25


AT Keyboard Box V0.04 - Debug and Calibration for Microchip PIC 16C74A Microcontroller

AT Keyboard Box V0.01 Front view


(initial version with PIC16C74A) Microchip PIC16C74A microcontroller and piezo-
beeper on the left side.

Screen shot of the HyperTerminal Program


showing the start-up message of the AT Keyboard Box V0.04
and some keyboard and keypad entries

How the numeric foil-keypad works [Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/keyboard/box_dbg/box_dbg.html (3 of 7)12/02/2008 17:16:25


AT Keyboard Box V0.04 - Debug and Calibration for Microchip PIC 16C74A Microcontroller

Here is the description of the additional small numeric foil-keypad. The numeric foil-keypad is equipped with a specific resistor cascade to decode the values
through direct 8 bit A/D conversion using the PIC-internal A/D converter. The advantage is a very low pin usage: Only two pins are necessary for proper detection
and decoding of all keypad entries. One pin provides the analog value, the other pin serves for interrupt generation whenever a key of the keypad is touched. The
interrupt is used to start the A/D conversion.

During the interrupt service routine, only a short busy wait (analog settling time) and the A/D conversion - using the internal RC oscillator - is carried out. Before
leaving the ISR, the 8 bit A/D result is stored in a specific register and a dedicated flag is set.

Decoding of the A/D value is done during normal operation (activated by the flag) using two look-up tables. The first look-up table (LUT1) contains the expected
8 bit values of the keypad to check for valid entries. A numeric window of 3 allows for slight analog deviations during matching. The matching algorithm just
scans the entire LUT1 until the received keypad A/D result matches a LUT1 entry. The amount of loops carried out in LUT1 determines the position of the
corresponding symbol/character in LUT2. At the end, RS232 transmission and LCD display update are carried out.

Dynamic configuration of RS232 baud rate setting at start-up (user-customization with 1200 baud - 115200 baud). A watchdog timer implemented using TMR1
checks for inactivity during the customization process. After 12 seconds of inactivity, the user-customization process terminates with the current setting. At power-
up, the default setting is 9600 baud, which will be configured after the time-out - unless no user-customization takes place.

This setup works also without attached foil keypad, even if the corresponding code is assembled and loaded into the microcontroller.

Note that every change in microprocessor clock frequency needs a re-calibration and/or re-design of the analog foil-keypad decoding circuitry. This means that
the PIC microprocessor clock frequency (related to the A/D conversion speed), output drive strength of the keypad resistor cascade and both debounce capacitors
on IRQ line and analog value pin affect the proper function of the keypad circuit. Whenever the PIC clock frequency is changed, (slight) adaptations on the analog
circuitry may have to be expected.

Specifications [Toc] [Top]

Processor: PIC16F77 (PIC16C74A)


Clock Frequency: 14.745600 MHz (HS mode)
Throughput: 3.7 MIPS
RS232 Baud Rate: Customizable by user (BRGH = 0),
any setting from 1200 baud - 115200 baud
Serial Output: default setup: 9600 baud, 8 bit, no parity, 1 stopbit
Keyboard Routine Features: Capability of bi-directional communication between controller and
keyboard
Numeric Keypad Features: Interrupt-based acquisition, direct 8 bit A/D conversion
Acquisition Methodology: Preemptive, interrupt-based keyboard scan pattern acquisition,
decoding to ASCII characters during normal operation mode
activated by ready flag (including LCD display and RS232
activities)
http://www.trash.net/~luethi/microchip/projects/keyboard/box_dbg/box_dbg.html (4 of 7)12/02/2008 17:16:25
AT Keyboard Box V0.04 - Debug and Calibration for Microchip PIC 16C74A Microcontroller

Code Size of entire Program: 1231 instruction words


Required Hardware: AT keyboard, PS/2 connector, MAX232 level shifter, dedicated
foil-keypad, LM393 comparator circuity for interrupt generation,
HD44780 compatible dot matrix LCD (2x16, 2x20 or 2x40
characters)
Optional Hardware: Piezo beeper with decoupling capacitor
Required Software: RS232 terminal software (or Excel 97 RS232 Debug Interface)

Parts order information [Toc] [Top]

Numeric foil-keypad order information and technical specifications:


www.conrad.de: FOLIENTASTATUR 1x12, Part-Nr. 709948-14

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Source Code [Toc] [Top]

Main File Main Keyboard Decode Lookup Table SHIFT Keyboard Decode Lookup Table HEX Files

Debug and calibration English 'codepage' (QWERTY) English 'codepage' (QWERTY) QWERTY 'codepage':
version for numeric foil- View: eng_main.html View: eng_shif.html box_dbg_eng.hex
keypad V0.04: Download: eng_main.asm Download: eng_shif.asm
box_dbg.asm QWERTZ 'codepage':
box_dbg_sg.hex

http://www.trash.net/~luethi/microchip/projects/keyboard/box_dbg/box_dbg.html (5 of 7)12/02/2008 17:16:25


AT Keyboard Box V0.04 - Debug and Calibration for Microchip PIC 16C74A Microcontroller

Modified Swiss German Modified Swiss German


'codepage' (QWERTZ) 'codepage' (QWERTZ)
View: ger_main.html View: ger_shif.html
Download: ger_main.asm Download: ger_shif.asm

The above programs need additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd_bf.asm
Important: Due to bi-directional communication between controller and keyboard as well as between controller and LCD display, the above programs only
work if both components are connected and are working properly!

Schematics, Data Sheets and Pinout [Toc] [Top]

AT Keyboard Specification (PDF, 189 kB)

The schematics of the AT Keyboard Box using the PIC16F77:

Top view: kbd_box_top.pdf (with outdated 4 MHz crystal, now 14.7456 MHz)
LCD connection: kbd_box_lcd.pdf
Numeric foil-keypad: kbd_box_keypad.pdf
RS232 circuitry: kbd_box_max232.pdf
Power supply: kbd_box_power.pdf
Simulation of interrupt generation circuit (positive IRQ pulses): kbd_box_sdf.pdf

You don't know how a dot matrix LCD is working? Have a look at my data sheets page.

Download ASCII Character Map: ASCII-Map.pdf

You can get the description of the various keyboard connectors <here>.

Last updated: 06.06.2005

[Toc] [Top]

If you see only this page in your browser window,


click here
http://www.trash.net/~luethi/microchip/projects/keyboard/box_dbg/box_dbg.html (6 of 7)12/02/2008 17:16:25
AT Keyboard Box V0.04 - Debug and Calibration for Microchip PIC 16C74A Microcontroller

to get the entire site.

http://www.trash.net/~luethi/microchip/projects/keyboard/box_dbg/box_dbg.html (7 of 7)12/02/2008 17:16:25


NSC ADC12130 Test Interface

NSC ADC12130 Test Interface


with dot matrix LCD Display

Table of Contents [Toc]

Overview
Specifications
Project Resources
Available Microchip PIC Assembler Source Code

Overview [Toc] [Top]

The output data format can be chosen from 8 different configurations.


I finally arrived to get some status data out of the converter, I had so much trouble, because the data sheet is not very convenient to
read and so I made a mistake. The bad representation of the data sheet is confusing: They describe all different types of the 1213x
series together in one data sheet, you have to be careful to get the right commands for the 12130 type.
To get rid of crosstalk, separate every data wire from each other with an extra ground wire between them (ADC to PIC interface).
At the beginning I got really confusing results because of crosstalk due to the high frequency parts of the very short clock pulses.
I use now flat band wire, each data (and clock) connection is isolated with a ground connection.
The data from the AD converter is now pretty clean and consistent.

Specifications [Toc] [Top]

National Semiconductors ADC12130 A/D Converter


Resolution: 12 bit + sign
Max. conversion clock frequency: 5 MHz
Max. serial clock frequency: 5 MHz
Min. conversion time: 8.8 us
Min. throughput time: 14 us
Integral linearity error: 2 LSB max
Single supply: 3.3 - 5.0 V 10 %

Hint

Do not try to connect the NSC ADC12130 to the PIC SSP interface of some more sophisticated PICs, eg. PIC 16C74. I've spent a
complete weekend trying to do that until I finally found out that the PIC SSP is not compatible with the one of the NSC ADC12130.
The clock and the data specifications of the PIC does not match with the ones of the ADC, there's an incompatible "skew" between
them.

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Source Code [Toc] [Top]

http://www.trash.net/~luethi/microchip/projects/adc_test/nsc12130.html (1 of 2)12/02/2008 17:16:25


NSC ADC12130 Test Interface

Main File HEX Files

Download assembler source code: Download Hex File:


nsc12130.asm nsc12130.hex

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.asm

Schematic of the interface: NSC_ADC12130.pdf (12.8 KB)

Last updated: 27.04.2004

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/adc_test/nsc12130.html (2 of 2)12/02/2008 17:16:25


DCF77 Test Interface

DCF77 Test Interface


with Excel 97 Work Sheet for Visualization

Table of Contents [Toc]

Concept
Components
Test Setup
Software
Project Resources
Available Microchip PIC Assembler Source Code

Concept [Toc] [Top]

Precise time is always a nice feature. In Europe, we have a public RF transmitter located in Mainflingen, Germany, providing
standardized time information at 77.5 kHz. A cheap DCF77 receiver unit translates the RF data into PWM. A PIC 16F84
microcontroller performs software-based PWM decoding and transmits the data through RS232 to a PC with dedicated Excel 97
work sheet. The Excel 97 work sheet is able to acquire and log RS232 data, and also visualizes and translates complete DCF77
frames. A complete DCF77 evaluation setup is created.

See also the short technical introduction to DCF77.

Components [Toc] [Top]

The receiver has been ordered by Conrad Electronics, 92240 Hirschau, Germany (www.conrad.de)

Component:
Ordering number: #641138
Description: DCF77-Empfnger BN 641138
Price: Euro 9.95, December 2002

based on Temic 4224 DCF77 IC


Data sheet (167 kB)

This unit performs the translation from 77.5 kHz RF to DCF77 PWM data. The information is encoded as follows: Pulse of 0.1s = 0,
0.2s = 1, numbers are encoded in BCD (binary coded decimal)
For detailed information, please refer to this document or the data sheet section.

http://www.trash.net/~luethi/microchip/projects/dcf77_test/dcf77_test.html (1 of 4)12/02/2008 17:16:27


DCF77 Test Interface

Schematic:
Outputs need pull-up resistors (open collector) which have to draw
less than 1 mA.

1 - GND
2 - VDD, 1.5 V up to 15 V
3 - DCF77 PWM output, default active low, high pulses
4 - DCF77 PWM output, default active high, low pulses

For best reception, the Ferrit-antenna should be positioned rectangular to the direction of Mainflingen, Germany, the location of the
DCF77 transmitter.

Test Setup [Toc] [Top]

This picture shows the test setup with DCF77 receiver unit at the lower right corner. The LCD display serves only for debugging
purposes and is not used within this project. This setup consists of DCF77 PWM bit stream decoder, PIC 16F84 microcontroller,
and MAX232 level shifter for serial transmission.

http://www.trash.net/~luethi/microchip/projects/dcf77_test/dcf77_test.html (2 of 4)12/02/2008 17:16:27


DCF77 Test Interface

A second view on my standard PIC 16F84 test board. On this setup, I only use serial transmission, no reception. At the upper left
corner of the picture, you can see the RS232 to USB1.1 converter, which I bought because my Laptop has only a single serial port. It
works astonishingly well and entirely transparent to all my software. That's what I like - and expect from quality HW-SW co-design.

Software [Toc] [Top]

Screen shot of Excel 97 based DCF77 Visualizer

This is the graphical user interface of my Excel 97 work sheet designed to visualize and translate received serial DCF77 data from

http://www.trash.net/~luethi/microchip/projects/dcf77_test/dcf77_test.html (3 of 4)12/02/2008 17:16:27


DCF77 Test Interface

the PIC microcontroller. You can see two valid DCF77 data frames, each of them containing 59 bits of information. Every frame is
enclosed with marks of value 2. Reception and decoding is done using Visual Basic macros. I used serial port 2, provided by the
USB1.1 serial converter, configured to 19200 baud, 8 data bits, no parity, 1 stop bit. The entire chart is setup to display 150 samples.
This is normally carried out within 150 seconds, assuming a clean DCF77 data reception containing a single PWM pulse every
second.
The bit streams of the two consecutive valid frames are displayed within the two large text boxes below the chart. The Visual Basic
code carries out a simple frame consistency check (59 data bits, no marks inside) automatically every complete frame and displays
the translation of the last valid frame in the three smaller text boxes at right. To keep it simple, there is neither DCF77 parity bit
checking nor any error handling implemented in the software.

Project Resources [Toc] [Top]

Available Microchip PIC Assembler Source Code [Toc] [Top]

Main File HEX Files

Download assembler source code: Download Hex File:


dcf_test.asm dcf_test.hex

The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.asm

Technical introduction to DCF77

Download Excel 97 work sheet (DCF77 data visualization and translation): DCF77_Visualizer.zip (155 kB)

Last updated: 27.04.2004

[Toc] [Top]

If you see only this page in your browser window,


click here
to get the entire site.

http://www.trash.net/~luethi/microchip/projects/dcf77_test/dcf77_test.html (4 of 4)12/02/2008 17:16:27


jacOS

V1.06.0

jacOS

jacOS . ,
. jacOS event-driven priority-based RTOS. 1.06.0
, , , . .
.

.
: .
. ,
. -, , , .
, . , ,
. , , . ,
- , ,
.
, ?
. , , .
, . ROM, RAM.
, , , .
. , .
.
"" ( ), , .
"" , " ", , .
, :
.
, , . , , , "".
RTOS? , . , .
. RTOS .
. RTOS . ,
RTOS RTOS, , . , RTOS ,
? , , , .

.
jacOS 1.06.0 12- , 14- 16- PIC, AVR , MSP430 51.
. , 41- , , , .
18- . , "" .
, , , .
.

http://technogate.tripod.com/ (1 of 36)12/02/2008 17:19:07


jacOS

PIC 12 SMALL
H-T
256 ROM. .

PIC 14 COMPACT + TCB + 4 8


H-T ECB bank0 (TCB).
bank1
(ECB)
2-4 .

2
3 .
PIC18 COMPACT 1. , TCB TCB 4 8- .
H-T ECB near, ECB - 3 4-.
,
128 RAM. (96
) ~=24
2.
64Kb(32)
PIC18 NORMAL 1. , TCB
Code model = Static overlay.
IAR ECB TCB 5 9- .
__bank1 (256 ). ECB - 4 5-.
AVR GCC NORMAL TCB 5 9- .
WINAVR ECB - 4 6-.
AVR COMPACT 1.
IAR __tiny. ~=30.

2. Cross Call tiny small
v0,v1,v3.
TCB 4 8- .
ECB - 2 5-.
1. Cross Call
NORMAL small
v3.
TCB - 5 12- .
ECB - 3 6-.
MSP430 NORMAL TCB 6 12- .
IAR ECB - 4 6-.
x51 NORMAL 1. 64Kb TCB 4 8- .
Keil ECB - 3 5-.

.

PIC12 , PIC16 HI-TECH PICC v8.05 Produce assembler list file
PIC18 HI-TECH PICC-18 v8.35

PIC18 IAR C/EC++ Compiler for , XLINK


Microchip PIC18 2.12A/W32 (Diagnostics -> No global type checking).
AVR WinAVR 20040404

http://technogate.tripod.com/ (2 of 36)12/02/2008 17:19:07


jacOS

AVR IAR C/EC++ Compiler for AVR Code motion (?)


3.20C/W32 Cross Call (?) .
MSP430 IAR C/EC++ Compiler for MSP430 : Size - High.
V3.20A/W32
x51 Keil Cx51 v7.04 , BL51 Misc
Warning L15 (Disable Warning Number: = 15)

jacOS . "" PIC18 (,


HT-PICC18). V1.06.0 .
, .
. , PIC16 PIC12
"" HI-TECH PICC.

.
, path info .
.

.
.
. , .
, , "" ADC, , -
. , "", RTOS. ""
. "" , . ,
( ), , . .
, . , " " ,
.

jacOS . ,
. , ,
... . , .

OST_TASK task_1; //1

__task void Task1( void )


{
static int counter; //2
for(;;) { //3
counter++; //4
OS_Cooperate(); //5
counter++; //6
}
}

IAR __task.
, , . (TCB).
//1 task_1 OST_TASK, TCB. jacOS
TCB. OST_TASK, - OST_TASK_T, .
TCB bank1. , . jacOS bank2
bank3. , , .

http://technogate.tripod.com/ (3 of 36)12/02/2008 17:19:07


jacOS

, .

bank1 OST_TASK task_1; // bank1

OS_Cooperate() //5 .
. . , , OS_Cooperate() jacOS
.
, //2. static ,
. , static,
. PIC,
.
, . OS_Cooperate() ,
. , ? jacOS
, , .


, . . ,
your_func() , .
, . , .
your_func().
, , ,
. , .

C:, c:\jacos\prim
jacOS. PIC IDE - MPLAB 5.7x MPLAB 6.. .
, .
. , ,
, .
counter++ . , counter
. , IDE , counter++ .

/********************************************/

__task void TaskABC(void)


{
char loc_var,
static char sta_var;
for(;;) {
loc_var = PORTA;
. . .
sta_var = 45;
OS_Cooperate(); //1
loc_var = PORTB; //2
. . .
OS_Cooperate();
}
}

OS_Cooperate() , . //1
, //2. , //2 loc_var , sta_var,

http://technogate.tripod.com/ (4 of 36)12/02/2008 17:19:07


jacOS

, 45-.

- , .

/***** c:\jacos\prim\prim1*****************/
#define OS_MAIN
#include <jacos.h>

OST_TASK task1;
OST_TASK task2;
unsigned char counter;

__task void T1( void )


{
while(1) {
counter++; //3 //8
OS_Cooperate(); //4 //9
counter++; //7 //13
}
}

__task void T2( void )


{
while(1) {
counter++; //5 //11
OS_Cooperate(); //6 //12
counter++; //10 //
}
}

void main(void)
{
OS_Init();
OS_Task_Create(T1,&task1); //1
OS_Task_Create(T2,&task2);
while(1) {
OS_Scheduler(); //2
}
}
/**** 1*******************************/

#define OS_MAIN
, main() , OS_MAIN.

#include <jacos.h>
.
.

OS_Init();
. .

OS_Task_Create(
OST_ADDRESS __,
OST_TASK_P __TCB,
OST_U8 );

http://technogate.tripod.com/ (5 of 36)12/02/2008 17:19:08


jacOS

. prim1 , OS_Task_Create() . - ,
- TCB.
, prim1 . , .
. ,
, , .

OS_Scheduler();
OS_Scheduler() .
. , OS_Scheduler() , .
. , OS_Scheduler() - ,
. , . , WDT, .

c:\jacos\prim\prim1.
, jacOS ? , .
"jacnfg.h". prim1 :

#define OS_Lib_Type OS_ntn


/**** jacnfg.h ****************************/

PIC12F675 :

main.c -
40Antln.lib -

:
1) jacnfg.h.
2) head ( \jacos\incl ).

prim1 MPLAB 6.2x :


Project->Build Options->Project->General->Include Path = \jacos\prim\prim1;\jacos\incl

, . PICC , Produce assembler


list file ON. , PIC12 PIC16 . , "",
.

.
. .
. ? , ,
100 150? OS_Delay().

/***** c:\jacos\prim\prim2******