Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Parity ODD

Status
Not open for further replies.
This works at setting the right address:
Code:
		movlw	kbdata
LoopT
		dcfsnz	kbdata
		goto	doneA
		tblrd	*+		;use TBLPTRU:TBLPTRH:TBLPTRL as 24-bit pointer to memory
		bra		LoopT
doneA:
		tblrd	*+		
		movf	TABLAT,w	;place value pointed to in W

But how would i make the table?

I have this there now:

Code:
MyTable:
    DB   ' '    ;0
    DB   ' '    ;1
    DB   ' '    ;2
    DB   ' '    ;3
    DB   ' '    ;4
    DB   ' '    ;5
    DB   ' '    ;6
    DB   '`'    ;7
    DB   ' '    ;8
    DB   ' '    ;9
    DB   ' '    ;A
    DB   '1'    ;B
    DB   ' '    ;C
    DB   'z'    ;D
    DB   'a'    ;E
    DB   '2'    ;F
    DB   ' '    ;10
    DB   'x'    ;11
    DB   'e'    ;12
    DB   '3'    ;13
    DB   ' '    ;14
    DB   'v'    ;15
    DB   't'    ;16
    DB   '5'    ;17
    DB   ' '    ;18
    DB   'b'    ;19
    DB   'g'    ;1A
    DB   '6'    ;1B
    DB   ' '    ;1C
    DB   'm'    ;1D
    DB   'u'    ;1E
    DB   '8'    ;1F
    DB   ' '    ;20
    DB   'k'    ;21
    DB   'o'    ;22
    DB   '9'    ;23
    DB   ' '    ;24
    DB   0x2F    ;25
    DB   ';'    ;26
    DB   '-'    ;27
    DB   ' '    ;28
    DB   0x27    ;29
    DB   '['    ;2A
    DB   ' '    ;2B
    DB   ' '    ;2C
    DB   ' '    ;2D
    DB   ' '    ;2E
    DB   ' '    ;2F
    DB   ' '    ;30
    DB   ' '    ;31
    DB   ' '    ;32
    DB   ' '    ;33
    DB   ' '    ;34
    DB   ' '    ;35
    DB   ' '    ;36
    DB   ' '    ;37
    DB   ' '    ;38
    DB   ' '    ;39
    DB   ' '    ;3A
    DB   ' '    ;3B
    DB   ' '    ;3C
    DB   ' '    ;3D
    DB   ' '    ;3E
    DB   ' '    ;3F
    DB   ' '    ;40
    DB   ' '    ;41
    DB   ' '    ;42
    DB   ' '    ;43
    DB   ' '    ;44
    DB   ' '    ;45
    DB   ' '    ;46
    DB   ' '    ;47
    DB   ' '    ;48
    DB   ' '    ;49
    DB   ' '    ;4A
    DB   ' '    ;4B
    DB   ' '    ;4C
    DB   ' '    ;4D
    DB   ' '    ;4E
    DB   ' '    ;4F
    DB   ' '    ;50
    DB   ' '    ;51
    DB   ' '    ;52
    DB   ' '    ;53
    DB   ' '    ;54
    DB   ' '    ;55
    DB   ' '    ;56
    DB   ' '    ;57
    DB   ' '    ;58
    DB   ' '    ;59
    DB   ' '    ;5A
    DB   ' '    ;5B
    DB   ' '    ;5C
    DB   ' '    ;5D
    DB   ' '    ;5E
    DB   ' '    ;5F
    DB   ' '    ;60
    DB   ' '    ;61
    DB   ' '    ;62
    DB   ' '    ;63
    DB   ' '    ;64
    DB   ' '    ;65
    DB   ' '    ;66
    DB   ' '    ;67
    DB   ' '    ;68
    DB   ' '    ;69
    DB   ' '    ;6A
    DB   ' '    ;6B
    DB   ' '    ;6C
    DB   ' '    ;6D
    DB   ' '    ;6E
    DB   ' '    ;6F
    DB   ' '    ;70
    DB   ' '    ;71
    DB   ' '    ;72
    DB   ' '    ;73
    DB   ' '    ;74
    DB   ' '    ;75
    DB   ' '    ;76
    DB   ' '    ;77
    DB   ' '    ;78
    DB   ' '    ;79
    DB   ' '    ;7A
    DB   ' '    ;7B
    DB   ' '    ;7C
    DB   ' '    ;7D
    DB   ' '    ;7E
    DB   ' '    ;7F
    DB   ' '    ;80
    DB   ' '    ;81
    DB   ' '    ;82
    DB   ' '    ;83
    DB   ' '    ;84
    DB   ' '    ;85
    DB   ' '    ;86
    DB   ' '    ;87
    DB   ' '    ;88
    DB   ' '    ;89
    DB   'q'    ;8A
    DB   ' '    ;8B
    DB   ' '    ;8C
    DB   's'    ;8D
    DB   'w'    ;8E
    DB   ' '    ;8F
    DB   'c'    ;90
    DB   'd'    ;91
    DB   '4'    ;92
    DB   ' '    ;93
    DB   ' '    ;94
    DB   'f'    ;95
    DB   'r'    ;96
    DB   ' '    ;97
    DB   'n'    ;98
    DB   'h'    ;99
    DB   'y'    ;9A
    DB   ' '    ;9B
    DB   ' '    ;9C
    DB   'j'    ;9D
    DB   '7'    ;9E
    DB   ' '    ;9F
    DB   ','    ;A0
    DB   'i'    ;A1
    DB   '0'    ;A2
    DB   ' '    ;A3
    DB   '.'    ;A4
    DB   'l'    ;A5
    DB   'p'    ;A6
    DB   ' '    ;A7
    DB   ' '    ;A8
    DB   ' '    ;A9
    DB   '='    ;AA
    DB   ' '    ;AB
    DB   ' '    ;AC
    DB   ']'    ;AD
    DB   0x5C   ;AE
    DB   ' '    ;AF
    DB   ' '    ;B0
    DB   ' '    ;B1
    DB   ' '    ;B2
    DB   ' '    ;B3
    DB   ' '    ;B4
    DB   ' '    ;B5
    DB   ' '    ;B6
    DB   ' '    ;B7
    DB   ' '    ;B8
    DB   ' '    ;B9
    DB   ' '    ;BA
    DB   ' '    ;BB
    DB   ' '    ;BC
    DB   ' '    ;BD
    DB   ' '    ;BE
    DB   ' '    ;BF
    DB   ' '    ;C0
    DB   ' '    ;C1
    DB   ' '    ;C2
    DB   ' '    ;C3
    DB   ' '    ;C4
    DB   ' '    ;C5
    DB   ' '    ;C6
    DB   ' '    ;C7
    DB   ' '    ;C8
    DB   ' '    ;C9
    DB   ' '    ;CA
    DB   ' '    ;CB
    DB   ' '    ;CC
    DB   ' '    ;CD
    DB   ' '    ;CE
    DB   ' '    ;CF
    DB   ' '    ;D0
    DB   ' '    ;D1
    DB   ' '    ;D2
    DB   ' '    ;D3
    DB   ' '    ;D4
    DB   ' '    ;D5
    DB   ' '    ;D6
    DB   ' '    ;D7
    DB   ' '    ;D8
    DB   ' '    ;D9
    DB   ' '    ;DA
    DB   ' '    ;DB
    DB   ' '    ;DC
    DB   ' '    ;DD
    DB   ' '    ;DE
    DB   ' '    ;DF
    DB   ' '    ;E0
    DB   ' '    ;E1
    DB   ' '    ;E2
    DB   ' '    ;E3
    DB   ' '    ;E4
    DB   ' '    ;E5
    DB   ' '    ;E6
    DB   ' '    ;E7
    DB   ' '    ;E8
    DB   ' '    ;E9
    DB   ' '    ;EA
    DB   ' '    ;EB
    DB   ' '    ;EC
    DB   ' '    ;ED
    DB   ' '    ;EE
    DB   ' '    ;EF
    DB   ' '    ;F0
    DB   ' '    ;F1
    DB   ' '    ;F2
    DB   ' '    ;F3
    DB   ' '    ;F4
    DB   ' '    ;F5
    DB   ' '    ;F6
    DB   ' '    ;F7
    DB   ' '    ;F8
    DB   ' '    ;F9
    DB   ' '    ;FA
    DB   ' '    ;FB
    DB   ' '    ;FC
    DB   ' '    ;FD
    DB   ' '    ;FE
    DB   ' '    ;FF
 

