'**************************************************************** '* Name : LCDtest8.BAS * '* Author : Gerald Crenshaw * '* Notice : Copyright (c) 2017 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 8/16/2017 * '* Version : 1.0 * '* Notes : This is a test program to drive a 2 line LCD * '* : display with the Hobbybotics serial backpack. * * '* : Added output on Pin2 to give serial output of * '* : Non inverted 9600 bps * '* : Changed the text from LCDtest5 * '**************************************************************** '16F628A '901 of 2048 words used 'Config bits 3FE9 Osc to XT, MCLR to +5 ' ' 'Pinout 16F628/A 'Pin 17 PortA0/AN0 'Pin 18 PortA1/AN1 'Pin 1 PortA2/AN2/Vref 'Pin 2 PortA3/AN3/CMP1 'Pin 3 PortA4/TOCKI/CMP2 'Pin 4 PortA5/MCLR/Vpp 'Pin 15 PortA6/OSC2/Clkout 'Pin 16 PortA7/OSC1/Clkin 'Pin 6 PortB0/Int 'Pin 7 PortB1/Rx/DT 'Pin 8 PortB2/TX/CK 'Pin 9 PortB3/CCP1 'Pin 10 PortB4/PGM 'Pin 11 PortB5 'Pin 12 PortB6/T1OSO/T1CKI/ICPCLK 'Pin 13 PortB7/T1OSI/ISPDAT 'Pin 14 5V/VDD 'Pin 5 Gnd/VSS ' ' New character mapping for Hobbybotics LCD display ' Character line map 2x16 (or 20) ' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ' L1 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 ' L2 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 ' Character line map 4x20 ' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ' L1 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 ' L2 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 ' L3 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 ' L4 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 101 102 103 104 ' ' ' set registers, variables and constants INCLUDE "modedefs.bas" 'includes Mode Definitions for display Define osc 4 'Set osc to 4Mhz, Xtal controled CMCON=7 'See Note 1A,Sets analog ports digital I CON 254 ' 'Instruction Prefix clrlcd CON 0 'Clear LCD of all previous instructions. 'Change from SEE backpack from 1 to 0 scp con 4 'set cursor position prefix, see map above 'New constant for Hobbybotics Backpack L1C1 CON 00 'Print Position for Line 1 Character 1 L2C1 CON 64 'Print Position for Line 2 Character 1 b2 VAR WORD 'Pin 1 PORTA.2 will output 9600bps TTL inverted data (N9600) 'Pin 2 PORTA.3 will output 9600bps TTL non inverted data (T9600) START: 'serout porta.2,N9600,[I, 9, 0] 'turn backlight OFF serout porta.2,N9600,[I, 9, 1] 'turn backlight ON serout porta.3,T9600,[I, 9, 1] 'turn backlight ON Low PORTB.0 b2=60 'Set max time in second SerOut PORTA.2,N9600,[I,clrlcd] 'Pin 1, clear lcd of previous stuff SerOut PORTA.3,T9600,[I,clrlcd] 'pin 2, clear lcd of previous stuff Pause 1000 'pause to let LCD catch up. SerOut PORTA.2,N9600,[I,scp,L1C1,"Testing-Line-One"] 'Tests all of line 1 LCD SerOut PORTA.3,T9600,[I,scp,L1C1,"Testing-Line-One"] 'Tests all of line 1 LCD SerOut PORTA.2,N9600,[I,scp,L2C1,"Testing-Line-Two"] 'Tests all of line 2 LCD SerOut PORTA.3,T9600,[I,scp,L2C1,"Testing-Line-Two"] 'Tests all of line 2 LCD Pause 6000 'Pause three seconds so I can check LCD countdown: SerOut PORTA.2,N9600,[I,clrlcd] SerOut PORTA.3,T9600,[I,clrlcd] SerOut PORTA.2,N9600,[I,scp,L1C1,"COUNTDOWN "] SerOut PORTA.3,T9600,[I,scp,L1C1,"COUNTDOWN "] SerOut PORTA.2,N9600,[I,scp,L2C1,#b2," Seconds"] SerOut PORTA.3,T9600,[I,scp,L2C1,#b2," Seconds"] b2=b2-1 IF b2=0 Then boom Pause 1000 GoTo countdown boom: SerOut PORTA.2,N9600,[I,clrlcd] SerOut PORTA.3,T9600,[I,clrlcd] SerOut PORTA.2,N9600,[I,scp,L1C1," Turn on"] SerOut PORTA.3,T9600,[I,scp,L1C1," Turn on"] SerOut PORTA.2,N9600,[I,scp,L2C1," LED 1"] SerOut PORTA.3,T9600,[I,scp,L2C1," LED 1"] High PORTB.0 Pause 5000 GoTo START End