Simple RS232 Interface for Microchip PIC16F84
Simple RS232 Interface fully software contro lled RS232 transmission and reception for P IC16F84
Table of Contents [Toc]
Concept Project Resources Available Microchip PIC Assembler Source Code Schematic, Data Sheets, Pinout
Concept
[Toc Toc]] [Top [Top]]
Fully software controlled RS232 reception and transmission for PIC16F8x. The microcontroller echoes every received RS232 character back to the RS232 terminal window on the host (i.e. the computer). The HyperTerminal program (Win9x, WinXP) is configured to use the standard settings as shown below.
Simple RS232 Interface for Microchip PIC16F84
Screen shot of the HyperTerminal Program showing the start-up message of this RS232 test routine.
Project Resources
Standard RS232 ComPort settings (9600-8-N-1)
[Toc Toc]] [Top [Top]]
Toc]] [Top [Top]] Available Microchip PIC Assembler Source Code [Toc
Main File
HEX Files
Download assembler source code:
Download Hex File:
Simple RS232 Interface for Microchip PIC16F84
Screen shot of the HyperTerminal Program showing the start-up message of this RS232 test routine.
Project Resources
Standard RS232 ComPort settings (9600-8-N-1)
[Toc Toc]] [Top [Top]]
Toc]] [Top [Top]] Available Microchip PIC Assembler Source Code [Toc
Main File
HEX Files
Download assembler source code:
Download Hex File:
Simple RS232 Interface for Microchip PIC16F84
If you see only this page in your browser window, click here to get the entire site.
http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm
;**************************** ;****************************************** ***************************** ***************************** ****************** **** ; ; RS232 Test Interface V1.02 ; ========================== ; ; written by Peter Luethi, 26.03.1999, Dietikon, Switzerland ; http://www.electronic-engineering.ch ; last update: 16.01.2005 ; ; V1.02: Fixed copy/paste issue of ISR context store/restore ; (nobody is perfect): Erroneously erased INTCON,INTF ; clearing, resulting in endless ISR calling... ; Re-structured entire ISR and RS232 echo sub-routines ; (11.04.2004) ; ; V1.01: ISR context restore improvements (21.11.1999) ; ; V1.00: Initial release (26.3.1999) ; ; This code and accompanying files may be distributed freely and ; modified, provided this header with my name and this notice remain ; intact. Ownership rights remain with me. ; You may not sell this software without my approval. ;
http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm
; featured PICs. ; Program handles all aspects of RS232 ; Transmission (Register TXD) and ; Reception (register RXD) through interrupts (PortB0 IRQ). ; The microcontroller sends feedback of received characters back to ; the terminal window. ; ; Program shows the implementation and function of the modules ; m_bank.asm, m_wait.asm, and m_rs096.asm on the PIC16F84A. ; ;**************************** ;****************************************** ***************************** ***************************** ****************** **** ;***** COMPILATION MESSAGES & WARNINGS ***** ERRORLEVEL -207 ERRORLEVEL -302
; found label after column 1 ; register in operand not in bank 0
;***** PROCESSOR DECLARATION & CONFIGURATION ***** PROCESSOR 16F84A #include "p16f84a.inc" ; embed Configuration Data within .asm File. __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC ;***** MEMORY STRUCTURE *****
http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm
FLAGreg equ BASE+d'7' #define RSflag FLAGreg,0x00 ; RS232 data reception flag TXD RXD
equ equ
BASE+d'8' BASE+d'9'
; TX-Data register ; RX-Data register
W_TEMP equ BASE+d'10' ; context register (ISR) STATUS_TEMP equ BASE+d'11' ; context register (ISR) PCLATH_TEMP equ BASE+d'12' ; context register (ISR) FSR_TEMP equ BASE+d'13' ; context register (ISR) ;***** INCLUDE FILES ***** #include "..\..\m_bank.asm" #include "..\..\m_wait.asm" #include "..\..\m_rs096.asm" ; specify desired RS232 module ;***** MACROS ***** ;***** SUB-ROUTINES ***** RSservice SEND TAB SEND 'E' SEND 'c'
http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm
;************************ bcf INTCON,GIE ; disable all interrupts btfsc INTCON,GIE ; assure interrupts are disabled goto ISR movwf W_TEMP ; context save: W swapf STATUS,W ; context save: STATUS movwf STATUS_TEMP ; context save clrf STATUS ; bank 0, regardless of current bank movfw PCLATH ; context save: PCLATH movwf PCLATH_TEMP ; context save clrf PCLATH ; page zero, regardless of current page bcf STATUS,IRP ; return to bank 0 movfw FSR ; context save: FSR movwf FSR_TEMP ; context save ;*** context save done ***
;************************** ;*** ISR MAIN EXECUTION *** ;************************** ;*** check origin of interrupt *** btfsc INTCON,INTF ; check for RB0/INT interrupt goto _ISR_RS232 ; if set, there was a keypad stroke catch-all
http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm
; necessarily mean, that the interrupts are already re-enabled. ; Basically, interrupt re-enabling is carried out at the end of ; the corresponding service routine in normal operation mode. ; The flag responsible for the current ISR call has to be cleared ; to prevent recursive ISR calls. Other interrupt flags, activated ; during execution of this ISR, will immediately be served upon ; termination of the current ISR run. _ISR_RS232error bsf INTCON,INTE ; after error, re-enable IRQ already here _ISR_RS232end bcf INTCON,INTF ; clear RB0/INT interrupt flag ;goto ISRend ; terminate execution of ISR
;***************************************** ;*** ISR TERMINATION (CONTEXT RESTORE) *** ;*****************************************
ISRend movfw FSR_TEMP ; context restore movwf FSR ; context restore movfw PCLATH_TEMP ; context restore movwf PCLATH ; context restore swapf STATUS_TEMP,W STATUS_TEMP,W ; context restore movwf STATUS ; context restore swapf W_TEMP,F ; context restore swapf W_TEMP,W ; context restore RETFIE enable global interrupt (INTCON,GIE)
http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm
SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND
'2' '' 'T' 'e' 's' 't' '' 'I' 'n' 't' 'e' 'r' 'f' 'a' 'c' 'e' ':' '' 'P' 'I' 'C' '1' '6' 'F' '8' '4'
http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.asm
LOOP btfsc RSflag call RSservice goto LOOP END
; check RS232 data reception flag ; if set, call RS232 echo & LCD display routine
http://www.trash.net/~luethi/microchip/projects/rs232/rs_test/rs_test.hex
:020000040000FA :020000007E2858 :080008004F288C0081018316D2 :100010000313C030810508008C008 :100010000313C030810508008C008101831603138F 101831603138F :10002000C0308105013081048312 :10002000C030810501308104831203130B110B1DB5 03130B110B1DB5 :1000300017288C0B1628080094000 :1000300017288C0B162808009400051008308C0037 51008308C0037 :100040002D2014180514141C0510 :100040002D2014180514141C0510940C2D208C0B55 940C2D208C0B55 :10005000212805142D202D20080 :10005000212805142D202D2008001D308D0033286 01D308D003328677 :1000600008308D0033288D0B3328 :1000600008308D0033288D0B332808009501732844 08009501732844 :1000700009301C2045301C2063301 :1000700009301C2045301C2063301C2068301C20B7 C2068301C20B7 :100080006F301C203A301C200930 :100080006F301C203A301C2009301C2015081C2021 1C2015081C2021 :100090000D301C200A301C2013100 :100090000D301C200A301C2013100B1608008B1387 B1608008B1387 :1000A0008B1B4F289600030E97008 :1000A0008B1B4F289600030E970083010A089800C7 3010A089800C7 :1000B0008A018313040899008B185 :1000B0008A018313040899008B185F2875280B1296 F2875280B1296 :1000C00030200618362808308C002 :1000C00030200618362808308C002D200618951789 D200618951789 :1000D000061C95130C0B950C8C0B652 :1000D000061C95130C0B950C8C0B65282D20061C0B 82D20061C0B :1000E0003628131474280B168B1019 :1000E0003628131474280B168B101908840018086E 08840018086E :1000F0008A00170E8300960E160E09 :1000F0008A00170E8300960E160E09008B018316D8 008B018316D8 :1001000003130510061401138312 :1001000003130510061401138312031305148B1037 031305148B1037 :100110000B168B1793010D301C200 :100110000B168B1793010D301C200A301C20523017 A301C20523017 :100120001C2053301C2032301C2033 :100120001C2053301C2032301C2033301C20323035 301C20323035 :100130001C2020301C2054301C2065 :100130001C2020301C2054301C2065301C207330C3 301C207330C3 :100140001C2074301C2020301C2049 :100140001C2074301C2020301C2049301C206E30B4 301C206E30B4 :100150001C2074301C2065301C2072 :100150001C2074301C2065301C2072301C2066303E 301C2066303E
Microchip PIC microcontroller assembler modules
PIC Assembler Modules For Non-Commercial Use Use Only
I would appreciate to be credited within your project, if you use any of the source code below. If you have an interesting project going on, I'll be glad about feedback. The software below comes with no guarantee or warranty except for my good intentions. Further the use of this code implies that the user has a fundamental understanding of electronics and its risks. I'm not responsible for any harm or damage, caused by inproper use of any of the code below. Any commercial use of of parts or all of of this code requires requires the permission of the author .
Table of Contents [Toc]
General Standard Modules Dot Matrix LCD Modules LCD Display Driver Routines LCD Display Conversion Routines RS232 Modules Notes on Modules General Recommendations Known Limitations of MPLAB IDE Technical Hints
Toc]] [Top [Top]] General [Toc
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.
Microchip PIC microcontroller assembler modules
LCDtris equ TRISB LCDport equ PORTB CONSTANT BASE = 0x0C
; 16F84 base address of user file registers
#include "..\m_bank.asm" #include "..\m_wait.asm" #include "..\m_lcd.asm"
Standard Modules
[Toc Toc]] [Top [Top]]
Assembler include files: General macros to ease assembler handling, e.g. macros BANK0, BANK1 V2.00 (17.08.2004) Bank & page handling: Bank0, Bank1,...
m_bank.asm
Branch macros (to simplify 'IF THEN ELSE' queries): BEQ val: branch on equal w and val BNE val: branch on not equal w and val BREG val: branch on equal or greater w than val ... V1.02 (20.08.2004)
Parameterizable wait function, which performs a "busy" wait. Implemented standard delay (@ 4 MHz): WAIT 0x01 is equal to 1 unit == 1.02 ms The assigned standard prescaler for TMR0 is PRESCstd = b'00000001' Relationship between TMR0 prescaler and unit delay (WAIT 0x01): b'00000000' b'00000000' == 1:2 ==> 0.512 ms b'00000001' b'00000001' == 1:4 ==> 1.02 ms (standard) ( standard) b'00000111' b'00000111' == 1:256 ==> 65.3 ms m_wait.asm
Microchip PIC microcontroller assembler modules
CONSTANT BASE = 0x0C
; 16F84 base address of user file registers
#include "..\m_bank.asm" #include "..\m_wait.asm" ; Call of implemented procedures with: ; WAIT 0x01 ; standard delay, 1.02 ms ; WAITX d'16',d'7' ; 1.045 s @ 4 MHz, extended with specific prescaler
V1.00 (16.02.2003)
Beep function on parameterizable output port. Declarations needed in main program: #define #define
m_beep.asm
BEEPport BEEPtris
PORTA,0x00 TRISA,0x00
CONSTANT BASE = 0x0C
; 16F84 base address of user file registers
#include "..\m_bank.asm" #include "..\m_beep.asm" ; Call of implemented procedures with: ; BEEPinit ; initialization to set output port ; BEEP 0xFF,0x02
For demo-programs or complete applications, refer to 'Projects'
Dot Matrix LCD Modules
[click here]
[Toc Toc]] [Top [Top]]
Assembler include include files: Display Display drivers for dot matrix LCD displays. ( Hitachi HD44780 compatibles )
Microchip PIC microcontroller assembler modules
Dot Matrix LCD LCD Display 2 lines x 40 characters Dot Matrix LCD LCD Display 4 lines x 20 characters
Toc]] [Top [Top]] LCD Display Driver Routines [Toc
Download the PDF schematic to 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 have to be on the the low nibble of of the port.
Microchip PIC microcontroller assembler modules
V2.06 (26.12.2004)
7 wires, 4 bit LCD interface Based on timing constraints, no busy flag check. So if LCD fails, system is still running stable. Higher reliability, because less critical system components. No portable code for higher clock frequencies. R/W connection to LCD supported for compatibility to m_lcd_bf.asm, but can be put to GND at LCD side => You'll get one interrupt pin more on the processor side. Schematic of LCD connection (PDF) connection (PDF) Declarations needed in main program:
m_lcd.asm
LCDtris equ TRISB LCDport equ PORTB ; LCD data ports D4-D7 are on ; LCD_EN is on LCDport,0x05 ; LCD_RW is on LCDport,0x06 ; LCD_RS is on LCDport,0x07 CONSTANT BASE = 0x0C
; could also be PORTC, PORTD on 16F77 LCDport,0x1-0x4 ; Enable ; Read/Write ; Register Select ; 16F84 base address of user file registers
#include "..\m_bank.asm" #include "..\m_wait.asm" #include "..\m_lcd.asm"
V2.26 (26.12.2004)
7 wires, 4 bit LCD interface Extended m_lcd.asm with the ability to define your own characters (max. 8) in macro LCDspecialChars. Based on timing constraints, specifications as m_lcd.asm. Schematic of LCD connection (PDF) connection (PDF) Declarations needed in main program:
Microchip PIC microcontroller assembler modules
LCDtris equ TRISB LCDport equ PORTB ; LCD data ports D4-D7 are on ; LCD_EN is on LCDport,0x05 ; LCD_RW is on LCDport,0x06 ; LCD_RS is on LCDport,0x07 CONSTANT BASE = 0x0C
; could also be PORTC, PORTD on 16F77 LCDport,0x1-0x4 ; Enable ; Read/Write ; Register Select ; 16F84 base address of user file registers
; complete/replace macro LCDspecialChars to define your own characters #include "..\m_bank.asm" #include "..\m_wait.asm" #include "..\m_lcdx.asm"
V3.09 (26.12.2004)
7 wires, 4 bit LCD interface Extended m_lcd.asm which reads busy flag of LCD (bi-directional communication 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 f ails, if LCD (-connection) fails, because processor is waiting for ready signal from fr om LCD to send next character. => Deadlock, but should not occur under normal circumstances! Solution: Connect an auxilliary 10k resistor from DB7 to GND, so if the LCD is disconnected, the microprocessor will read an inactive busy flag. (That's needed because of the internal weak pull ups of the microprocessor ports. Maybe also needed if you switch them off.) Schematic of LCD connection (PDF) connection (PDF) Declarations needed in main program:
m_lcd_bf.asm
Microchip PIC microcontroller assembler modules
LCDtris equ TRISB LCDport equ PORTB ; LCD data ports D4-D7 are on ; LCD_EN is on LCDport,0x05 ; LCD_RW is on LCDport,0x06 ; LCD_RS is on LCDport,0x07
; could also be PORTC, PORTD on 16F77 LCDport,0x1-0x4 ; Enable ; Read/Write ; Register Select
CONSTANT BASE = 0x0C ; 16F84 base address of user file registers FLAGreg equ BASE+d'7' ; general flag register #define LCDbusy FLAGreg,0x00 ; LCD busy flag declared within flag register #define LCDcflag FLAGreg,0x01 #include "..\m_bank.asm" #include "..\m_wait.asm" #include "..\m_lcd_bf.asm"
V3.29 (26.12.2004)
m_lcdxbf.asm
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. Bidirectional communication, communication, reads busy flag of LCD. Schematic of LCD connection (PDF) connection (PDF)
V2.12e (17.08.2004)
7 wires, 4 bit LCD interface Basically as m_lcd.asm, but with the ability to independently configure LCD control and data lines, i.e. LCD data on low nibble of any port, LCD command lines on any port bits (even different port). Schematic of LCD connection (PDF) connection (PDF) Declarations needed in main program:
m_lcde.asm
Microchip PIC microcontroller assembler modules
LCDtris LCDport #define #define #define #define #define #define
equ TRISA equ PORTA LCD_ENtris TRISB,0x01 LCD_EN PORTB,0x01 LCD_RStris TRISB,0x02 LCD_RS PORTB,0x02 LCD_RWtris TRISB,0x03 LCD_RW PORTB,0x03
CONSTANT BASE = 0x0C
; LCD data on low nibble of portA ; EN on portB,1 ; RS on portB,2 ; RW on portB,3
; 16F84 base address of user file registers
#include "..\m_bank.asm" #include "..\m_wait.asm" #include "..\m_lcde.asm"
V4.03e (17.08.2004)
7 wires, 4 bit LCD interface Extended m_lcde.asm which reads busy flag of LCD (bi-directional communication communication between controller and LCD) Schematic of LCD connection (PDF) connection (PDF) Declarations needed in main program:
m_lcde_bf.asm
LCDtris LCDport #define #define #define #define #define #define
equ TRISA equ PORTA LCD_ENtris TRISB,0x01 LCD_EN PORTB,0x01 LCD_RStris TRISB,0x02 LCD_RS PORTB,0x02 LCD_RWtris TRISB,0x03 LCD_RW PORTB,0x03
; LCD data on low nibble of portA ; EN on portB,1 ; RS on portB,2 ; RW on portB,3
CONSTANT BASE = 0x0C ; 16F84 base address of user file registers FLAGreg equ BASE+d'7' ; general flag register #define LCDbusy FLAGreg,0x06 ; LCD busy flag declared within flag register #define LCDcflag FLAGreg,0x07 ; LCD command/data flag
Microchip PIC microcontroller assembler modules
#include "..\m_wait.asm" #include "..\m_lcde_bf.asm"
V4.23e (17.08.2004)
m_lcdexbf.asm
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. Bidirectional communication, communication, reads busy flag of LCD. Schematic of LCD connection (PDF) connection (PDF)
For demo-programs or complete applications, refer to 'Projects'
[click here]
Toc]] [Top [Top]] LCD Display Conversion Routines [Toc
V1.02 (20.08.2004)
8 bit binary to decimal conversion routine for LCD output, stringent for any numeric display output or interaction. Declarations needed in main program:
m_lcdv08.asm
CONSTANT BASE = 0x0C ; 16F84 base address of user file registers FLAGreg equ BASE+d'4' ; general flag register LO equ BASE+d'5' LO_TEMP set BASE+d'6' #define BCflag FLAGreg,0x00 ; blank checker for preceding zeros #include #include #include #include
"..\m_bank.asm" "..\m_wait.asm" "..\m_lcd.asm" "..\m_lcdv08.asm"
; Call of implemented procedure with: LCDval_08 ; result is stored in register LO
Microchip PIC microcontroller assembler modules
V1.02 (20.08.2004)
16 bit binary to decimal conversion routine for LCD output, stringent for any numeric display output or interaction. Declarations needed in main program:
m_lcdv16.asm
CONSTANT BASE = 0x0C ; 16F84 base address of user file registers FLAGreg equ BASE+d'4' ; general flag register LO equ BASE+d'5' HI equ BASE+d'6' LO_TEMP set BASE+d'7' HI_TEMP set BASE+d'8' #define BCflag FLAGreg,0x00 ; blank checker for preceding zeros #include #include #include #include
"..\m_bank.asm" "..\m_wait.asm" "..\m_lcd.asm" "..\m_lcdv16.asm"
; Call of implemented procedure with: LCDval_16 ; result is stored in registers HI, LO
V1.00 (20.08.2004)
8 bit binary LCD output routine for debugging of registers and bitstreams, e.g. to visualize the binary output of an A/D converter to check the magnitude of its LSB toggling due to digital quantization and/or noise. Declarations needed in main program:
m_lcdb08.asm
Microchip PIC microcontroller assembler modules
CONSTANT BASE = 0x0C ; 16F84 base address of user file registers b08_cnt equ BASE+d'4' ; counter LO equ BASE+d'5' LO_TEMP set BASE+d'6' #include #include #include #include
"..\m_bank.asm" "..\m_wait.asm" "..\m_lcd.asm" "..\m_lcdb08.asm"
; Call of implemented procedure with: LCDbin_08 ; value in register LO, output to LCD
V1.00 (20.08.2004)
16 bit binary LCD output routine for debugging of registers and bitstreams, e.g. to visualize the binary output of an A/D converter to check the magnitude of its LSB toggling due to digital quantization and/or noise. Declarations needed in main program:
m_lcdb16.asm
CONSTANT BASE = 0x0C ; 16F84 base address of user file registers b16_cnt equ BASE+d'4' ; counter LO equ BASE+d'5' HI equ BASE+d'6' LO_TEMP set BASE+d'7' HI_TEMP set BASE+d'8' #include #include #include #include
"..\m_bank.asm" "..\m_wait.asm" "..\m_lcd.asm" "..\m_lcdb16.asm"
; Call of implemented procedure with: LCDbin_16 ; values in register HI, LO, output to LCD
For demo-programs or complete applications, refer to 'Projects'
[click here]
Microchip PIC microcontroller assembler modules
RS232 Modules
[Toc Toc]] [Top [Top]]
For external interrupts, such as the RB0/INT pin or PORTB change interrupt, the latency will be three to four instruction cycles. The exact latency depends on when the interrupt occurs. The latency is the same for both one and two cycle instructions. (=> see Microchip PIC16/17 Microcontroller 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: Specifications: 2400 baud, 8 bit, no parity, parity, 1 stopbit (@ 4 MHz / 1 MIPS) MIPS) Declarations needed in main program: #define TXport PORTA,0x00 ; RS232 output port, could be #define TXtris TRISA,0x00 ; any active push/pull port ; RS232 input port is RB0, because of its own interrupt flag
m_rs024.asm
CONSTANT BASE = 0x0C TXD equ BASE+d'7' RXD equ BASE+d'8'
; 16F84 base address of user file registers ; TX data register, for transmission ; RX data register, for storage
#include "..\m_bank.asm" #include "..\m_rs024.asm" ; ; ; ; ;
Call of implemented procedures with: RS232init ; initialization SEND 'c' ; sends character 'c' SENDw ; sends content of working register RECEIVE ; macro in ISR: receive from RS232, ; store in register RXD
Microchip PIC microcontroller assembler modules
V1.02 (11.04.2004)
m_rs048.asm
Functionality Functionality as m_rs024.asm
Specifications: Specifications: 4800 baud, 8 bit, no parity, parity, 1 stopbit (@ 4 MHz / 1 MIPS) MIPS) V1.02 (11.04.2004)
m_rs096.asm
Functionality Functionality as m_rs024.asm
Specifications: Specifications: 9600 baud, 8 bit, no parity, parity, 1 stopbit (@ 4 MHz / 1 MIPS) MIPS) V1.02 (11.04.2004)
m_rs192.asm
Functionality Functionality as m_rs024.asm
Specifications: Specifications: 19200 baud, baud, 8 bit, no parity, parity, 1 stopbit (@ 4 MHz / 1 MIPS) MIPS) V1.02 (11.04.2004)
m_rs7n1.asm
Functionality Functionality as m_rs024.asm
Developed for an old and heavy matrix needle printer with RS232 Interface. Specifications: Specifications: 9600 baud, 7 bit, no parity, parity, 1 stopbit (@ 4 MHz / 1 MIPS) MIPS)
For demo-programs or complete applications, refer to 'Projects'
Notes on Modules
[Toc Toc]] [Top [Top]]
Code is optimized for 1. small memory, and 2. optimal execution time. If extern sources are called from within modules, set absolute pathes. Please refer to Known Limitations of MPLAB IDE below. Declare and define the required registers and statements in the MAIN. Declarations of constants and registers need to be listed in the MAIN before the '#include' statement of the modules, since most modules are referencing specific constants and registers (therefore they need to be defined at that time).
General Recommenda Recommendations tions
[click here]
[Toc Toc]] [Top [Top]]
Manage the used registers in a clear structured way. For prototyping, it is recommended to introduce temporarily dedicated registers for each new code segment. At the end, when everything runs properly, you can start to optimize the design in order to share as much registers as possible to save memory space. Otherwise, you run the risk of getting data consistency problems - bugs, which are really hard to solve! Provide dedicated registers for interrupt handling! Do not call subroutines from the interrupt service routine (ISR), which are executed during normal operation. If so, ensure to perform a complete context save of all registers being used within this subroutine. Interrupt flags have to be cleared by software before re-enabling the 'global interrupt enable bit' (GIE) and exiting the ISR. Otherwise, recursive ISR