I need a help from members,to help me show me how i can use at/ps2 keyboard to enter text or data to the eeprom memory of the pic16f877a ,the code is attached and it works very fine for led sign display i was using pc to enter the text,
****************
DEFINE OSC 10 ' Oscillator speed in MHz: 3(3.58) 4 8 10 12 16 20 25 32 33 40
Include "modedefs.bas" ' Include serial modes
@ DEVICE PIC16F877A,HS_OSC,WDT_OFF,PWRT_ON,LVP_OFF,BOD_OFF
CMCON = 7
ADCON1 = 7
TRISB = 0 ' Setup PortB = outputs module selection data
TRISD = 0 ' Setup PortD = outputs the data word and address of module
TRISA.2 = 0 : TRISA.1 = 0 : TRISA.0 = 0
databits var PORTA.2 ' clock signal for the character segment data IC
addsbits var PORTA.1 ' clock signal for the char. segment address data IC
modsbits var PORTA.0 ' clock signal for the module select IC
Addss VAR BYTE[8] ' 8-byte address array
Mods VAR BYTE[8] ' 8-byte address array
Datas var byte[64]' array to keep the ever changing character segments
loops con 2 ' number of frame loops, for flicker-free effect
columns con 63 ' columns + 1 = number of columns on the display, starts from 0 to 63 = 64
module con 8 ' number of modules and columns on modules 8 x 8, indicates when to go to next module and when to start from beginning of module
EOM con "" ' Character used as "End of Message" marker
SPA con $D ' Character used as "End of Message" marker
character_segment VAR BYTE ' data word for LED matrix
column_select VAR BYTE ' variable that keeps track if one module length was exceeded
module_select VAR BYTE ' variable that keeps track of which module should be activated
i VAR BYTE ' for loop pointer
iTMP var byte ' points to the char. segment that will start out the new scroll
char var byte ' points to the char. that will be seperated into segments for display
charTMP var byte ' points to the char that will start out the new scroll
ColumnAddress VAR BYTE ' pointer that indexes which column in module is to be addressed
LoopDisplay var byte ' pointer that indexes how many times the screen has been looped
char2disp var byte ' variable that gets the character to display
NEWcharflag var byte ' indicates that new char. needs to be displayed on start of next refresh
message var byte ' stores how many columns have been taken up by message, scrolling message will = 63, message shorter than the lenght of sigh <= 62.
displayme var word ' pause between each lighting of LEDs, in microseconds
''''' S T O R E A D D R E S S S E Q U E N C E S IN A R R A Y S ''''''''
FOR i = 0 TO 7
' LOOKUP i,[$01,$02,$04,$08,$10,$20,$40,$80],module_select 'used with NPN transistors
LOOKUP i,[$FE,$FD,$FB,$F7,$EF,$DF,$BF,$7F],module_select 'used with MIC5801 ICs & DM74ALS574 ICs
Mods[i] = module_select ' Load all 8 addresses into array
LOOKUP i,[$10,$20,$40,$80,$01,$02,$04,$08],column_select
Addss[i] = column_select ' Load all 8 addresses into array
NEXT i
''''' S T O R E C H A R A C T E R S E G M E N T S I N A R R A Y ''''''
start: ' very start of the whole loop, this point will reset all variabled, and will start on a clean start
char = 0 : charTMP = 0 : i = 0 : iTMP = 0 : NEWcharflag = 0 : 'reset all necessary variables
message = columns
MoveDataByOneColumn: 'the data display stars here
i = iTMP : char = charTMP 'set the character segment and character to start out the display with
NEWcharflag = 0 'reset the flag which indicates to start out with new character when the display stars scrolling
FOR ColumnAddress = 0 TO columns 'store max. no. of segments in the data array, which is 64
READ char,char2disp 'read a character from the eeprom memory
'check if the character from the eeprom memory is a lower/upper case char. or a number or a special char.
'then grab its' segment data from the 4 lookup tables containing all character
If (char2disp >= "A") and (char2disp <= "Z") then
goto UPPERcase
endif
If (char2disp >= "a") and (char2disp <= "z") then
goto LOWERcase
else
goto OTHERcase
endif
'done checking the character format, and grabbing its' segment values
donecharacterlookup: 'done looking up the character data
IF character_segment = EOM THEN 'check to see if end of character
character_segment = $FF 'yes, so replace it with a blank, so there is a blank after each character
char = char + 1 'increment pointer to next character in message
i = 0 'reset index pointer that points to which char. segment to display
if (ColumnAddress = 0) then 'check to see if this is the first time we're looping, we do not want to do this 64 times!
charTMP = charTMP + 1 'increment the character pointer to next character, the next time the screen displays
iTMP = 0 'reset index pointer that points which char. segment to display, next time the screen displays
NEWcharflag = 1 'set a flag which indicates that new character must be displayed next time the screen displays
endif 'end if
else 'no, not the end of character
i = i + 1 'increment pointer to the next char. segment of the character displaying
endif 'done checking character segments
Datas[ColumnAddress] = character_segment 'store the segment in the character segment array
NEXT ColumnAddress 'do this 64 times to fill up the whole character segment array
if NEWcharflag = 0 then 'check to see if the 'new character' flag was set
iTMP = iTMP + 1 'no, so increment the pointer to point to new char. segment of character, next time the screen displays
endif 'done incrementing pointer of character segments
goto startDISPLAY
fillDISPLAY:
iTMP = 0 : charTMP = 0 : NEWcharflag = 0 ': GOTO MoveDataByOneColumn
message = ColumnAddress 'store the message lenght to calculate the refresh rate later on
for i = ColumnAddress TO columns 'fill up the data array with blanks if message is shorter than the length of the SIGN
Datas[i] = $FF 'if message is shorter then the lenght of the SIGN, fill up rest of the columns with blanks
next i
Bookmarks