LCD RS232 Interface
LCD RS232 Interface
Concept
Project Resources
Available Microchip PIC Assembler Source Code
Schematic, Data Sheets, Pinout
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.
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)
You can get the pinout and a description of the various keyboard connectors <here>.
[Toc] [Top]
;***************************************************************************
;
; 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
; 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.
;
;***************************************************************************
PROCESSOR 16F84A
#include "p16f84a.inc"
#include "..\..\m_bank.asm"
#include "..\..\m_wait.asm"
#include "..\..\m_rs096.asm" ; specify desired RS232 module
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
ISR ;************************
;*** ISR CONTEXT SAVE ***
;************************
;**************************
;*** ISR MAIN EXECUTION ***
;**************************
; 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
;*****************************************
;*** ISR TERMINATION (CONTEXT RESTORE) ***
;*****************************************
MAIN
clrf INTCON ; reset interrupts (disable all)
RS232init ; RS232 initialization
clrf FLAGreg ; initialize all flags
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
END
: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
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.
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
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.
#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd.asm"
Assembler include files: General macros to ease assembler handling, e.g. macros BANK0, BANK1
V2.00 (17.08.2004)
Bank & page handling: Bank0, Bank1,...
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'
#include "..\m_bank.asm"
#include "..\m_wait.asm"
V1.00 (16.02.2003)
Beep function on parameterizable output port.
m_beep.asm CONSTANT BASE = 0x0C ; 16F84 base address of user file registers
#include "..\m_bank.asm"
#include "..\m_beep.asm"
Assembler include files: Display drivers for dot matrix LCD displays. (Hitachi HD44780 compatibles)
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.
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.
#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.
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
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.)
m_lcd_bf.asm
#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.
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).
m_lcde.asm
#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)
#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.
V1.02 (20.08.2004)
8 bit binary to decimal conversion routine for LCD output, stringent for any numeric display output or
interaction.
#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd.asm"
#include "..\m_lcdv08.asm"
V1.02 (20.08.2004)
16 bit binary to decimal conversion routine for LCD output, stringent for any numeric display output or
interaction.
#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd.asm"
#include "..\m_lcdv16.asm"
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.
m_lcdb08.asm
#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd.asm"
#include "..\m_lcdb08.asm"
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.
#include "..\m_bank.asm"
#include "..\m_wait.asm"
#include "..\m_lcd.asm"
#include "..\m_lcdb16.asm"
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)
#include "..\m_bank.asm"
#include "..\m_rs024.asm"
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)
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.)
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).
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:
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.
[Toc] [Top]
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
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)
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
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)
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.
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.
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.
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.
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
Parallel (PC)
Back to Contents
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
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)
PC Gameport / MIDI
Back to Contents
VGA
Back to Contents
SCART
Back to Contents
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
[ 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 ]
;***************************************************************************
;
; 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
endm
;***************************************************************************
;
; 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):
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
;***************************************************************************
;
; 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
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF BEEPport
ERROR "Define BEEPport in MAIN PROGRAM"
ENDIF
IFNDEF BEEPtris
ERROR "Define BEEPtris in MAIN PROGRAM"
ENDIF
IFNDEF PRESCbeep
#define PRESCbeep b'00000111' ; 65,3 ms per Cycle
ENDIF
BEEPinit macro
bcf BEEPport
BANK1
bcf BEEPtris
BANK0
endm
goto BEEPb
decfsz TEMP2,1 ; repeat subroutine
goto BEEPa
RETURN
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.")
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
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.
[Toc] [Top]
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
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),
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF
IFNDEF LCDtris
ERROR "Declare LCDtris in MAIN PROGRAM"
ENDIF
IFNDEF LCDport
ERROR "Declare LCDport in MAIN PROGRAM"
ENDIF
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
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
endm
;***************************************************************************
;
; 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
; ==========================
; 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
IFNDEF M_BANK_ID
IFNDEF LCDtris
ERROR "Declare LCDtris in MAIN PROGRAM"
ENDIF
IFNDEF LCDport
ERROR "Declare LCDport in MAIN PROGRAM"
ENDIF
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
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_CGAdr 0x0D
LCDchar b'00001010'
LCD_CGAdr 0x0E
LCDchar b'00011011'
LCD_CGAdr 0x0F
LCDchar b'00000000'
;***************************************************************************
;
; 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.
;
;
; 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:
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF
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
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
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
call LCDxmit
call LCDclk
WAIT LCDWAIT ; ~1 ms @ 4 MHz
;***************************************************************************
;
; 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.
;
;
; 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
; B7: RS
;
; REQUIRED MEMORY:
; ================
; 2 registers: @ BASE+2 - BASE+3
; 2 flags: LCDbusy, LCDcflag
;
;***************************************************************************
#DEFINE M_LCD_ID dummy
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF
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
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
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
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
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'
endm
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
;***************************************************************************
;
; 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)
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF
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
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
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
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
ELSE
ERROR "Wrong line number specified in LCDline"
ENDIF
ENDIF
ENDIF
ENDIF
endm
; 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
;***************************************************************************
;
; 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)
; 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
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF
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
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
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
call LCDdata
endm
;***************************************************************************
;
; 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,
; 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
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF M_WAIT_ID
ERROR "Missing include file: m_wait.asm"
ENDIF
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
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
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
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
LCDchar b'00000000'
decfsz LCDtemp2,f
goto _LCDbusyloop ; busy loop
RETURN
;***************************************************************************
;
; 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
;
IFNDEF M_LCD_ID
ERROR "Missing include file: m_lcd.asm or similar"
ENDIF
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"
ENDIF
IFNDEF BCflag
ERROR "ModuleError: #define BCflag FLAGreg,0x05 (Blank checker) in MAIN PROGRAM"
ENDIF
LCDval_08 macro
call LCDval08
endm
LCDval08
movfw LO
movwf LO_TEMP ; LO -> LO_TEMP
bcf BCflag ; blank checker for preceeding zeros
_VALcnv08
clrf TEMP1 ; counter
movfw TEMP2 ; decrement-value
_V08_1 subwf LO_TEMP,0 ; TEST: LO_TEMP-TEMP2 >= 0 ?
;***************************************************************************
;
; 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
;
IFNDEF M_LCD_ID
ERROR "Missing include file: m_lcd.asm or similar"
ENDIF
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 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
LCDval_16 macro
call LCDval16
endm
LCDval16
movfw LO ; LO -> LO_TEMP
movwf LO_TEMP
movfw HI ; HI -> HI_TEMP
movwf HI_TEMP
bcf BCflag ; Blank checker for preceeding zeros
_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
;***************************************************************************
;
; 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
IFNDEF M_LCD_ID
ERROR "Missing include file: m_lcd.asm or similar"
ENDIF
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
LCDbin_08 macro
call LCDbin08
endm
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
;***************************************************************************
;
; 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
IFNDEF M_LCD_ID
ERROR "Missing include file: m_lcd.asm or similar"
ENDIF
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
LCDbin_16 macro
call LCDbin16
endm
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
;***************************************************************************
;
; 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.
;
;
; 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
;
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF TXport
ERROR "Define TXport in MAIN PROGRAM."
ENDIF
IFNDEF TXtris
ERROR "Define TXtris in MAIN PROGRAM."
ENDIF
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
IFNDEF TXD
ERROR "Declare TXD register in MAIN PROGRAM"
ENDIF
IFNDEF RXD
ERROR "Declare RXD register in MAIN PROGRAM"
ENDIF
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
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
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
;*** 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)
goto X_Wait
RETURN
;***************************************************************************
;
; 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.
;
;
; 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
;
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF TXport
ERROR "Define TXport in MAIN PROGRAM."
ENDIF
IFNDEF TXtris
ERROR "Define TXtris in MAIN PROGRAM."
ENDIF
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
IFNDEF TXD
ERROR "Declare TXD register in MAIN PROGRAM"
ENDIF
IFNDEF RXD
ERROR "Declare RXD register in MAIN PROGRAM"
ENDIF
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
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
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
;*** 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)
goto X_Wait
RETURN
;***************************************************************************
;
; 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.
;
;
; 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
;
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF TXport
ERROR "Define TXport in MAIN PROGRAM."
ENDIF
IFNDEF TXtris
ERROR "Define TXtris in MAIN PROGRAM."
ENDIF
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
IFNDEF TXD
ERROR "Declare TXD register in MAIN PROGRAM"
ENDIF
IFNDEF RXD
ERROR "Declare RXD register in MAIN PROGRAM"
ENDIF
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
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
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
;*** 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)
goto X_Wait
RETURN
;***************************************************************************
;
; 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.
;
;
; 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
;
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF TXport
ERROR "Define TXport in MAIN PROGRAM."
ENDIF
IFNDEF TXtris
ERROR "Define TXtris in MAIN PROGRAM."
ENDIF
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
IFNDEF TXD
ERROR "Declare TXD register in MAIN PROGRAM"
ENDIF
IFNDEF RXD
ERROR "Declare RXD register in MAIN PROGRAM"
ENDIF
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
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
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
;*** 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)
goto X_Wait
RETURN
;***************************************************************************
;
; 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.
;
;
; 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
;
IFNDEF M_BANK_ID
ERROR "Missing include file: m_bank.asm"
ENDIF
IFNDEF TXport
ERROR "Define TXport in MAIN PROGRAM."
ENDIF
IFNDEF TXtris
ERROR "Define TXtris in MAIN PROGRAM."
ENDIF
IFNDEF BASE
ERROR "Declare BASE (Base address of user file registers) in MAIN PROGRAM"
ENDIF
IFNDEF TXD
ERROR "Declare TXD register in MAIN PROGRAM"
ENDIF
IFNDEF RXD
ERROR "Declare RXD register in MAIN PROGRAM"
ENDIF
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
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
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
;*** 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)
goto X_Wait
RETURN
Concept
Available resources
This Excel Worksheet has been designed to speed-up the implementation of 16 bit assembler look-up tables.
There are the following advantages:
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.
[Toc] [Top]
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!
Inhalt:
Layout
Bestckungsplan
Schema
Stckliste
Bauanleitung
Abgleichanleitung
FAQ
Links zum Thema
Layout:
zurck...
download, anzeigen
Bestckungsplan:
zurck...
download, anzeigen
Schema:
zurck...
Fr die technisch interessierten Leute hier das genaue Schema des Decoders. Zum Anschauen am Bildschirm oder zum
downloaden und ausdrucken...
Stckliste:
zurck...
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"...
Bauanleitung:
zurck...
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
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.
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.
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...
Electronic
Circuits &
Radio Controlled
Modeling
Microchip PIC
Microcontrollers
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
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
Thanks for the oportunity to tell you what a great site this is. Many thanks, [email protected]
John Eiderton Nanjing China no URL given
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
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
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
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
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
[Top]
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.
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.
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...
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".
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.
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 !
[Top]
Study theses
Publications
Awards
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.
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:
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.
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...
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.
"... 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 ..."
[Toc] [Top]
Links
Table of Contents [Toc]
Electronic Links
Microchip PIC Links
R/C Links
GPS Links
Data Sheets & Application Notes
Colleague's 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
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
National Semiconductors
Infineon
Maxim Semiconductors
Linear Technology
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
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.
[Toc] [Top]
Software
Electronics
DCF77 Capture & Visualization (Excel 97 Worksheet with Visual Basic Macro)
Automatic Table Generator for MPLAB Assembler (Excel 97 Worksheet with Visual Basic Macro)
Windows 95 HyperTerminal
because Windows 98 HyperTerminal does not echo locally typed 153 kB HyperTerminal95.zip
characters.
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
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.
[Toc] [Top]
Data Sheets
Table of Contents [Toc]
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)
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)
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)
Link: How to control HD44780 based LCDs Describes the basics of the Hitachi HD44780 based character
LCDs.
(Peer Ouwehand's LCD pages)
[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:
These reasons have lead me to change to another controller solution. Finally, I decided to change to the Microchip PIC controllers.
The Microchip PIC microcontrollers are a convenient and cost-effective solution for a lot of home-made applications, because:
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.
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
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
You can also switch directly to the PIC16F877, which offers additional peripheral interfaces, especially if you want to connect some IC peripheral components:
PIC16F877
I started with the PICSTART Plus development programmer from Microchip in 1998, and I still use the same programmer today:
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.
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
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
Please see also the latest* README text files for PICSTART Plus (17 kB) & ICD2 (32 kB)
* by 19.06.2005
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."
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.
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.
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.
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.
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.
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.
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.
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.)
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.
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:
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:
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...
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:
#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).
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:
#include "..\m_bank.asm"
#include "..\m_wait.asm"
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.
Below are some interesting text snippets found on the web about the history of Microchip PIC controllers.
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.
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.
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.
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.
[Toc] [Top]
TELL A
SEARCH WEBRING: This WebRing All
FRIEND!
Computers & Internet > Hardware Add this feed:
PICmicro Sites Add Your
Manager: uandmekids Web Site.
Join Here!
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.
submit my vote
view results without voting
picsystems
this group is about PIC projects.
Andy Programming
View and get updates of current and future projects, download source code for both windows and dos.
Robotics UK
Welcome to robotics UK, i'll show you how to use a PIC in robotics
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.
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
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.
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: 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
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.
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.
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
Contact Information:
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.
Welcome to theempirenet.com
Internet Services
Hosting Talk
The Empirenet
Empirenet
Way International
MS
Home Shopping
Next
Catalog
Staples
Comet
http://theempirenet.com/eewebring/index.html12/02/2008 17:14:28
Electronics Engineering
TELL A
SEARCH WEBRING: This WebRing All
FRIEND!
Engineering > Electrical Add this feed:
Electronics Engineering Add Your
Manager: uandmekids Web Site.
Join Here!
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.
Electronics 2000
Electronics 2000, for electronics hobbyists, engineers and students.
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.
Office Cam The Multimedia Electronic Literature & Learning Internet Site Cam Page
This web site is dedicated to the advancement of electronic engineering skills.
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
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
[ Skip Previous | Previous | LIST SITES | Next | Skip Next | Random Site ]
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
Drive-by-wire Operations
Autonomous State Operations
Piloted-Autonomous Operations
Telemetry Feedback
Monitoring Sessions
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.
Electronics Engineering
Prev | Ring Hub | Join | Rate|
Next
WebRing Inc.
Search
Visit a complete list of WebRing memberships here
Sponsored Link: Ashton Pub Ottawa
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!
Iron WebMaster
Microprocessors, controllers, RTOS, Networking / Communication
Protocols & Embedded technology related sites
Round 2 VOTING
Get in on the Action!
Ads by Google
Celestial Horizons
Basic Compilers for PIC microcontrollers.
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.
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!
Iron WebMaster
Microprocessors, controllers, RTOS, Networking / Communication
Protocols & Embedded technology related sites
Round 2 VOTING
Get in on the Action!
Ads by Google
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.
This web site is dedicated to the memory of James Leonard Callaghan (Cal)
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
Project description:
This is a very small program to try the Sharp GP2Y0D340K infrared object detector.
Electronics used:
Sharp GP2Y0D340K
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
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
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
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
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.
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.
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.
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
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
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
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
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
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
Project descrition:
Description how to use the PIC microcontroller to control a LCD with the SED 1300 controller.
Link: SED 1300 LCD
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
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
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
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.
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.
Previous Entries
SEND TO A FIREND
Send to a friend:
NAVIGATION
Home
PIC Books & Articles
PIC Code library
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
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
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.
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.
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.
Top view of removable pressure sensor module. Circuit design CDP-TX-01 wireless
transmitter, 434 MHz, up to 7.5 kb/s, uni-
directional
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
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
A lot of people have asked me where I got the Motorola absolute pressure sensor from.
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
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.
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.
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.
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'...
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)
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.
Test setup: Drift of 2 bits during one hour (with a single spike).
Test setup: Drift of 3 bits during half an hour. The strange curve comes
possibly from temperature variations.
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)
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:
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.
[Toc] [Top]
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...?
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.
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.
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 ...
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.
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.
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.
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.
Example of a session using the Windows HyperTerminal. The entire contents was sent by the PIC controller.
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.
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
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'.
However, some AT keyboards may behave different and may need code adaptations to get bi-directional communication working properly.
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.
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.
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?"
The AT keyboard sends different scan codes on pressing, holding and releasing of each button. An example is given at the table below:
All scan patterns can easily be visualized and verified with the AT Scan Code Debug Routine and the RS232 Debug Interface.
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.
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.
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
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.
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).
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.
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
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)
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.
You can get the pinout and a description of the various keyboard connectors <here>.
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.
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.
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.
There are these four main code blocks in the keyboard assembler source:
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.
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):
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:
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:
This is roughly what is done in the '_OUTP' section in the assembler source file kbd_2xx.asm.
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.
;******************************
_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
;******************************
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...
[Toc] [Top]
Concept
How it works
Specifications
Features
Limitations
Project Resources
Available PIC Assembler Code
Schematic, Data Sheets, Pinout
User-specific Customization
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.
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.
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)
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.
You can get the description of the various keyboard connectors <here>.
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.
[Toc] [Top]
Concept
How it works
Specifications
Features
Limitations
Project Resources
Available PIC Assembler Code
Schematic, Data Sheets, Pinout
User-specific Customization
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.
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.
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.
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)
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
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
However, some AT keyboards may behave different and may need code adaptations to get bi-directional communication working properly.
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)
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.
You can get the description of the various keyboard connectors <here>.
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.
[Toc] [Top]
Concept
How it works
Specifications
Parts order information
Features
Limitations
Project Resources
Available PIC Assembler Source Code
Schematics, Data Sheets, Pinout
User-specific Customization
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.
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.
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.
Note that every change in microprocessor clock frequency needs a re-calibration and/or re-design of the analog foil-keypad decoding circuitry.
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'.
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
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!
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.
You can get the description of the various keyboard connectors <here>.
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.
[Toc] [Top]
Concept
How it works
Specifications
Supported Morse Alphabet
Features
Limitations
Project Resources
Available PIC Assembler Code
Schematic, Data Sheets, Pinout
User-specific Customization
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).
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.
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 ----.
K -.- X -..-
L .-.. Y -.--
M -- Z --..
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)
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:
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.
You can get the description of the various keyboard connectors <here>.
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.
[Toc] [Top]
Concept
How it works
Specifications
Supported Morse Alphabet
Features
Limitations
Project Resources
Available PIC Assembler Code
Schematic, Data Sheets, Pinout
User-specific Customization
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).
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 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.
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.
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 ---..
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)
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:
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.
You can get the description of the various keyboard connectors <here>.
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.
[Toc] [Top]
Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code
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.
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)
[Toc] [Top]
Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code
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)
[Toc] [Top]
Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code
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.
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)
[Toc] [Top]
Concept
Project Resources
Available Microchip PIC Assembler Source Code
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"
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)
[Toc] [Top]
Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code
Schematics
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 output during operation LCD display output during operation
shows animation with stars shows forth-and-back shifting 'Hello World'
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
The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.asm
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.
[Toc] [Top]
Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code
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.
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)
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
[Toc] [Top]
Concept
Specifications
Project Resources
Available Microchip PIC Assembler Source Code
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 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)
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
[Toc] [Top]
Concept
Project Resources
Available Microchip PIC Assembler Source Code
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:
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
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)
[Toc] [Top]
Concept
How the numeric foil-keypad works
Specifications
Parts order information
Project Resources
Available Microchip PIC Assembler Source Code
Schematics, Data Sheets, Pinout
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.
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.
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.
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
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!
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.
You can get the description of the various keyboard connectors <here>.
[Toc] [Top]
Overview
Specifications
Project Resources
Available Microchip PIC Assembler Source Code
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.
The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.asm
[Toc] [Top]
Concept
Components
Test Setup
Software
Project Resources
Available Microchip PIC Assembler Source Code
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.
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
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.
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.
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.
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.
This is the graphical user interface of my Excel 97 work sheet designed to visualize and translate received serial DCF77 data from
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.
The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.asm
Download Excel 97 work sheet (DCF77 data visualization and translation): DCF77_Visualizer.zip (155 kB)
[Toc] [Top]
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- . , "" .
, , , .
.
PIC 12 SMALL
H-T
256 ROM. .
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
.
, path info .
.
.
.
. , .
, , "" ADC, , -
. , "", RTOS. ""
. "" , . ,
( ), , . .
, . , " " ,
.
jacOS . ,
. , ,
... . , .
IAR __task.
, , . (TCB).
//1 task_1 OST_TASK, TCB. jacOS
TCB. OST_TASK, - OST_TASK_T, .
TCB bank1. , . jacOS bank2
bank3. , , .
, .
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++ .
/********************************************/
OS_Cooperate() , . //1
, //2. , //2 loc_var , sta_var,
, 45-.
- , .
/***** c:\jacos\prim\prim1*****************/
#define OS_MAIN
#include <jacos.h>
OST_TASK task1;
OST_TASK task2;
unsigned char counter;
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 );
. prim1 , OS_Task_Create() . - ,
- TCB.
, prim1 . , .
. ,
, , .
OS_Scheduler();
OS_Scheduler() .
. , OS_Scheduler() , .
. , OS_Scheduler() - ,
. , . , WDT, .
c:\jacos\prim\prim1.
, jacOS ? , .
"jacnfg.h". prim1 :
PIC12F675 :
main.c -
40Antln.lib -
:
1) jacnfg.h.
2) head ( \jacos\incl ).
.
. .
. ? , ,
100 150? OS_Delay().
/***** c:\jacos\prim\prim2******