OK, I think I've got it all turned around the right way now. 
And there's some options to flip it around different ways if it's not, so hopefully this should do it.
I was asking about the USART, because it's possible to use it in Sychronous mode to drive the display really fast, but it only sends data LSB first so I needed to reverse the bit order in case you want to use it. But for now, let's stick with SHIFTOUT.
Note: You MUST be assembling with MPASM. The default PM.exe will not work.<hr>
There are 8 modes that are selectable at any time.
Simply set the variable NKKmode to the mode number and update the display.
See the mode examples in post #2. <hr>
There are 5 commands for use with the NKK display.
NKKclear - clears the screen
NKKtext - write Text at a specified location
NKKbyte - display a BYTE variable
NKKword - display a WORD variable
NKKupdate - Update the Display
<hr>
NKKclearThis will clear the screen buffer in memory.
Code:
@ NKKclear ; clear the NKK screen buffer
You must call NKKupdate for the changes to be seen.
NKKtext (row, col, "Text")Displays a string of text at the specified location.
Code:
@ NKKtext (1,1,"RPM:")
Above code displays
RPM: at Row1 Column1.
The end of each row wraps to the beginning of the next row. So you can actually fill the entire display with 1 command of 40 chars.
Code:
@ NKKtext (1,1,"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ=%$&")
NKKbyte (row, col, width, justification, Variable) Displays a BYTE variable in a fixed width field, with leading zero blanking and left or right justification.
Code:
@ NKKbyte (1,3,3,right,ByteVar)
The line above would display the value in
ByteVar at Row1 Column3.
The field size is 3 characters, and it will be Right justified with leading 0's blanked.
Justification can be
LEFT, RIGHT or ZEROS. Zeros will
NOT blank the leading 0's.
NKKword (row, col, width, justification, Variable)Displays a WORD variable in a fixed width field, with leading zero blanking and left or right justification.
Code:
@ NKKword (2,2,4,right,RPM) ; Display RPM
The line above would display the WORD value in
RPM at Row2 Column2.
The field width is 4 characters, right jusified.
Justification can be
LEFT, RIGHT or ZEROS. Zeros will
NOT blank the leading 0's.
NKKupdate - Update the Display This command does most of the work. It actually sends the screen to the display.
The other commands only work on the character buffer.
After they are done changing the buffer, call this to see them displayed.
Code:
@ NKKupdate ; Send data to the display
<hr>
There are 2 options available
NKK_LSBFIRSTThis option reverses the bit order of each byte being sent.
This would be useful when using the USART's synchronous mode.
If using SHIFTOUT or the MSSP module. Do not use this option, and send all data MSB first.
Code:
DEFINE NKK_LSBFIRST
NKK_REVERSED - Scans Left to RightThis option makes a mirror image of the display.
It's mainly there for me to debug with HyperTerminal.
Code:
DEFINE NKK_REVERSED
<hr>
This is a test program that I believe you should start with.
You will need to fill in the NKKstartData: and NKKsendByte: subroutines with SHIFTOUT statements to interface with your display.
Just follow the comments.
Code:
RPM VAR WORD
IPS VAR WORD
INCLUDE "NKK.pbp"
Initialize:
NKKmode = 6 ; 4x5 mode
@ NKKclear ; clear the NKK screen buffer
@ NKKtext (1,1,"RPM:") ; row 1, column 1
@ NKKtext (3,1,"IPS:") ; row 3, column 1
@ NKKtext (4,2,"0.") ; row 4, column 2
;----[ The Main Loop ]------------------------------------------------------
Main:
@ NKKword (2,2,4,right,RPM) ; Display RPM
@ NKKword (4,4,2,zeros,IPS) ; Display IPS
@ NKKupdate ; Send data to the display
RPM = RPM + 10
IPS = IPS + 2
PAUSE 1000
GOTO Main
;----[ Send Command to start Display Data Transfer ]------------------------
NKKstartData:
; *** this subroutine should send the $55 command ***
RETURN
;----[ Send 1 byte to the NKK display ]-------------------------------------
NKKsendByte:
; *** this subroutine should send one byte at a time ***
; *** The byte to send is in the variable OutByte ***
; *** Send the data MSB first ***
RETURN
You'll also need to turn on the backlight yourself.
If all goes well, it should look something like this.
<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3139" /><!--
-->
Download the NKK.pbp file below, and remove the .txt extension.
Place it in your PBP folder. Usually c:\PBP. Or you can put it in the same folder as your main program file.
The whole thing compiles to about 1400 words on a 16F, or 2600 bytes on an 18F.
Good Luck!
Bookmarks