Attachments

  • esp01 May. 19.gif
    esp01 May. 19.gif
    77.2 KB · Views: 147
Last edited:
You're just retrieving one character at a time from the table?

Code:
;
        movlw   upper MyTable   ; TBLPTR = &MyTable + kbdata
        movwf   TBLPTRU         ;
        movlw   high MyTable    ;
        movwf   TBLPTRH         ;
        movlw   low MyTable     ;
        addwf   kbdata,W        ; add index, 0..255
        movwf   TBLPTRL         ;
        movlw   0               ; adjust for Carry
        addwfc  TBLPTRH,F       ;
        addwfc  TBLPTRU,F       ;
        tblrd*                  ; read into TABLAT
        movf    TABLAT,W        ; retrieve table char'
 
Yes its a KEYBOARD i just need 1 character at a time.

The above doesnt work. Now sure why tho. um.... Ill post my entire code again.

Code:
	LIST P=18F2525	;directive to define processor
	#include <P18F2525.INC>	;processor specific variable definitions


    CONFIG	OSC = INTIO67, WDT = OFF, LVP = OFF, XINST = OFF

#define kbt TRISC	
#define kb PORTC
#define kbl LATC
#define kb_dat 1
#define kb_clk 2


		CBLOCK	0x000
		d1
		d2
		d3
		count
		Xmit_Byte
		parity
		kbdata
		pntr
		somedata
		ENDC

CALC_PARITY MACRO ARG_BYTE
        SWAPF   ARG_BYTE, W 
        XORWF   ARG_BYTE, F 
        RRCF    ARG_BYTE, W 
        XORWF   ARG_BYTE, F 
        BTFSC   ARG_BYTE, 2 
        INCF    ARG_BYTE, F 
        ENDM

		ORG	0x0000
		bra Init
		ORG	0x0008
		bra HighInt	


Init:
	movlw	0x72
	movwf	OSCCON			;8 Mhz

	movlw	0x0F
	movwf	ADCON1			;All Digital

	bcf		kbt, kb_dat		;make kb data line ouput
	bcf		kbt, kb_clk		;make kb clock line ouput


	call	Delay100uS
	movlw	0xF4
	call	SendKB
	call	Delay100uS
	clrf	pntr
Main:
	call	GetKB

	bra		Main

GetKB:
    MOVLW   0x08                  ;set up to read 8 bits
    MOVWF   count
    CLRF    kbdata

    btfsc   kb, kb_clk
	bra		$-2
    btfss   kb, kb_clk
	bra	$-2
    btfsc   kb, kb_clk
	bra	$-2

MyByte: 
	;call	Delay10us

    btfss   kb, kb_dat
	bcf		kbdata,7
    btfsc   kb, kb_dat
	bsf		kbdata,7

    rrncf    kbdata, f

    btfss   kb, kb_clk
	bra	$-2
    btfsc   kb, kb_clk
	bra	$-2

    decfsz  count  , f         ;test if all done
	goto 	MyByte

	call	Delay40uS
	call	Delay40uS
	call	Delay40uS
	call	Delay40uS

	;movlw	0x70
	;cpfseq	kbdata
	;bra		$+4
	;goto	startget

	;movf	kbdata, W

		movlw	upper MyTable
		movwf	TBLPTRU
		movwf	high MyTable
		movwf	TBLPTRH
		movlw	low MyTable
		movwf	TBLPTRL
	
		;repeat the following lines as necessary
		movlw	kbdata
;LoopT
		;dcfsnz	kbdata
		;goto	doneA
		;tblrd	*+		;use TBLPTRU:TBLPTRH:TBLPTRL as 24-bit pointer to memory
		;bra		LoopT
;doneA:
;		tblrd	*+		
;		movf	TABLAT,w	;place value pointed to in W

        movlw   upper MyTable   ; TBLPTR = &MyTable + kbdata
        movwf   TBLPTRU         ;
        movlw   high MyTable    ;
        movwf   TBLPTRH         ;
        movlw   low MyTable     ;
        addwf   kbdata,W        ; add index, 0..255
        movwf   TBLPTRL         ;
        movlw   0               ; adjust for Carry
        addwfc  TBLPTRH,F       ;
        addwfc  TBLPTRU,F       ;
        tblrd*                  ; read into TABLAT
        movf    TABLAT,W        ; retrieve table char'

		movwf	kbdata

	movlw 	somedata ;set starting address of my table
	addwf	pntr,0
	movwf	FSR0L
	movf	kbdata, W
	movwf	INDF0
	incf 	pntr

	call	Delay300mS
    RETURN

SendKB:
	bcf		kbt, kb_dat
	bcf		kbt, kb_clk
	clrf	count

	movwf	Xmit_Byte
	movff	Xmit_Byte,parity

	movlw	0x08
	movwf	count
d_loop:
	rrcf	Xmit_Byte, 1
	btfss	STATUS, C
	call	SendZero
	btfsc	STATUS, C
	call	SendOne
	
	decfsz	count
	goto	d_loop

;ParityTest
	CALC_PARITY parity
	btfsc	parity,0
	call	SendZero
	btfss	parity,0
	call	SendOne

;StopBit
	call	SendOne

	bsf		kbt, kb_dat		;make kb data line input
	bsf		kbt, kb_clk		;make kb clock line input
	return

SendOne:
	bcf		kbl, kb_clk
	bsf		kbl, kb_dat
	call	Delay40uS
	bsf		kbl, kb_clk
	return
SendZero:
	bcf		kbl, kb_clk
	bcf		kbl, kb_dat
	call	Delay40uS
	bsf		kbl, kb_clk
	return
Delay300mS
	movlw	0xD1
	movwf	d1
	movlw	0x4F
	movwf	d2
	movlw	0x02
	movwf	d3
