Here is the original code someone wrote, and it used the ser out.
I want to change this to a 4 bit output, that I can latch into a 4-bit latch, or another picaxe chip awaiting data from it.
I know I need to change the SERTXD instruction to another table operation, to use C.0 - C.3 outputs, and the C.4 output as a strobe to signal a valid data byte to the receiving component... BUT... I am not sure exactly how to do this without using some really long and inefficient code...
What needs to be changed here to do so, and is this the most efficient use of memory space to do so??
This is a really good learning experience, so I thank you all in advance!!!
The code is as follows -
What needs to be added and changed to make this a parallel output?? Adding comments to the lines will help me learn what you did, and why and how it works...
Thanks for your help everyone... I am on a fast learning curve, and I am really loving this!!!
Best regards to all...
Kim
I want to change this to a 4 bit output, that I can latch into a 4-bit latch, or another picaxe chip awaiting data from it.
I know I need to change the SERTXD instruction to another table operation, to use C.0 - C.3 outputs, and the C.4 output as a strobe to signal a valid data byte to the receiving component... BUT... I am not sure exactly how to do this without using some really long and inefficient code...
What needs to be changed here to do so, and is this the most efficient use of memory space to do so??
This is a really good learning experience, so I thank you all in advance!!!
The code is as follows -
Code:
**************************************************************************************
#Picaxe 20X2
#Terminal 38400
#No_Data
'
' I want to change from this:
'
'
'
'.........................20X2
'........................--__--.
'.......................|+V 0V|
'.......................|SI SO|----------------------> TXD
'.......................|C7 B0|<------------
'.......................|C6 B1|<---------. |
'.......................|C5 B2|----> * * * * 1x1 through 4x4
'.......................|C4 B3|----> * * * * Matrix Keypad
'.......................|C3 B4|----> * * * * No Diodes
'.......................|C2 B5|----> * * * * No Resistors
'.......................|C1 B6|<-----' |
'.......................|C0 B7|<--------'
'......................`------'
'
'
'
' To THIS:
'
'
'........................20X2
'........................--__--.
'.......................|+V 0V|
'.......................|SI SO|
'.......................|C7 B0|<-----------.
'.......................|C6 B1|<---------. |
'.......................|C5 B2|----> * * * * 1x1 through 4x4
'...Data Valid<== |C4 B3|----> * * * * Matrix Keypad
'.............B3<== |C3 B4|----> * * * * No Diodes
'.............B2<== |C2 B5|----> * * * * No Resistors
'.............B1<== |C1 B6|<-----' |
'.............B0<== |C0 B7|<-------'
'......................`------'
'
'
'
'
Symbol DIR_X = %00111100
Symbol MSK_X = %11000011
Symbol XOR_X = MSK_X
Symbol DIR_1 = %00100000
Symbol MSK_1 = MSK_X
Symbol XOR_1 = MSK_X | DIR_1
Symbol DIR_2 = %00010000
Symbol MSK_2 = MSK_X
Symbol XOR_2 = MSK_X | DIR_2
Symbol DIR_3 = %00001000
Symbol MSK_3 = MSK_X
Symbol XOR_3 = MSK_X | DIR_3
Symbol DIR_4 = %00000100
Symbol MSK_4 = MSK_X
Symbol XOR_4 = MSK_X | DIR_4
Symbol keyPress = b2
Symbol lastKeyPress = b3
; =====================================================================================
SetFreq M32
PullUp %11011000
lastKeyPress = $FF
Do
Gosub ReadKeyPress
ReadTable keyPress, keyPress
If keyPress <> lastKeyPress Then
lastKeyPress = keyPress
SerTxd ( "Key = ", #keyPress, CR, LF ) ' ?? This needs to be changed to a sub routine... but how do I do this??
Pause 40
End If
Loop
ReadKeyPress:
dirsB = DIR_X
keyPress = MSK_X & pinsB ^ XOR_X
If keyPress <> 0 Then
dirsB = DIR_1
keyPress = MSK_1 & pinsB ^ XOR_1
If keyPress <> DIR_1 Then : Return : End If
dirsB = DIR_2
keyPress = MSK_2 & pinsB ^ XOR_2
If keyPress <> DIR_2 Then : Return : End If
dirsB = DIR_3
keyPress = MSK_3 & pinsB ^ XOR_3
If keyPress <> DIR_3 Then : Return : End If
dirsB = DIR_4
keyPress = MSK_4 & pinsB ^ XOR_4
If keyPress <> DIR_4 Then : Return : End If
End If
keyPress = 0
Return
Table %00000000, ( 0 )
Table %00000101, ( 1 )
Table %00000110, ( 2 )
Table %00000111, ( 17 )
Table %01000100, ( 3 )
Table %01000101, ( 18 )
Table %01000110, ( 19 )
Table %01000111, ( 20 )
Table %10000100, ( 4 )
Table %10000101, ( 21 )
Table %10000110, ( 22 )
Table %10000111, ( 23 )
Table %11000100, ( 24 )
Table %11000101, ( 25 )
Table %11000110, ( 26 )
Table %11000111, ( 27 )
Table %00001001, ( 5 )
Table %00001010, ( 6 )
Table %00001011, ( 28 )
Table %01001000, ( 7 )
Table %01001001, ( 29 )
Table %01001010, ( 30 )
Table %01001011, ( 31 )
Table %10001000, ( 8 )
Table %10001001, ( 32 )
Table %10001010, ( 33 )
Table %10001011, ( 34 )
Table %11001000, ( 35 )
Table %11001001, ( 36 )
Table %11001010, ( 37 )
Table %11001011, ( 38 )
Table %00010001, ( 9 )
Table %00010010, ( 10 )
Table %00010011, ( 39 )
Table %01010000, ( 11 )
Table %01010001, ( 40 )
Table %01010010, ( 41 )
Table %01010011, ( 42 )
Table %10010000, ( 12 )
Table %10010001, ( 43 )
Table %10010010, ( 44 )
Table %10010011, ( 45 )
Table %11010000, ( 46 )
Table %11010001, ( 47 )
Table %11010010, ( 48 )
Table %11010011, ( 49 )
Table %00100001, ( 13 )
Table %00100010, ( 14 )
Table %00100011, ( 50 )
Table %01100000, ( 15 )
Table %01100001, ( 51 )
Table %01100010, ( 52 )
Table %01100011, ( 53 )
Table %10100000, ( 16 )
Table %10100001, ( 54 )
Table %10100010, ( 55 )
Table %10100011, ( 56 )
Table %11100000, ( 57 )
Table %11100001, ( 58 )
Table %11100010, ( 59 )
Table %11100011, ( 60 )
**************************************************************************************
Thanks for your help everyone... I am on a fast learning curve, and I am really loving this!!!
Best regards to all...
Kim
Last edited by a moderator: