Specifications
mikroElektronika | Free Online Book | PIC Microcontrollers | Appendix B: Examples
i=i+1
ENDW
Exit
ENDM
;**********************************************************************
; This macro writes value in size of 1 byte on LCD
; excluding leading zeros
;**********************************************************************
lcdbyte MACRO arg0
digbyte arg0 ; A hundred is in Dig2,
; A ten is in Dig1 and one in Dig0
movf Dig2, w
addlw 0x30
call LCDdata
movf Dig1, w ; If digit is 0 move cursor
addlw 0x30
call LCDdata
movf Dig0, w ; If digit is 0 move cursor
addlw 0x30
call LCDdata
ENDM
;**********************************************************************
; 1ms Delay
Delay1ms:
movlw .200
movwf LOOPcnt
Delay10us:
nop ;1us
nop ;1us
nop ;1us
nop ;1us
nop ;1us
nop ;1us
nop ;1us
decfsz LOOPcnt, f ;1us
goto Delay10us ;2us
return
EXAMPLE 16
RS232 serial communication
This example illustrates the use of the microcontroller's EUSART module. Connection to the PC is enabled through RS232
standard. The program works in the following way: Every byte received via the serial communication is displayed using
LED diodes connected to port B and is automatically returned to the transmitter thereafter. If an error occurs on receive,
it will be signalled by switching the LED diode on. The easiest way to test device operation in practice is by using a
standard Windows program called Hyper Terminal.
http://www.mikroe.com/en/books/picmcubook/appb/ (51 of 54)5/3/2009 11:36:02 AM