In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Mike_W wrote:
[3]I have been working on displaying word variables and I am having trouble with this Hex counter. It only displays two digits the right most digit counts (0 - F) as I expected but the left most digit only advances every 256 counts. I cannot get it to display four digits. What am I missing. [/3]
[3] [/3]
[3] Mike W[/3]
[3][/3]
[3][/3]
DEVICE SX28, OSCXT2, TURBO, STACKX, OPTIONX
FREQ 4_000_000
' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------
Lcdout VAR RA.0 ' output to Parallax LCD
' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------
LcdBaud CON "T19200" ' or T2400, or T9600
LcdCls CON $0C ' clear LCD (need 5 ms delay)
LcdCR CON $0D ' move pos 0 of next line
LcdOn1 CON $16 ' LCD on; no crsr, no blink
LcdLine0Pos0 CON $80 ' move to line 0, position 0
LcdLine1Pos0 CON $94 ' move to line 1, position 0
' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
temp1 VAR Byte
counter VAR Word
wTemp1 VAR Word
wTemp2 VAR Word
wTemp3 VAR Word
wTemp4 VAR Word
' -------------------------------------------------------------------------
' Subroutine DECLARATIONS
' -------------------------------------------------------------------------
GET_HEX SUB 1, 3 ' print using HEXx format
LCD_OUT SUB 1, 2 ' send to LCD
' =========================================================================
' Program Data
' =========================================================================
PROGRAM Start
' =========================================================================
' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------
Start:
PLP_A = %0001 ' pull up unused pins
PLP_B = %00000000
PLP_C = %00000000
HIGH Lcdout ' make lcd output pin high
pause 100 ' let LCD initialize
LCD_OUT LcdCls
LCD_OUT LcdOn1
pause 5
Main:
for counter = 0 to 65535
if counter = 65535 then
end
endif
LCD_OUT LcdLine1Pos0
GET_HEX counter, 4
pause 250
next
goto Main
' -------------------------------------------------------------------------
' Subroutines / Jump Table
' -------------------------------------------------------------------------
LCD_OUT:
temp1 = __PARAM1 ' digit to send
SEROUT Lcdout, LCDBaud, temp1 ' send the digitacter
RETURN
' -------------------------------------------------------------------------
GET_HEX:
wTemp2 = __WPARAM12 ' copy output value
IF __PARAMCNT = 2 THEN
IF __WPARAM23 = 1 THEN Low_Nib
ENDIF
SWAP wTemp2 ' move high nib
wTemp3 = wTemp2 & $0F ' make pointer
READ Hex_Digit + wTemp3, wTemp1 ' get NIB1 digit
LCD_OUT wTemp1 ' print it
SWAP wTemp2 ' restore low nib
Low_Nib:
wTemp3 = wTemp2 & $0F ' make digit pointer
READ Hex_Digit + wTemp3, wTemp1 ' get NIB0 digit
LCD_OUT wTemp1 ' print it
RETURN
' =========================================================================
Hex_Digit:
WDATA "0123456789ABCDEF"
' -------------------------------------------------------------------------
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=156322
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)