Delay300mS_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	$+6
	decfsz	d3, f
	goto	Delay300mS_0
	return

Delay10us
	movlw	0x10
	movwf	d1
Delay30us_0
	decfsz	d1, f
	goto	Delay30us_0
	nop
	return

Delay50mS
	movlw	0x1E
	movwf	d1
	movlw	0x4F
	movwf	d2
Delay50mS_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	Delay50mS_0
	goto	$+2
	nop
	return

	
Delay100uS
	movlw	0x41
	movwf	d1
Delay100uS_0
	decfsz	d1, f
	goto	Delay100uS_0
	return

Delay40uS
	movlw	0x19
	movwf	d1
Delay40uS_0
	decfsz	d1, f
	goto	Delay40uS_0
	return
Delay1S
	movlw	0x11
	movwf	d1
	movlw	0x5D
	movwf	d2
	movlw	0x05
	movwf	d3
Delay1S_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	$+6
	decfsz	d3, f
	goto	Delay1S_0
	return

HighInt:
	retfie	FAST

MyTable:
    DB   ' '    ;0
    DB   ' '    ;1
    DB   ' '    ;2
    DB   ' '    ;3
    DB   ' '    ;4
    DB   ' '    ;5
    DB   ' '    ;6
    DB   '`'    ;7
    DB   ' '    ;8
    DB   ' '    ;9
    DB   ' '    ;A
    DB   '1'    ;B
    DB   ' '    ;C
    DB   'z'    ;D
    DB   'a'    ;E
    DB   '2'    ;F
    DB   ' '    ;10
    DB   'x'    ;11
    DB   'e'    ;12
    DB   '3'    ;13
    DB   ' '    ;14
    DB   'v'    ;15
    DB   't'    ;16
    DB   '5'    ;17
    DB   ' '    ;18
    DB   'b'    ;19
    DB   'g'    ;1A
    DB   '6'    ;1B
    DB   ' '    ;1C
    DB   'm'    ;1D
    DB   'u'    ;1E
    DB   '8'    ;1F
    DB   ' '    ;20
    DB   'k'    ;21
    DB   'o'    ;22
    DB   '9'    ;23
    DB   ' '    ;24
    DB   0x2F    ;25
    DB   ';'    ;26
    DB   '-'    ;27
    DB   ' '    ;28
    DB   0x27    ;29
    DB   '['    ;2A
    DB   ' '    ;2B
    DB   ' '    ;2C
    DB   ' '    ;2D
    DB   ' '    ;2E
    DB   ' '    ;2F
    DB   ' '    ;30
    DB   ' '    ;31
    DB   ' '    ;32
    DB   ' '    ;33
    DB   ' '    ;34
    DB   ' '    ;35
    DB   ' '    ;36
    DB   ' '    ;37
    DB   ' '    ;38
    DB   ' '    ;39
    DB   ' '    ;3A
    DB   ' '    ;3B
    DB   ' '    ;3C
    DB   ' '    ;3D
    DB   ' '    ;3E
    DB   ' '    ;3F
    DB   ' '    ;40
    DB   ' '    ;41
    DB   ' '    ;42
    DB   ' '    ;43
    DB   ' '    ;44
    DB   ' '    ;45
    DB   ' '    ;46
    DB   ' '    ;47
    DB   ' '    ;48
    DB   ' '    ;49
    DB   ' '    ;4A
    DB   ' '    ;4B
    DB   ' '    ;4C
    DB   ' '    ;4D
    DB   ' '    ;4E
    DB   ' '    ;4F
    DB   ' '    ;50
    DB   ' '    ;51
    DB   ' '    ;52
    DB   ' '    ;53
    DB   ' '    ;54
    DB   ' '    ;55
    DB   ' '    ;56
    DB   ' '    ;57
    DB   ' '    ;58
    DB   ' '    ;59
    DB   ' '    ;5A
    DB   ' '    ;5B
    DB   ' '    ;5C
    DB   ' '    ;5D
    DB   ' '    ;5E
    DB   ' '    ;5F
    DB   ' '    ;60
    DB   ' '    ;61
    DB   ' '    ;62
    DB   ' '    ;63
    DB   ' '    ;64
    DB   ' '    ;65
    DB   ' '    ;66
    DB   ' '    ;67
    DB   ' '    ;68
    DB   ' '    ;69
    DB   ' '    ;6A
    DB   ' '    ;6B
    DB   ' '    ;6C
    DB   ' '    ;6D
    DB   ' '    ;6E
    DB   ' '    ;6F
    DB   ' '    ;70
    DB   ' '    ;71
    DB   ' '    ;72
    DB   ' '    ;73
    DB   ' '    ;74
    DB   ' '    ;75
    DB   ' '    ;76
    DB   ' '    ;77
    DB   ' '    ;78
    DB   ' '    ;79
    DB   ' '    ;7A
    DB   ' '    ;7B
    DB   ' '    ;7C
    DB   ' '    ;7D
    DB   ' '    ;7E
    DB   ' '    ;7F
    DB   ' '    ;80
    DB   ' '    ;81
    DB   ' '    ;82
    DB   ' '    ;83
    DB   ' '    ;84
    DB   ' '    ;85
    DB   ' '    ;86
    DB   ' '    ;87
    DB   ' '    ;88
    DB   ' '    ;89
    DB   'q'    ;8A
    DB   ' '    ;8B
    DB   ' '    ;8C
    DB   's'    ;8D
    DB   'w'    ;8E
    DB   ' '    ;8F
    DB   'c'    ;90
    DB   'd'    ;91
    DB   '4'    ;92
    DB   ' '    ;93
    DB   ' '    ;94
    DB   'f'    ;95
    DB   'r'    ;96
    DB   ' '    ;97
    DB   'n'    ;98
    DB   'h'    ;99
    DB   'y'    ;9A
    DB   ' '    ;9B
    DB   ' '    ;9C
    DB   'j'    ;9D
    DB   '7'    ;9E
    DB   ' '    ;9F
    DB   ','    ;A0
    DB   'i'    ;A1
    DB   '0'    ;A2
    DB   ' '    ;A3
    DB   '.'    ;A4
    DB   'l'    ;A5
    DB   'p'    ;A6
    DB   ' '    ;A7
    DB   ' '    ;A8
    DB   ' '    ;A9
    DB   '='    ;AA
    DB   ' '    ;AB
    DB   ' '    ;AC
    DB   ']'    ;AD
    DB   0x5C   ;AE
    DB   ' '    ;AF
    DB   ' '    ;B0
    DB   ' '    ;B1
    DB   ' '    ;B2
    DB   ' '    ;B3
    DB   ' '    ;B4
    DB   ' '    ;B5
    DB   ' '    ;B6
    DB   ' '    ;B7
    DB   ' '    ;B8
    DB   ' '    ;B9
    DB   ' '    ;BA
    DB   ' '    ;BB
    DB   ' '    ;BC
    DB   ' '    ;BD
    DB   ' '    ;BE
    DB   ' '    ;BF
    DB   ' '    ;C0
    DB   ' '    ;C1
    DB   ' '    ;C2
    DB   ' '    ;C3
    DB   ' '    ;C4
    DB   ' '    ;C5
    DB   ' '    ;C6
    DB   ' '    ;C7
    DB   ' '    ;C8
    DB   ' '    ;C9
    DB   ' '    ;CA
    DB   ' '    ;CB
    DB   ' '    ;CC
    DB   ' '    ;CD
    DB   ' '    ;CE
    DB   ' '    ;CF
    DB   ' '    ;D0
    DB   ' '    ;D1
    DB   ' '    ;D2
    DB   ' '    ;D3
    DB   ' '    ;D4
    DB   ' '    ;D5
    DB   ' '    ;D6
    DB   ' '    ;D7
    DB   ' '    ;D8
    DB   ' '    ;D9
    DB   ' '    ;DA
    DB   ' '    ;DB
    DB   ' '    ;DC
    DB   ' '    ;DD
    DB   ' '    ;DE
    DB   ' '    ;DF
    DB   ' '    ;E0
    DB   ' '    ;E1
    DB   ' '    ;E2
    DB   ' '    ;E3
    DB   ' '    ;E4
    DB   ' '    ;E5
    DB   ' '    ;E6
    DB   ' '    ;E7
    DB   ' '    ;E8
    DB   ' '    ;E9
    DB   ' '    ;EA
    DB   ' '    ;EB
    DB   ' '    ;EC
    DB   ' '    ;ED
    DB   ' '    ;EE
    DB   ' '    ;EF
    DB   ' '    ;F0
    DB   ' '    ;F1
    DB   ' '    ;F2
    DB   ' '    ;F3
    DB   ' '    ;F4
    DB   ' '    ;F5
    DB   ' '    ;F6
    DB   ' '    ;F7
    DB   ' '    ;F8
    DB   ' '    ;F9
    DB   ' '    ;FA
    DB   ' '    ;FB
    DB   ' '    ;FC
    DB   ' '    ;FD
    DB   ' '    ;FE
    DB   ' '    ;FF


		END
 
