DATA {@Location,}Constant{,Constant...}

Store constants in on-chip non-volatile EEPROM when the device is first programmed. If the optional Location value is omitted, the first DATA statement starts storing at address 0 and subsequent statements store at the following locations. If the Location value is specified, it denotes the starting location where these values are stored. An optional label can be assigned to the starting EEPROM address for later reference by the program.

Constant can be a numeric constant or a string constant. Only the least significant byte of numeric values are stored unless the WORD modifier is used. Strings are stored as consecutive bytes of ASCII values. No length or terminator is automatically added.

DATA only works with microcontrollers with on-chip EEPROM such as the PIC16F84 and PIC16C84. It will not work on devices with on-chip I2C interfaced serial EEPROM like the 12CE67x and 16CE62x parts. Since EEPROM is non-volatile memory, the data will remain intact even if the power is turned off.

The data is stored in the EEPROM space only once at the time the microcontroller is programmed, not each time the program is run. WRITE can be used to set the values of the on-chip EEPROM at runtime.

	' Store 10, 20 and 30 starting at location 5
	DATA @5,10,20,30

	' Assign a label to a word at the next location
dlabel 	DATA word $1234	' Stores $34, $12

	' Skip 4 locations and store 10 0s
	DATA (4), 0(10)


DEBUG Item{,Item...}

Send one or more Items to a predefined pin at a predefined baud rate in standard asynchronous format using 8 data bits, no parity and 1 stop bit (8N1). The pin is automatically made an output.

If a pound sign (#) precedes an Item, the ASCII representation for each digit is sent serially. DEBUG (on all devices except the 12-bit core) also supports the same data modifiers as SEROUT2. Refer to the section on SEROUT2 for this information.




Send binary digits


Send decimal digits


Send hexadecimal digits

REP c\n

Send character c repeated n times

STR ArrayVar{\n}

Send string of n characters

DEBUG is one of several built-in asynchronous serial functions. It is the smallest of the software generated serial routines. It can be used to send debugging information (variables, program position markers, etc.) to a terminal program like Hyperterm. It can also be used anytime serial output is desired on a fixed pin at a fixed baud rate.

The serial pin and baud rate are specified using DEFINEs:

	' Set Debug pin port

	' Set Debug pin bit

	' Set Debug baud rate

	' Set Debug mode: 0 = true, 1 = inverted

DEBUG assumes a 4MHz oscillator when generating its bit timing. To maintain the proper baud rate timing with other oscillator values, be sure to DEFINE the OSC setting to any different oscillator value.

In some cases, the transmission rates of DEBUG instructions may present characters too quickly to the receiving device. A DEFINE adds character pacing to the serial output transmissions. This allows additional time between the characters as they are transmitted. The character pacing DEFINE allows a delay of 1 to 65,535 microseconds (.001 to 65.535 milliseconds) between each character transmitted.

For example, to pause 1 millisecond between the transmission of each character:


While single-chip RS-232 level converters are common and inexpensive, thanks to current RS-232 implementation and the excellent I/O specifications of the PICmicro, most applications don't require level converters. Rather, inverted TTL (DEBUG_MODE = 1) can be used. A current limiting resistor is suggested (RS-232 is suppose to be short-tolerant).

	' Send the text B0= followed by the decimal value of B0 and a linefeed out serially
	DEBUG B0=, dec B0, 10