PDA

View Full Version : DEC to ASCII not working in HSEROUT



SunDanzer
- 12th July 2009, 03:08
I'm using an 18F4520 (i think) writing to an Orbital Matrix display over a serial port.

I can write characters fine, but the variable RPM displays 00000. RPM is declared as a WORD. I've tried a lot of variations, RPM as a Byte, IDec, SDec, Dec, Dec1, Dec2, etc, #RPM, but only 00000. Also the Shift command is not working. This may be a clue.

RPM = 100 ; RPM is a WORD
HSEROUT [$FE,$47,0,2,"RPM = ", DEC5 RPM]

Result >> RPM = 00000

I think the DEC is not converting the number to ASCII correctly. I also have a fair number of variables, maybe 100, and a few hundred lines of assembly in an include file to create timers and a software PWM.

These commands worked fine writing to an LCD using a parallel interface and the LCDOUT command. But since then, I expanded the assembly include file and added a few more variable.

Any ideas?

David B.

jmontse
- 12th July 2009, 19:30
Hello,
On Friday I was having a similar problem with the DEC5 and HSEROUT but I am not sure if is this "bug" or if my ADC was dead. Tomorrow I will check at work.

Now I tested in a 18F4680 at home:

Walue = 100 'also defined as word
HSEROUT [DEC5 Walue,10,13]

and the terminal shows "100" as expected, using PBPro, compling with MPLAB, so it seems to work fine.

By the way, aren't you mixing up the LCD commands with the HSEROUT?
$FE etc.. is used in the LCDOUT command, that has a different sintax than HSEROUT.

JM

Archangel
- 12th July 2009, 19:48
By the way, aren't you mixing up the LCD commands with the HSEROUT?
$FE etc.. is used in the LCDOUT command, that has a different sintax than HSEROUT.

JMHello JM, The $FE is probably a serial LCD command as is the $47 giving instruction to it as to where to place the "string" data, as opposed to being HSEROUT formatting.

jtowich
- 22nd July 2009, 06:11
Found the problem, has to do with configuration bits.

Although the extended instruction configuration bit is disabled by default, if this line is used to turn LVP off,

@ __CONFIG _CONFIG4L, _LVP_OFF_4L

the extended instruction bit will be set. So it has to be specifically turned off with this

@ __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L

or else there is very strange and inconsistent behavior. Problems were experienced with the DEC modifier in HSEROUT and with the shift (<<) commands.

Oddly, if the line

@ __CONFIG _CONFIG4L, _LVP_OFF_4L

is not used at all, the extended instruction bit remains disabled, as it should be by default.