Works fine in the simulator for me. Here's what I simulated (below). With the 'kbdata' variable set to 0x01, WREG contains 0x11 at the end of the routine.

Code:
        movlw   upper MyTbl     ;
        movwf   TBLPTRU         ;
        movlw   high MyTbl      ;
        movwf   TBLPTRH         ;
        movlw   low MyTbl       ;
        addwf   kbdata,W        ;
        movwf   TBLPTRL         ;
        movlw   0               ;
        addwfc  TBLPTRH,F       ;
        addwfc  TBLPTRU,F       ;
        tblrd*                  ;
        movf    TABLAT,W        ;

MyTbl   db      0x10,0x11,0x12
 
oh i see its the comments lol and the lineup. This is the new table...

Code:
MyTable
    db ' ', ' ', ' ', ' ',  ' ',  ' ',  ' ',  '`',  ' ',  ' ',  ' ',  '1',  ' ',  'z',  'a',  '2',  ' ',  'x',   'e',   '3',  ' ',  'v',  't',  '5',  ' ',  'b',  'g',  '6', ' ', 'm', 'u', '8', ' ', 'k', 'o', '9', ' ', 0x2F, ';', '-', ' ', 0x27, '[', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',  ' ', 'q', ' ', ' ', 's', 'w', ' ', 'c', 'd', '4', ' ', ' ', 'f', 'r', ' ', 'n', 'h', 'y', ' ', ' ', 'j', '7', ' ', ',', 'i', '0', ' ', '.', 'l', 'p', ' ', ' ', ' ', '=', ' ', ' ', ']', 0x5C, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
 
You don't really have to put the whole table on one line but if you do use multiple lines then you should have an even number of bytes in each line to preserve the word alignment.

Sorry I wasn't clearer on that Jason...
 
ha ha lol this sux i might just do it in C.

If i press the 1 KEY its works 100% but if i press like a 9 or a j it doesnt work. Gives me a 0xFF.

EDIT:
just read that above post and works nice now!

Code:
MyTable
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', '`'
	db     ' ', ' '
	db     ' ', '1'
	db     ' ', 'z'
	db     'a', '2'
	db     ' ', 'x'
	db     'e', '3'
	db     ' ', 'v'
	db     't', '5'
	db     ' ', 'b'
	db     'g', '6'
	db     ' ', 'm'
	db     'u', '8'
	db     ' ', 'k'
	db     'o', '9'
	db     ' ', 0x2F
	db     ';', '-'
	db     ' ', 0x27
	db     '[', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     'q', ' '
	db     ' ', 's'
	db     'w', ' '
	db     'c', 'd'
	db     '4', ' '
	db     ' ', 'f'
	db     'r', ' '
	db     'n', 'h'
	db     'y', ' '
	db     ' ', 'j'
	db     '7', ' '
	db     ',', 'i'
	db     '0', ' '
	db     '.', 'l'
	db     'p', ' '
	db     ' ', ' '
	db     '=', ' '
	db     ' ', ']'
	db     0x5C, ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' '
 
Last edited:
im turning the shift key into a 1 time cap lock type button and turning the cap lock into cap lock lol. the rest of the keys might not be used except for F1-F12 and ESC
 
PRESS THE HQ button

Thanks again mike look at this:

[embed]http://www.youtube.com/v/c41l4z4nHjw[/embed]

and here is the code complete with LCD interface. When i say complete i mean usable but still needs more of the keys added. Like Delete and all non letters and space and characters that are ASCII. So all ASCII are done and the rest excluding space are undone.
Code:
	LIST P=18F2525	;directive to define processor
	#include <P18F2525.INC>	;processor specific variable definitions


    CONFIG	OSC = INTIO67, WDT = OFF, LVP = OFF, XINST = OFF

#define kbt TRISC	
#define kb PORTC
#define kbl LATC
#define kb_dat 1
#define kb_clk 2

#define LCDt TRISB
#define LCD LATB
#define RS	4
#define Et	5

;///////////////////////////////////////////
;//	Variables
;///////////////////////////////////////////
		CBLOCK	0x000
		d1
		d2
		d3
		count
		Xmit_Byte
		parity
		kbdata
		pntr
		somedata
		ENDC
;///////////////////////////////////////////
;// Calculate Parity Bit Macro
;///////////////////////////////////////////
CALC_PARITY MACRO ARG_BYTE
        SWAPF   ARG_BYTE, W 
        XORWF   ARG_BYTE, F 
        RRCF    ARG_BYTE, W 
        XORWF   ARG_BYTE, F 
        BTFSC   ARG_BYTE, 2 
        INCF    ARG_BYTE, F 
        ENDM

		ORG	0x0000
		bra Init
		ORG	0x0008
		bra HighInt	
;///////////////////////////////////////////
;//	Convert keyboard data to ASCII Table
;///////////////////////////////////////////
MyTable
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', '`'
	db     ' ', ' '
	db     ' ', '1'
	db     ' ', 'z'
	db     'a', '2'
	db     ' ', 'x'
	db     'e', '3'
	db     ' ', 'v'
	db     't', '5'
	db     ' ', 'b'
	db     'g', '6'
	db     ' ', 'm'
	db     'u', '8'
	db     ' ', 'k'
	db     'o', '9'
	db     ' ', 0x2F
	db     ';', '-'
	db     ' ', 0x27
	db     '[', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     'q', ' '
	db     ' ', 's'
	db     'w', ' '
	db     'c', 'd'
	db     '4', ' '
	db     ' ', 'f'
	db     'r', ' '
	db     'n', 'h'
	db     'y', ' '
	db     ' ', 'j'
	db     '7', ' '
	db     ',', 'i'
	db     '0', ' '
	db     '.', 'l'
	db     'p', ' '
	db     ' ', ' '
	db     '=', ' '
	db     ' ', ']'
	db     0x5C, ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' ', ' '
	db     ' '
