and of course, the code for the pic 16F84A that is to be clocked at 4MHz to
achieve 2400 baud with 15ms character pacing.
The program is compiled with Microengineering Labs Pic BASIC Pro,
and outputs infinite test messages:
" Variable = 0 Variable = 1 Variable = 3.... and so on"
This is what I have reliably achieved on the PSP screen.
The pic program can also drive a 3x7 segment LED display array so you
can view the test variable on LED screen, but it isn't required that any
displays be connected.
Connect the blue wire from your PSP remote controller plug to gnd of the pic circuit,
and the grey wire from the PSP remote via 470 Ohm resistor to port RB0 of the pic circuit
Code: Select all
'
''''''''''''''''''''''''''''''''''''''''''''''
' Multiplexed 3x7 Segment LED Display Driver / PSP Serial port tester '
'                                            '
'         Art           '
''''''''''''''''''''''''''''''''''''''''''''''
'
trisa = 0				'set all ports as outputs
trisb = 0				'
trisa.0 = 1				'now set individual inputs
trisa.4 = 1				'
trisb.0 = 1				'
'
OPTION_REG = %00100000			'put timer module in counting mode
'
include "modedefs.bas"
DEFINE CHAR_PACING 15000			'
'
delay var byte				'
D1 var byte				'display buffers
D2 var byte				'
D3 var byte				'
DB var byte				'display digit buffer
B1 var byte				'
B2 var byte				'
B3 var byte				'
B4 var byte				'
B5 var byte				'
B6 var byte				'
B7 var byte				'
B8 var byte				'
B9 var byte				'
B0 var byte				'
C2 var word				'
M1 var word
'
M1 = 0
@ goto _testA				'skip interrupt handler
'
cnt:
'
Three_dig:
'
DB = D1
low porta.2
gosub digit
high porta.2
DB = D2
low porta.3
gosub digit
high porta.3
DB = D3
low porta.1
gosub digit
high porta.1
return
'
digit:
@            MOVF    _DB      , W
@            SUBLW   0x00
@            BTFSS   STATUS    , Z
@            GOTO    _Label_0016
@            MOVLW   0x80
@            MOVWF   _DB
Label_0016:
@            MOVF    _DB      , W
@            SUBLW   0x01
@            BTFSS   STATUS    , Z
@            GOTO    _Label_0017
@            MOVLW   0xE6
@            MOVWF   _DB
Label_0017:
@            MOVF    _DB      , W
@            SUBLW   0x02
@            BTFSS   STATUS    , Z
@            GOTO    _Label_0018
@            MOVLW   0x48
@            MOVWF   _DB
Label_0018:
@            MOVF    _DB      , W
@            SUBLW   0x03
@            BTFSS   STATUS    , Z
@            GOTO    _Label_0019
@            MOVLW   0x42
@            MOVWF   _DB
Label_0019:
@            MOVF    _DB      , W
@            SUBLW   0x04
@            BTFSS   STATUS    , Z
@            GOTO    _Label_001A
@            MOVLW   0x26
@            MOVWF   _DB
Label_001A:
@            MOVF    _DB      , W
@            SUBLW   0x05
@            BTFSS   STATUS    , Z
@            GOTO    _Label_001B
@            MOVLW   0x12
@            MOVWF   _DB
Label_001B:
@            MOVF    _DB      , W
@            SUBLW   0x06
@            BTFSS   STATUS    , Z
@            GOTO    _Label_001C
@            MOVLW   0x10
@            MOVWF   _DB
Label_001C:
@            MOVF    _DB      , W
@            SUBLW   0x07
@            BTFSS   STATUS    , Z
@            GOTO    _Label_001D
@            MOVLW   0xC6
@            MOVWF   _DB
Label_001D:
@            MOVF    _DB      , W
@            SUBLW   0x08
@            BTFSS   STATUS    , Z
@            GOTO    _Label_001E
@            CLRF    _DB
Label_001E:
@            MOVF    _DB      , W
@            SUBLW   0x09
@            BTFSS   STATUS    , Z
@            GOTO    _Label_001F
@            MOVLW   0x02
@            MOVWF   _DB
Label_001F:
portb = DB
'
pauseus 2200
portb = $FF
'
'
'
return
'
'***************************************************************************************************************
'
testA:
delay = 5
C2 = 0
'
test:
low porta.2
gosub segments
high porta.2
low porta.3
gosub segments
high porta.3
low porta.1
gosub segments
high porta.1
low porta.4
gosub segments
high porta.4
delay = delay - 1
IF delay = 255 THEN
INTCON = %10010000			'turn on interrupt when display test is done
goto start
ENDIF
goto test
segments:
high portb.1
pause delay
high portb.2
pause delay
high portb.3
pause delay
high portb.4
pause delay
high portb.5
pause delay
high portb.6
pause delay
high portb.7
pause delay
low portb.1
pause delay
low portb.2
pause delay
low portb.3
pause delay
low portb.4
pause delay
low portb.5
pause delay
low portb.6
pause delay
low portb.7
pause delay
return
'
'***************************************************************************************************************
'
start:
D1 = 0
D2 = 0
D3 = 0
'
FOR delay = 0 TO 90			'Hold 000 on display at startup
gosub Three_dig
NEXT delay
'goto cnt
'
'***************************************************************************************************************
'
Dog:
M1 = M1 + 1
D1 = M1 DIG 0				'
D2 = M1 DIG 1				'
D3 = M1 DIG 2				'
FOR delay = 0 TO 75			'Hold display
gosub Three_dig
NEXT delay
serout portb.0,OT2400,[" Variable = ",#M1]    ' 2400 baud true
goto Dog				'
disp:
D1 = C2 DIG 0				'
D2 = C2 DIG 1				'
D3 = C2 DIG 2				'
FOR delay = 0 TO 100			'Hold display
gosub Three_dig
NEXT delay
return
And here's the hex code so you don't need to own the compiler to test the circuit:
Code: Select all
:10000000AC28910190009F1727308F0010301420EA
:1000100003308F00E83014208F01643014208F01EA
:100020000A30142010081F288E0011088D001008B7
:100030008C008B200C08031D9F139F1B0800303E73
:100040009200220884000930930003103020920CA3
:10005000930B2628031430203A308D0098306D28F9
:1000600084139F1D3F28000820041F1D20068000C8
:10007000841700082004031C200680004A2800087A
:100080002004031C20061F19200680008417200965
:1000900080054A281F0D06398C0053208D008C0ADC
:1000A000532000006D2800308A000C0882070134BC
:1000B00075340334153400343C340C34D9348F0196
:1000C0008E00FF308E07031C8F07031CA728033008
:1000D0008D00DF306D2061288D01E83E8C008D0998
:1000E000FC30031C76288C07031873288C076400E7
:1000F0008D0F73280C187C288C1C80280000802809
:100100000800013E93000A308E008F018B20930B74
:1001100086281008080091019001103092000D0D02
:10012000900D910D0E0890020F08031C0F0F910205
:100130000318A1280E0890070F0803180F0F910746
:1001400003108C0D8D0D920B8F280C08A72883139C
:1001500003138312640008008316850186010514C9
:1001600005160614203081008312A601A7011E295E
:100170003208B5000511831605118312DA20051522
:100180008316051183123308B50085118316851176
:100190008312DA2085158316851183123408B50081
:1001A0008510831685108312DA2085148316851036
:1001B000831208003508003C031DE0288030B5009C
:1001C0003508013C031DE628E630B5003508023C41
:1001D000031DEC284830B5003508033C031DF22808
:1001E0004230B5003508043C031DF8282630B50020
:1001F0003508053C031DFE281230B5003508063CC5
:10020000031D04291030B5003508073C031D0A29D9
:10021000C630B5003508083C031D0F29B501350867
:10022000093C031D15290230B50035088600083049
:100230008D0098306D20FF30860008000530B60034
:10024000A401A5010511831605118312502105157E
:10025000831605118312851183168511831250218F
:1002600085158316851183128510831685108312D8
:1002700050218514831685108312051283160512EA
:10028000831250210516831605128312B6036400EB
:100290003608FF3C031D4F2990308B00A5292229E9
:1002A000861483168610831236085F20061583167F
:1002B0000611831236085F20861583168611831275
:1002C00036085F20061683160612831236085F2052
:1002D000861683168612831236085F200617831649
:1002E0000613831236085F2086178316861383123F
:1002F00036085F20861083168610831236085F202A
:10030000061183160611831236085F2086118316A4
:100310008611831236085F20061283160612831296
:1003200036085F20861283168612831236085F20F5
:10033000061383160613831236085F20861383166E
:100340008613831236085F200800B201B301B4019E
:10035000B60164005B3036020318B129B820B60F2D
:10036000A929A60A0319A70A26088C0027088D00C8
:1003700000308120B20026088C0027088D00013053
:100380008120B30026088C0027088D0002308120D0
:10039000B400B60164004C3036020318D229B820EC
:1003A000B60FCA290630A2000130A00008309F0015
:1003B0002030202056302020613020207230202034
:1003C0006930202061302020623020206C302020D5
:1003D00065302020203020203D302020203020207B
:1003E0002708910026080220B12924088C0025083E
:1003F0008D0000308120B20024088C0025088D007B
:1004000001308120B30024088C0025088D000230C3
:100410008120B400B6016400653036020318132A47
:08042000B820B60F0B2A0800FA
:02400E00F53F7C
:00000001FF
I am releasing this because I intend to take it further.
I will shortly biuld a smaller circuit without the display
for the purpose of serial level/timing conversion between the
PSP and other devices (particularly GPS).
Cheers, Art.
Cheers, Art.