'**************************************************************** '* Name : LCDtest9.BAS * '* Author : Gerald Crenshaw * '* Notice : Copyright (c) 2017 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 8/28/2017 * '* Version : 1.0 * '* Notes : This is a test program to drive a 2 line LCD * '* : display with the Hobbybotics serial backpack. * * '* : Pin6 to give serial output of * '* : Non inverted 9600 bps * '* : Pin7 to give serial output of * '* : Inverted 9600 BPS * '* : Pin 5 to LED * '**************************************************************** '12F629 '925 of 1024 words used 'Config bits 31F9 Osc to XT, MCLR to +5 '4 Mhz ceramic osc on pins 2,3 ' ' 'General NOTES '12F675/629 Pin Notes (chips are the same but the 675 has a 10 BIT D/A) 'Pin 1 VDD/V+ 'Pin 2 Osc1/GPIO.5/T1CK1/CLKIN I/O when INT Osc not used/Timer 1 Clk/Ext Clock In 'Pin 3 Osc2/GPIO.4/ ClkOut I/O when INT Osc used or an Oscilator /Ext Clock Out 'Pin 4 GPIO.3/MCLR/Vpp I Input Only/MCLR Ext/Programing V 'Pin 5 GPIO.2/T0CK1/Int/Cout I/O /Timer0 Clock Input/External Interupt/Comparator output 'Pin 6 GPIO.1/Cin-/ICSPClk I/O /Comparator In- /In Circuit Serial Prog Clock 'Pin 7 GPIO.0/Cin+/ICSPData I/O /Compartor In +/In Circuit Serial Prog Data/ 'Pin 8 Vss/Ground ' '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/ICSPCLK 'Pin 13 PortB7/T1OSI/ICSPDATA '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 7 GPIO.0 will output 9600bps TTL inverted data (N9600) 'Pin 6 GPIO.1 will output 9600bps TTL non inverted data (T9600) START: 'serout porta.2,N9600,[I,9,0] 'turn backlight OFF serout GPIO.0,N9600,[I,9,1] 'turn backlight ON serout GPIO.1,T9600,[I,9,1] 'turn backlight ON Low GPIO.2 b2=60 'Set max time in second SerOut GPIO.0,N9600,[I,clrlcd] 'Pin 1, clear lcd of previous stuff SerOut GPIO.1,T9600,[I,clrlcd] 'pin 2, clear lcd of previous stuff Pause 100 'pause to let LCD catch up. SerOut GPIO.0,N9600,[I,scp,L1C1,"Resistance is "] 'Print text line 1 LCD SerOut GPIO.1,T9600,[I,scp,L1C1,"Resistance is "] 'Print text line 1 LCD SerOut GPIO.0,N9600,[I,clrlcd] 'Pin 1, clear lcd of previous stuff SerOut GPIO.1,T9600,[I,clrlcd] 'pin 2, clear lcd of previous stuff SerOut GPIO.0,N9600,[I,scp,L2C1,"Futile"] 'Print text line 2 LCD SerOut GPIO.1,T9600,[I,scp,L2C1,"Futile"] 'Print text line 2 LCD Pause 3000 'Pause three seconds SerOut GPIO.0,N9600,[I,clrlcd] 'Pin 1, clear lcd of previous stuff SerOut GPIO.1,T9600,[I,clrlcd] 'pin 2, clear lcd of previous stuff SerOut GPIO.0,N9600,[I,scp,L1C1,"You will be "] 'Print text line 1 LCD SerOut GPIO.1,T9600,[I,scp,L1C1,"You will be"] 'Print text line 1 LCD SerOut GPIO.0,N9600,[I,clrlcd] 'Pin 1, clear lcd of previous stuff SerOut GPIO.1,T9600,[I,clrlcd] 'pin 2, clear lcd of previous stuff SerOut GPIO.0,N9600,[I,scp,L2C1,"Assimilated in"] 'Print text line 2 LCD SerOut GPIO.1,T9600,[I,scp,L2C1,"Assimilated in"] 'Print text line 2 LCD Pause 3000 'Pause three seconds countdown: SerOut GPIO.0,N9600,[I,clrlcd] 'Pin 7, clear lcd of previous stuff SerOut GPIO.1,T9600,[I,clrlcd] 'Pin 8, clear lcd of previous stuff SerOut GPIO.0,N9600,[I,scp,L1C1,"COUNTDOWN "] 'Print text line 1 LCD SerOut GPIO.1,T9600,[I,scp,L1C1,"COUNTDOWN "] 'Print text line 2 LCD SerOut GPIO.0,N9600,[I,scp,L2C1,#b2," Seconds"] 'Print text line 1 LCD SerOut GPIO.1,T9600,[I,scp,L2C1,#b2," Seconds"] 'Print text line 2 LCD b2=b2-1 'subtract 1 from from b2 Pause 1000 'Pause 1 second IF b2=0 Then boom GoTo countdown 'go to subroutine boom boom: SerOut GPIO.0,N9600,[I,clrlcd] 'Pin 7, clear lcd of previous stuff SerOut GPIO.1,T9600,[I,clrlcd] 'Pin 8, clear lcd of previous stuff SerOut GPIO.0,N9600,[I,scp,L1C1," Turn on"] 'Print text line 1 LCD SerOut GPIO.1,T9600,[I,scp,L1C1," Turn on"] 'Print text line 2 LCD SerOut GPIO.0,N9600,[I,scp,L2C1," LED 1"] 'Print text line 1 LCD SerOut GPIO.1,T9600,[I,scp,L2C1," LED 1"] 'Print text line 2 LCD High GPIO.2 'turn on LED at pin 5 Pause 3000 'pause 3 seconds GoTo START 'Goto start of program End