;///////////////////////////////////////////
;//	Toggle E
;///////////////////////////////////////////
ToggleE:
	bsf		LCD, Et
	call	Delay10us
	bcf		LCD, Et
	return
;///////////////////////////////////////////
;//	Send Command 2 Nybbles
;///////////////////////////////////////////
lcd_cmd:
	movwf	d2

	andlw	0xF0
	movwf	d1
	swapf	d1		;Upper
	
	movf	d2, W
	andlw	0x0F	;Lower
	movwf	d2

	movf	d1,W
	movwf	LCD
	bcf		LCD,RS
	call	ToggleE
	call	Delay10us

	movf	d2,W
	movwf	LCD
	bcf		LCD,RS
	call	ToggleE
	call	Delay10us
	return
;///////////////////////////////////////////
;//	Send Character 2 Nybbles
;///////////////////////////////////////////
lcd_char:
	movwf	d2

	andlw	0xF0
	movwf	d1
	swapf	d1		;Upper
	
	movf	d2, W
	andlw	0x0F	;Lower
	movwf	d2

	movf	d1,W
	movwf	LCD
	bsf		LCD,RS
	call	ToggleE
	call	Delay10us

	movf	d2,W
	movwf	LCD
	bsf		LCD,RS
	call	ToggleE
	call	Delay10us

	bcf		LCD,RS
	return
;///////////////////////////////////////////
;//	Initialize LCD
;///////////////////////////////////////////
InitLCD:
	clrf	LCDt
	bcf		LCD, RS

	call	Delay20mS
	movlw	0x03
	movwf	LCD
	call	ToggleE		;	movlw	0x03

	call	Delay2mS
	call	Delay2mS
	call	Delay2mS

	call	ToggleE		;	movlw	0x03

	call	Delay2mS
	call	Delay2mS
	call	Delay2mS

	call	ToggleE		;	movlw	0x03

	call	Delay2mS
	call	Delay2mS
	call	Delay2mS

	movlw	0x02		
	movwf	LCD

	call	ToggleE		;	movlw	0x02

	call	Delay2mS
	call	Delay2mS

	movlw	0x28
	call	lcd_cmd
	call	Delay2mS
	call	Delay2mS

	movlw	0x10
	call	lcd_cmd
	call	Delay2mS
	call	Delay2mS

	movlw	0x06
	call	lcd_cmd
	call	Delay2mS
	call	Delay2mS

	movlw	0x0f;C
	call	lcd_cmd
	call	Delay2mS
	call	Delay2mS

	movlw	0x01
	call	lcd_cmd
	call	Delay2mS
	call	Delay2mS
	return
;///////////////////////////////////////////
;//	LCD Line 1/2
;///////////////////////////////////////////
LineOne:
	movlw	0x80
	call	lcd_cmd
	call	Delay2mS
	return
LineTwo:
	movlw	0xC0
	call	lcd_cmd
	call	Delay2mS
	return
;///////////////////////////////////////////
;//	Initialize Main
;///////////////////////////////////////////
Init:
	movlw	0x72
	movwf	OSCCON			;8 Mhz

	movlw	0x0F
	movwf	ADCON1			;All Digital

	bcf		kbt, kb_dat		;make kb data line ouput
	bcf		kbt, kb_clk		;make kb clock line ouput

	call	InitLCD
	call	Delay2mS
	call	LineOne

	call	Delay100uS
	movlw	0xF4
	call	SendKB
	call	Delay100uS
	clrf	pntr
;///////////////////////////////////////////
;//	Main
;///////////////////////////////////////////
Main:
	call	GetKB
	bra		Main
;///////////////////////////////////////////
;//	Get Data From KB
;///////////////////////////////////////////
GetKB:
    MOVLW   0x08                  ;set up to read 8 bits
    MOVWF   count
    CLRF    kbdata

    btfsc   kb, kb_clk
	bra		$-2
    btfss   kb, kb_clk
	bra	$-2
    btfsc   kb, kb_clk
	bra	$-2

MyByte: 
	;call	Delay10us

    btfss   kb, kb_dat
	bcf		kbdata,7
    btfsc   kb, kb_dat
	bsf		kbdata,7

    rrncf    kbdata, f

    btfss   kb, kb_clk
	bra	$-2
    btfsc   kb, kb_clk
	bra	$-2

    decfsz  count  , f         ;test if all done
	goto 	MyByte

	call	Delay40uS
	call	Delay40uS
	call	Delay40uS
	call	Delay40uS

    movlw   upper MyTable   ; TBLPTR = &MyTable + kbdata
    movwf   TBLPTRU         ;
    movlw   high MyTable    ;
    movwf   TBLPTRH         ;
    movlw   low MyTable     ;
    addwf   kbdata,W        ; add index, 0..255
    movwf   TBLPTRL         ;
    movlw   0               ; adjust for Carry
    addwfc  TBLPTRH,F       ;
    addwfc  TBLPTRU,F       ;
	TBLRD*
	MOVF 	TABLAT, W 

	movwf	kbdata
;///////////////////////////////////////////
;//	Below was a test to save collected data
;///////////////////////////////////////////
;	movlw 	somedata ;set starting address of my table
;	addwf	pntr,0
;	movwf	FSR0L
;	movf	kbdata, W
;	movwf	INDF0
;	incf 	pntr

	movf	kbdata,W
	call	lcd_char

	call	Delay300mS
	call	Delay500mS
    RETURN
;///////////////////////////////////////////
;//	Send Data to KB
;///////////////////////////////////////////
SendKB:
	bcf		kbt, kb_dat
	bcf		kbt, kb_clk
	clrf	count

	movwf	Xmit_Byte
	movff	Xmit_Byte,parity

	movlw	0x08
	movwf	count
d_loop:
	rrcf	Xmit_Byte, 1
	btfss	STATUS, C
	call	SendZero
	btfsc	STATUS, C
	call	SendOne
	
	decfsz	count
	goto	d_loop

;ParityTest
	CALC_PARITY parity
	btfsc	parity,0
	call	SendZero
	btfss	parity,0
	call	SendOne

;StopBit
	call	SendOne

	bsf		kbt, kb_dat		;make kb data line input
	bsf		kbt, kb_clk		;make kb clock line input
	return

SendOne:
	bcf		kbl, kb_clk
	bsf		kbl, kb_dat
	call	Delay40uS
	bsf		kbl, kb_clk
	return
