skip navigational linksPJRC
Shopping Cart Download Website
Home Products Teensy Blog Forum
You are here: 8051 Tools PAULMON Monitor Manual Built-In Functions

PJRC Store
8051 Board, $79
LCD 128x64 Pixel, $29
LCD 16x2 Char, $14
Serial Cable, $5
9 Volt Power, $6
More Components...
8051 Tools
Main Page
Software
PAULMON Monitor
Development Board
Code Library
89C2051 Programmer
Other Resources

Using PAULMON2's Built-In Functions

PAULMON2 has built-in functions which you can call from your programs. Most of these functions provide I/O with the serial port. To use these, you should copy lines from the PAULMON2.EQU file.
cout
Print the byte in Acc to the serial port.
cin
Get a character from the serial port. This routine will wait until a character arrives, if one is not already in the buffer. The received character is returned in Acc.
cin_filter
Works like cin, but also attempts to identify the multi-byte escape sequences used by some of the keys on the PC keyboard. When one of these multi-byte sequences is "seen", only a single translated character is returned. Complex timing loops which automatically scale with the baud rate are used, so that the ESC key is detected properly.
Key Return Value Escape Sequence
Up 11 (^K) 1B 5B 41
Down 10 (^J) 1B 5B 42
Right 21 (^U) 1B 5B 43
Left 8 (^H) 1B 5B 44
Page Up 25 (^Y) 1B 5B 35 7E
Page Down 26 (^Z) 1B 5B 36 7E
phex
Print the value of Acc as a 2-digit Hex number
phex16
Print the value of DPTR as a 4-digit Hex number
pstr
Print a string, which is located in CODE memory. DPTR should be loaded with the address of the first byte of the string. The string should be terminated with a zero (which is not sent), or a byte with the most significant bit set (which is send, with the msb cleared). DPTR is returned with it's value pointing to the next byte in memory after the end of the string.
phex1
Print a single digit in HEX. Acc should contain a value from 0 to 15.
asc2hex
Converts an ascii character ('0' to '9' or 'A' to 'F') into a number which is returned in Acc. If the value passed in Acc is not one of the 16 legal characters, the Carry is set, otherwise it is cleared. This function will not accept lowercase characters, so upper should be called first if lowercase letters should be handled.
ghex
Get a 2-digit HEX number from the serial port, which is returned in Acc. If the user presses ESC, C is set (clear otherwise) and Acc is unknown. If the user presses Enter with no input, PSW.5 is set (clear otherwise), and Acc is unknown. R2 and R3 are changed.
ghex16
Get a 4-digit HEX number from the serial port, which is returned in DPTR. If the user presses ESC, C is set (clear otherwise) and DPTR is unknown. If the user presses Enter with no input, PSW.5 is set (clear otherwise), and DPTR is unknown. Acc, R2, R3, R4, and R5 are changed.
esc
Checks to see if <ESC> is waiting on serial port C=clear if no <ESC>, C=set if <ESC> pressed buffer is flushed
upper
Convert the character in Acc to uppercase, if it is a lowercase letter. If a non-alpha character is in Acc, it is not changed.
autobaud
Do an automatic baud rate detection (wait for user to press Enter)
pcstr
Print a string in compressed format. The format of the on-the-fly string compression used in PAULMON2 is not documented, unfortunately.
newline
Print a carriage return and a newline to the serial port.
lenstr
Measure the length of a string, which is located in CODE memory. DPTR should be loaded with the address of the first byte of the string. The string should be terminated as described above in pstr. DPTR is returned with it's value pointing to the next byte in memory after the end of the string. The length of the string is returned in R0. Obviously strings longer than 255 characters can't be measured, but pstr should handle long strings without trouble.
pint8u
Print the value in Acc as an unsigned (ordinary base 10) integer. In other words, a number between 0 to 255 will be printed. Flag F0 is changed.
pint8
Print the value in Acc as a signed (ordinary base 10) integer. In other words, a number between -128 to 127 will be printed. Flag F0 is changed.
pint16u
Print the value in DPTR as an unsigned (ordinary base 10) integer. In other words, a number between 0 to 65535 will be printed. Registers R2, R3, R4, R5, and flag PSW.5 are changed.
smart_wr
Attempt to write a byte in Acc to memory at location specified by DPTR. If PAULMON2 is configured for a Flash ROM, and the specified memory location is in the Flash ROM, then smart_wr will call prgm so that the byte is written with the flash programming algorithm. Carry is cleared if the byte was written sucessfully, or set if the byte could not be verified.
prgm
Write a byte in Acc to Flash ROM at DPTR. Carry is cleared if the byte was written sucessfully, or set if the byte could not be verified. Interrupts are disabled for brief periods of time.
erall
Erase the Flash ROM. This can time quite some time.
find
Find a program header in memory. This function is unfortunately not well documented.
PAULMON2 contains a table of jump instructions located immediately after the interrupt vectors. The symbols defined in PAULMON2.EQU are the locations of these jump instructions. These locations should be used, rather than figuring out where the code is actually located within PAULMON2, because the actual code addresses may change in the future if PAULMON2 is upgraded. The locations within the jump table will not be changed, to maintain compatibility with existing code.

Many other useful bits of code may be found in the Code Library which are not available within PAULMON2.


PAULMON2 Documentation, Paul Stoffregen
http://www.pjrc.com/tech/8051/pm2_docs/functions.html
Last updated: February 24, 2005
Status: This page could use a bit more work
Suggestions, comments, bug reports??? <paul@pjrc.com>