SendZero:
	bcf		kbl, kb_clk
	bcf		kbl, kb_dat
	call	Delay40uS
	bsf		kbl, kb_clk
	return
;///////////////////////////////////////////
;//	Delays Below
;///////////////////////////////////////////
;///////////
;// 300mS
;///////////
Delay300mS
	movlw	0xD1
	movwf	d1
	movlw	0x4F
	movwf	d2
	movlw	0x02
	movwf	d3
Delay300mS_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	$+6
	decfsz	d3, f
	goto	Delay300mS_0
	return
;///////////
;// 500mS
;///////////
Delay500mS
	movlw	0x07
	movwf	d1
	movlw	0x2F
	movwf	d2
	movlw	0x03
	movwf	d3
Delay500mS_0
	decfsz	d1, f
	goto	$+4
	decfsz	d2, f
	goto	$+4
	decfsz	d3, f
	goto	Delay500mS_0
	goto	$+2
	goto	$+2
	goto	$+2
	return

;///////////
;// 10uS
;///////////
Delay10us
	movlw	0x10
	movwf	d1
Delay30us_0
	decfsz	d1, f
	goto	Delay30us_0
	nop
	return
;///////////
;// 50mS
;///////////
Delay50mS
	movlw	0x1E
	movwf	d1
	movlw	0x4F
	movwf	d2
Delay50mS_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	Delay50mS_0
	goto	$+2
	nop
	return

;///////////
;// 100uS
;///////////
Delay100uS
	movlw	0x41
	movwf	d1
Delay100uS_0
	decfsz	d1, f
	goto	Delay100uS_0
	return
;///////////
;// 1mS
;///////////
Delay1mS
	movlw	0x8E
	movwf	d1
	movlw	0x02
	movwf	d2
Delay1mS_0
	decfsz	d1, f
	goto	$+4
	decfsz	d2, f
	goto	Delay1mS_0
	goto	$+2
	nop
	return
;///////////
;// 2mS
;///////////
Delay2mS
	movlw	0x1E
	movwf	d1
	movlw	0x04
	movwf	d2
Delay2mS_0
	decfsz	d1, f
	goto	$+4
	decfsz	d2, f
	goto	Delay2mS_0
	goto	$+2
	nop
	return
;///////////
;// 20mS
;///////////
Delay20mS
	movlw	0x3E
	movwf	d1
	movlw	0x20
	movwf	d2
Delay20mS_0
	decfsz	d1, f
	goto	$+4
	decfsz	d2, f
	goto	Delay20mS_0
	goto	$+2
	nop
	return

;///////////
;// 40uS
;///////////
Delay40uS
	movlw	0x19
	movwf	d1
Delay40uS_0
	decfsz	d1, f
	goto	Delay40uS_0
	return
;///////////
;// 1 Sec.
;///////////
Delay1S
	movlw	0x11
	movwf	d1
	movlw	0x5D
	movwf	d2
	movlw	0x05
	movwf	d3
Delay1S_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	$+6
	decfsz	d3, f
	goto	Delay1S_0
	return

HighInt:
	retfie	FAST

		END
 
Last edited:
Here is some C code. Its more into it. Im not sure if the keyboards you use output different data. so if so you have to alter this yourself. This works well for now. Ill post the new video in about 10 min.

Code:
/* *****************************************************************************
;                                                                             *
;    Filename:                     				                              *
;    Date:                                         	                          *
;    File Version: 001                                                        *
;                                                                             *
;    Author:   Jason Lopez                                                    *
;    Company:  AtomSoft                                                       *
;                                                                             *
;***************************************************************************** */

#include <p18f2525.h>
#include <delays.h>
#include <string.h>

#pragma config WDT = OFF, LVP = OFF, OSC = INTIO67, XINST = OFF

/************************************
Prototypes
*************************************/
void main(void);
void LCDString(rom unsigned char *str);
void InitLCD(void);
void LCDLine(unsigned char line);
void SendLCD(unsigned char dat,unsigned char RSV);
void ToggleE(void);

unsigned char GetKey(void);
/************************************
Variables and Defines
*************************************/
	unsigned char tempKey;
	unsigned char a2z[104];
	unsigned char shiftcap;

	unsigned char count;
 	 unsigned char kbdata;
//Keyboard Defines
	#define kbt_d	TRISCbits.TRISC1
	#define kbt_c	TRISCbits.TRISC2

	#define kb_dr	PORTCbits.RC1
	#define kb_dw	LATCbits.LATC1

	#define kb_cr	PORTCbits.RC2
	#define kb_cw	LATCbits.LATC2

//LCD Defines
	#define LCDt	TRISB
	#define LCD		PORTB
	#define RS		LATBbits.LATB4
	#define ET		LATBbits.LATB5

/************************************
Main
*************************************/
void main(void){

	OSCCON = 0x72;      			//8MHz clock
	while(!OSCCONbits.IOFS);		//wait for osc stable

	kbt_d = 1;		//Keyboard Data Tris is INPUT
	kbt_c = 1;		//Keyboard Clock Tris is INPUT

	InitLCD();
	LCDString((rom unsigned char*)"AtomSoftTech.");
	LCDLine(2);
	//LCDString((rom unsigned char*)"Keyboard Test");

	//a2zi = 0;
	while(1){
		tempKey = GetKey();
		if(tempKey >= 0x20) 
			if(tempKey <= 0x7E){
				if(shiftcap >= 1){
					 if(tempKey > 0x60)
						if(tempKey < 0x7B)
							tempKey -= 0x20;
					if(shiftcap == 1)
						shiftcap = 0;
				}

				SendLCD(tempKey,1);
			}

		if(tempKey == 0x08){
			SendLCD(0x10,0);
			Delay1KTCYx(16);

			SendLCD(0x20,1);
			Delay1KTCYx(16);

			SendLCD(0x10,0);
			Delay1KTCYx(16);
		}
			
		//a2z[a2zi++] = tempKey;
		Delay10KTCYx(90); 		//500mS
	}
}
/* ***********************************
Keyboard Stuff
************************************ */
unsigned char GetKey(void){
	char redo;
	redo = 0;
	kbdata = 0;
	count = 8;
GetKB:
_asm

A:
     btfsc   PORTC, 2,0
	bra		A
B:
    btfss   PORTC, 2,0
	bra		B
C:
    btfsc   PORTC, 2,0
	bra		C

MyByte: 

    btfss   PORTC, 1,0
	bcf		kbdata,7,1
    btfsc   PORTC, 1,0
	bsf		kbdata,7,1

    rrncf    kbdata, 1,1
D:
    btfss   PORTC, 2,0
	bra		D
E:
    btfsc   PORTC, 2,0
	bra		E

    decfsz  count  , 1,1      
	bra 	MyByte

_endasm	

Delay10TCYx(70); 		//Delay 320uS aka 2 clocks(bits)

	//return tmp;
	switch(kbdata){
        case 0x00:
            return ' ';
        case 0x01:
            return ' ';
        case 0x02:
            return ' ';
        case 0x03:
            return ' ';
        case 0x04:
            return ' ';
        case 0x05:
            return ' ';
        case 0x06:
            return ' ';
        case 0x07:
			if(shiftcap==1)
            	return '~';
			else
            	return '`';
        case 0x08:
            return ' ';
        case 0x09:
            shiftcap = 1;
            return 0x09;
        case 0x0A:
            return 'q';
        case 0x0B:
			if(shiftcap==1)
            	return '!';
			else
            	return '1';
        case 0x0C:
            return ' ';
        case 0x0D:
            return 'z';
        case 0x0E:
            return 'a';
        case 0x0F:
			if(shiftcap==1)
            	return '@';
			else
            	return '2';
        case 0x10:
            return ' ';
        case 0x11:
            return 'x';
        case 0x12:
            return 'e';
        case 0x13:
			if(shiftcap==1)
            	return '#';
			else
            	return '3';
        case 0x14:
            return ' ';
        case 0x15:
            return 'v';
        case 0x16:
            return 't';
        case 0x17:
			if(shiftcap==1)
            	return '%';
			else
            	return '5';
        case 0x18:
            return ' ';
        case 0x19:
            return 'b';
        case 0x1A:
            return 'g';
        case 0x1B:
			if(shiftcap==1)
            	return '^';
			else
            	return '6';
        case 0x1C:
            return ' ';
        case 0x1D:
            return 'm';
        case 0x1E:
            return 'u';
        case 0x1F:
			if(shiftcap==1)
            	return '*';
			else
            	return '8';
        case 0x20:
            return ' ';
        case 0x21:
            return 'k';
        case 0x22:
            return 'o';
        case 0x23:
			if(shiftcap==1)
            	return '(';
			else
            	return '9';
        case 0x24:
            return ' ';
        case 0x25:
			if(shiftcap==1)
            	return '?';
			else
            	return '/';
        case 0x26:
			if(shiftcap==1)
            	return ':';
			else
            	return ';';
        case 0x27:
			if(shiftcap==1)
            	return '_';
			else
            	return '-';
        case 0x28:
            return ' ';
        case 0x29:
            return 0x27;
        case 0x2A:
			if(shiftcap==1)
            	return '{';
			else
            	return '[';
        case 0x2B:
            return ' ';
        case 0x2C:
			if(shiftcap == 2)
				shiftcap = 0;
			else
				shiftcap = 2;
            return 0x09;
        case 0x2D:
            return 0x0A;
        case 0x2E:
            return ' ';
        case 0x2F:
            return ' ';
        case 0x30:
            return ' ';
        case 0x31:
            return ' ';
        case 0x32:
            return ' ';
        case 0x33:
            return 0x08;
        case 0x34:
            return ' ';
        case 0x35:
            return ' ';
        case 0x36:
            return ' ';
        case 0x37:
            return ' ';
        case 0x38:
            return ' ';
        case 0x39:
            return ' ';
        case 0x3A:
            return ' ';
        case 0x3B:
            return 0x1B;
        case 0x3C:
            return ' ';
        case 0x3D:
            return ' ';
        case 0x3E:
            return ' ';
        case 0x3F:
            return ' ';
        case 0x40:
            return ' ';
        case 0x41:
            return ' ';
        case 0x42:
            return ' ';
        case 0x43:
            return ' ';
        case 0x44:
            return ' ';
        case 0x45:
            return ' ';
        case 0x46:
            return ' ';
        case 0x47:
            return ' ';
        case 0x48:
            return ' ';
        case 0x49:
            return ' ';
        case 0x4A:
            return ' ';
        case 0x4B:
            return ' ';
        case 0x4C:
            return ' ';
        case 0x4D:
            return ' ';
        case 0x4E:
            return ' ';
        case 0x4F:
            return ' ';
        case 0x50:
            return ' ';
        case 0x51:
            return ' ';
        case 0x52:
            return ' ';
        case 0x53:
            return ' ';
        case 0x54:
            return ' ';
        case 0x55:
            return ' ';
        case 0x56:
            return ' ';
        case 0x57:
            return ' ';
        case 0x58:
            return ' ';
        case 0x59:
            return ' ';
        case 0x5A:
            return ' ';
        case 0x5B:
            return ' ';
        case 0x5C:
            return ' ';
        case 0x5D:
            return ' ';
        case 0x5E:
            return ' ';
        case 0x5F:
            return ' ';
        case 0x60:
            return ' ';
        case 0x61:
            return ' ';
        case 0x62:
            return ' ';
        case 0x63:
            return ' ';
        case 0x64:
            return ' ';
        case 0x65:
            return ' ';
        case 0x66:
            return ' ';
        case 0x67:
            return ' ';
        case 0x68:
            return ' ';
        case 0x69:
            return ' ';
        case 0x6A:
            return ' ';
        case 0x6B:
            return ' ';
        case 0x6C:
            return ' ';
        case 0x6D:
            return ' ';
        case 0x6E:
            return ' ';
        case 0x6F:
            return ' ';
        case 0x70:
            return ' ';
        case 0x71:
            return ' ';
        case 0x72:
            return ' ';
        case 0x73:
            return ' ';
        case 0x74:
            return ' ';
        case 0x75:
            return ' ';
        case 0x76:
            return ' ';
        case 0x77:
            return ' ';
        case 0x78:
            return '3';
        case 0x79:
            return ' ';
        case 0x7A:
            return ' ';
        case 0x7B:
            return ' ';
        case 0x7C:
            return ' ';
        case 0x7D:
            return ' ';
        case 0x7E:
            return ' ';
        case 0x7F:
            return ' ';
        case 0x80:
            return ' ';
        case 0x81:
            return ' ';
        case 0x82:
            return ' ';
        case 0x83:
            return ' ';
        case 0x84:
            return ' ';
        case 0x85:
            return ' ';
        case 0x86:
            return 0x09;
        case 0x87:
            return ' ';
        case 0x88:
            return ' ';
        case 0x89:
            return ' ';
        case 0x8A:
            return 'q';
        case 0x8B:
            return ' ';
        case 0x8C:
            return ' ';
        case 0x8D:
            return 's';
        case 0x8E:
            return 'w';
        case 0x8F:
            return ' ';
        case 0x90:
            return 'c';
        case 0x91:
            return 'd';
        case 0x92:
			if(shiftcap==1)
            	return '$';
			else
            	return '4';
        case 0x93:
            return ' ';
        case 0x94:
            return ' ';
        case 0x95:
            return 'f';
        case 0x96:
            return 'r';
        case 0x97:
            return ' ';
        case 0x98:
            return 'n';
        case 0x99:
            return 'h';
        case 0x9A:
            return 'y';
        case 0x9B:
            return ' ';
        case 0x9C:
            return ' ';
        case 0x9D:
            return 'j';
        case 0x9E:
			if(shiftcap==1)
            	return '&';
			else
            	return '7';
        case 0x9F:
            return ' ';
        case 0xA0:
			if(shiftcap==1)
            	return '<';
			else
            	return ',';
        case 0xA1:
            return 'i';
        case 0xA2:
			if(shiftcap==1)
            	return ')';
			else
            	return '0';
        case 0xA3:
            return ' ';
        case 0xA4:
			if(shiftcap==1)
            	return '>';
			else
            	return '.';
        case 0xA5:
            return 'l';
        case 0xA6:
            return 'p';
        case 0xA7:
            return ' ';
        case 0xA8:
            return ' ';
        case 0xA9:
            return ' ';
        case 0xAA:
			if(shiftcap==1)
            	return '+';
			else
            	return '=';
        case 0xAB:
            return ' ';
        case 0xAC:
            shiftcap = 1;
            return 0x09;
        case 0xAD:
			if(shiftcap==1)
            	return '}';
			else
            	return ']';
        case 0xAE:
			if(shiftcap==1)
            	return '|';
			else
            	return 0x5C;
        case 0xAF:
            return ' ';
        case 0xB0:
            return ' ';
        case 0xB1:
            return ' ';
        case 0xB2:
            return ' ';
        case 0xB3:
            return ' ';
        case 0xB4:
            return ' ';
        case 0xB5:
            return ' ';
        case 0xB6:
            return ' ';
        case 0xB7:
            return ' ';
        case 0xB8:
            return ' ';
        case 0xB9:
            return ' ';
        case 0xBA:
            return ' ';
        case 0xBB:
            return ' ';
        case 0xBC:
            return ' ';
        case 0xBD:
            return ' ';
        case 0xBE:
            return ' ';
        case 0xBF:
            return ' ';
        case 0xC0:
            return ' ';
        case 0xC1:
            return ' ';
        case 0xC2:
            return ' ';
        case 0xC3:
            return ' ';
        case 0xC4:
            return ' ';
        case 0xC5:
            return ' ';
        case 0xC6:
            return ' ';
        case 0xC7:
            return ' ';
        case 0xC8:
            return ' ';
        case 0xC9:
            return ' ';
        case 0xCA:
            return ' ';
        case 0xCB:
            return ' ';
        case 0xCC:
            return ' ';
        case 0xCD:
            return ' ';
        case 0xCE:
            return ' ';
        case 0xCF:
            return ' ';
        case 0xD0:
            return ' ';
        case 0xD1:
            return ' ';
        case 0xD2:
            return ' ';
        case 0xD3:
            return ' ';
        case 0xD4:
            return ' ';
        case 0xD5:
            return ' ';
        case 0xD6:
            return ' ';
        case 0xD7:
            return ' ';
        case 0xD8:
            return ' ';
        case 0xD9:
            return ' ';
        case 0xDA:
            return ' ';
        case 0xDB:
            return ' ';
        case 0xDC:
            return ' ';
        case 0xDD:
            return ' ';
        case 0xDE:
            return ' ';
        case 0xDF:
            return ' ';
        case 0xE0:
            return ' ';
        case 0xE1:
            return ' ';
        case 0xE2:
            return ' ';
        case 0xE3:
            return ' ';
        case 0xE4:
            return ' ';
        case 0xE5:
            return ' ';
        case 0xE6:
            return ' ';
        case 0xE7:
            return ' ';
        case 0xE8:
            return ' ';
        case 0xE9:
            return ' ';
        case 0xEA:
            return ' ';
        case 0xEB:
            return ' ';
        case 0xEC:
            return ' ';
        case 0xED:
            return ' ';
        case 0xEE:
            return ' ';
        case 0xEF:
            return ' ';
        case 0xF0:
            return ' ';
        case 0xF1:
            return ' ';
        case 0xF2:
            return ' ';
        case 0xF3:
            return ' ';
        case 0xF4:
            return ' ';
        case 0xF5:
            return ' ';
        case 0xF6:
            return ' ';
        case 0xF7:
            return ' ';
        case 0xF8:
            return ' ';
        case 0xF9:
            return ' ';
        case 0xFA:
            return ' ';
        case 0xFB:
            return ' ';
        case 0xFC:
            return ' ';
        case 0xFD:
            return ' ';
        case 0xFE:
            return ' ';
        case 0xFF:
            return ' ';
	}
	return ' ';
}
/* ***********************************
LCD Stuff
************************************ */
void LCDString(rom unsigned char *str){
	while(*str != 0)
		SendLCD(*str++,1);
}
void InitLCD(void){
	LCDt = 0x00;
	RS = 0;
	Delay10KTCYx(4);	//Delay 40000 TCY aka 20mS

	LCD = 0x03;
	ToggleE();
	Delay10KTCYx(1);	//Delay 10000 TCY aka 5mS

	ToggleE();
	Delay10KTCYx(1);	//Delay 10000 TCY aka 5mS

	ToggleE();
	Delay10KTCYx(1);	//Delay 10000 TCY aka 5mS
	Delay1KTCYx(2);		//Delay 2000 TCY aka 1mS  // Total = 6mS

	LCD = 0x02;
	ToggleE();
	Delay1KTCYx(8);		//Delay 8000 TCY aka 4mS

	SendLCD(0x28,0);	//Data = 0x28, RS = 0 (command mode)
	Delay1KTCYx(8);		//Delay 8000 TCY aka 4mS

	SendLCD(0x10,0);	//Data = 0x10, RS = 0 (command mode)
	Delay1KTCYx(8);		//Delay 8000 TCY aka 4mS

	SendLCD(0x06,0);	//Data = 0x06, RS = 0 (command mode)
	Delay1KTCYx(8);		//Delay 8000 TCY aka 4mS

	SendLCD(0x0F,0);	//Data = 0x0F, RS = 0 (command mode)
	Delay1KTCYx(8);		//Delay 8000 TCY aka 4mS

	SendLCD(0x01,0);	//Data = 0x01, RS = 0 (command mode)
	Delay1KTCYx(8);		//Delay 8000 TCY aka 4mS
}
void LCDLine(unsigned char line){
	if(line == 1)
		SendLCD(0x80,0);

	if(line == 2)
		SendLCD(0xC0,0);
}
void SendLCD(unsigned char dat,unsigned char RSV){
	char cmdHi;
	char cmdLo;

	cmdHi = dat >> 4;
	cmdLo = dat & 0x0F;

	LCD = cmdHi;
	RS = RSV;
	ToggleE();

	Delay10TCYx(2); 		//10uS Delay

	LCD = cmdLo;
	RS = RSV;
	ToggleE();
}
void ToggleE(void){
	ET = 1;
	Delay10TCYx(2); 		//10uS Delay
	ET = 0;
}
 
Nice, just gotta make a command parser for it now.
 
Well you can echo text to the LCD now, so what, what're you gonna do with the text? You need a command line parser, that can take commands and data and do something with them. Once you get to that point by the way be careful, command line parsers are a little tricky if you don't do propery boundary testing on your data to make sure it's valid all sorts of weird things can go wrong. It's a lot of really boring coding, but you may be able to find some example code out there for C.
 
Last edited:
Ill figure it out. Ill make sure to make a max variable size limit so i dont overflow. I wanted to do this mainly for a signboard i want to make in the future . I wanted the option of editing the data VIA LCD/GLCD and Normal Keyboard. This way it doesnt need a PC and can be altered in place.
 
This may sound dum but would not the sign really be no more then a big LCD. I have seen them that print out as you type.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top