 |
ooPIC Programmer's Guide
Chapter 16 - Serial Control Protocol
|
|
|
|
| In ooPIC firmware version B.2.0+, the primary serial port is dedicated to a system called the Serial Control Protocol (SCP) which allows the ooPIC to be controlled over the serial port. SCP allows a remote PC, Pocket PC, Palm Pilot, or any other device with a serial port to interact with, control and debug an ooPIC application while it is running. In addition, the serially attached device can be used as a terminal to the ooPIC providing user I/O with such options as keyboards and LCD touch screens. Special considerations were made in the protocol to allow the serial connection to be done via a wireless radio link. To access an ooPIC using the B.2.X+ firmware you need to have set the ooPIC.Snode property in your ooPIC program. The address is in the range from 1 to 7, address 0 is reserved as the "everyone answer" address for programming via the serial port. If ooPIC.Snode is not set in the program then the ooPIC can only be addressed using address 0. SCP allows any serially connected device to interact with an ooPIC with simple serial commands. For example; if the serial connected device needed to set the position of an RC Servo connected to the ooPIC, the device would send a series of characters, such as the following, through the serial port to the ooPIC:
\041J64M
This breaks down to: "\, Node#, Object Address, J, Object Value, M". Where Node# is the network address of the ooPIC, Object Address is the location of the Object in memory and Object Value is the value to send to that Object. |
Overview |
| | The Serial Control Protocol (SCP) works by allowing a serially attached device to both read and write the properties of the Objects dimensioned in the ooPIC's application currently running in the ooPIC. SCP also provides debugging features that allow the ooPIC's application program to be stopped, single stepped, resumed, branched to, and even allows program modifications as well as entirely new programs to be downloaded to the ooPIC. SCP accomplishes these features by allowing access to the ooPIC's RAM, EEPROM and I2C port through the serial port with a simple serial protocol. The structure of the protocol is configured in such a way that the data loss that may be experienced during use of a radio linked serial port can be detected and corrected using only the Transmit and Receive lines of the serial port without the need for additional flow control I/O lines. The entire character set used by SCP is composed of human readable characters so that a serial terminal program can be used to manually control, program and debug the ooPIC. When active, SCP uses I/O lines 22 and 23 for serial communications utilizing a 9600,N,8,1 no flow control connection. The default baud rate of 9600 BPS may be changed to a baud rate as high as 38400 BPS and as low as 1200 BPS. When the ooPIC is powered up or is reset, the primary serial port's operating mode is set so that all incoming and outgoing serial data is exchanged with any serial Objects that may be dimensioned in the ooPIC's application program. When in this mode, the SCP module will silently monitored all incoming serial data that is received by the primary serial port for the Escape Sequences that change the primary serial port's operating mode. When the primary serial port's operating mode is switched to Serial Control Mode, all serial data is then exchanged with the SCP module until a future Escape Sequence changes the primary serial port's operating mode back to exchanging data with the serial Objects.
Escape Sequence are modeled after ANSI 'C' Escape Sequences where the Escape character is represented by the Backwards Slash character ( \ ) and the character immediately following the Escape character is used as a control value. When the the SCP module detects the Escape character ( \ ), the next character received (the control value) is used to set the primary serial port's operating mode. |
Serial Control Mode |
| | Before the connected serial device can communicate with the ooPIC, the ooPIC must be placed in Serial Control Mode. This is the mode in which the ooPIC will respond to serial commands. If the ooPIC is not placed in Serial Control Mode or has been exited from serial control mode, then it will ignore serial commands. The SCP Escape Sequence [Escape] [Node] is used to place the ooPIC into Serial Control Mode where the the control value of the Escape sequence, [Node], is a 1 digit number 0-7 which represents the ooPIC's serial network Node number. When this Escape Sequence is encountered, the [Device-Number] is checked against the ooPIC's serial network Node number and if they match, or [Device-Number] is 0, then the ooPIC will be placed into Serial Control Mode. Upon being placed in Serial Control Mode, the primary serial port's input buffer and the 3 control registers; Memory Address, Memory Type and Sub Address are cleared. Once in Serial Control Mode, the ooPIC's SCP Module will respond to any commands that are issued. Serial Control Mode is exited by either issuing the Exit command "X" or an Escape Sequence where the control character is a non-numeric character. After exiting Serial Control Mode, the ooPIC's primary serial port's operating mode is set so that all incoming and outgoing serial data is exchanged with any serial Objects that may be dimensioned in the ooPIC's application program and the SCP will return to silently monitor the incoming serial data.
Example: To place the ooPIC in and out of serial control mode, Send "\0". (the ooPIC is now in Serial Control Mode) Send "\A". (the ooPIC is now out of serial control mode)
The ooPIC's serial network Node number is set by the ooPIC's currently running application program. It can be any number from 0 to 7. When set to any number other than 0, the SCP Module can be activated by either of the two Escape Sequences; [Escape] [0] or [Escape] [Node]. Note that the SCP Module will always respond to "\0" regardless of what the serial network Node has been set to. This allows up to 7 ooPIC's to share a connection to a single serial port. When multiple ooPICs are sharing a single serial port, the Escape Sequence: [Escape] [0] will activate all of them while [Escape] [Node] will only activate the ones that are set for that Node. When an ooPIC's SCP Module has been activated, access to its RAM memory and program EEPROM is achieved via a set of commands which are used to specify the address and type of the memory to read and write. A single uppercase ALPHA character is used to initiate each of the commands and each command returns a lower case character to indicate when it has completed its function. Most of the commands can be issued in any order. For example the Acknowledge Commands command "V" can be issued at any time to verify a valid connection with SCP, the Request Buffer command "Q" can be issued at any time to read the current contents of the SCP's input buffer, and the Exit command "X" can be issued at any time to exit SCP.
Example: To place the ooPIC in serial control mode, issue some commands, and exit serial control mode, Send "\0". Send "V". Receive "v". (verified the SCP has a valid connection) Send "Q". Receive "q" (nothing in input buffer) Send "V". Receive "v". (verified the SCP has a valid connection) Send "\A". (the ooPIC is now out of serial control mode)
To verify that the ooPIC was placed in serial control mode, the Acknowledge Commands Command "V" can be issued. When the Acknowledge Commands function is on, all commands will respond with an acknowledgment character.
Example: To place the ooPIC in serial control mode and verify a valid connection with SCP and then exit, Send "\0". Send "V". Receive "v". (Acknowledge Commands is now on) Send "\A". (the ooPIC is now out of serial control mode)
To discontinue Acknowledge Commands, the Silence command "U" is used. When the Acknowledge Commands function is off, only the commands that send data back to the ooPIC will respond with an acknowledgment character.
Example: To place the ooPIC in serial control mode and verify a valid connection with SCP and then exit, Send "\0" Send "V". Receive "v". (Acknowledge Commands is now on) Send "U". (Acknowledge Commands is now off) Send "\A". (the ooPIC is now out of serial control mode)
|
Sending Values |
| | While in Serial Control Mode, Decimal and Hexadecimal Characters are used for transferring data. Decimal Characters are used when a single value is being sent, and Hexadecimal Characters are used when multiple values are being sent. When sending values to the ooPIC, each character of incoming serial data is stored in the primary serial port's 16-charactor input buffer. Any data that is in the input buffer when a store command is executed, will be evaluated for its numeric value. Even non numeric characters will be evaluated based on there ASCII values. To verify that the data was received correctly, The Query Buffer command "Q" can be used to copy the contents of the input buffer to the primary serial port's output buffer which is then sent out over the serial port. When this command has completed, a "q" is returned indicating that the command is done.
Example: To put Hex("1D3F") into the buffer, and then verify that it was received properly by reading it back, Send "\0V", Receive "v" Send "1D3F" Send "Q", Receive "1D3Fq"
Note that the Query Buffer command "Q" does not need for the Acknowledge Commands Command "V" to be used prior to use because it is one of the commands that send data back to the ooPIC.
Example: Same as above, but without the Acknowledge Commands Command "V", Send "\01D3FQ", Receive "1D3Fq"
Also note that the Request Buffer command "Q" is a non-destructive command that can be issued repeatedly without changing the bytes in the input buffer. The Clear Buffer command "R" is used to clear the buffer.
Example: To put "1234" into the buffer, verify that it was received properly multiple times and then clear it, Send "\0V", Receive "v" Send "1234" Send "Q", Receive "1234q" Send "Q", Receive "1234q" Send "R", Receive "r" Send "Q", Receive "q"
Note that if the buffer is empty when a command that reads its value is used, then the buffer's value will be read as 0. Also note that ALL incoming characters are stored to the input buffer. This includes the backspace character. Therefore, if the buffer winds up with erroneous data in it, the backspace character will not erase the data. |
Accessing Memory |
| | The ooPIC's II+'s memory is arranged as 512-Byte bank of RAM plus a 256-Byte bank of EEPROM. Reading and writing memory is done with the Read Memory "M" and Set Memory "N" commands. In addition, the Read Memory and Set Memory commands can access the ooPIC's External EEPROM memory chips as well as any other I2C devices connected to the Local I2C port. 
Before any memory type can be accessed, a few specifications must be set. The Store Memory and Read Memory commands rely on 3 control registers that specify how to perform the read and write functions. These control registers are; Memory Type, Memory Address, and Sub Address.
Memory Type
Each time memory is accessed, the Memory Type control register is examined to determine what kind of memory to access and how access it. The Memory Type is an 8-Bit value that is used to specify a number of attributes about the memory. To set the Memory Type, the Set Type command "H" is used. To read the Memory Type the Read Type command "G" is used.
Example: To set the Memory Type to "64", and then read the Memory Type, Send "\0V", Receive "v" Send "64H", Receive "h" Send "G", Receive "64g"
There are 4 different types of memory that can be accessed with SCP. RAM, Internal EEPROM, External, and Default Object Property. The Default Object Property is a special type of memory access. All of the Object's Default Properties physically resides inside the RAM memory which can also be accesses, but reading and writing to the Default Object Property activates critical Object routines that are required when the Object's default property changes. External Memory is also a special type of memory. It uses the Local I2C port to to access the ooPIC's program EEPROM located in socket E0, the data EEPROM located in socket E1 and any other I2C device that may be connected to the Local I2C port. The following table shows the mapping of the bits of the Memory Type value:
| Bit(s) | Use | Description |
| 7 | Auto-Increment Address | 0: the 16-bit Memory Address control register will auto increment each time the memory is read or written. 1: the address remains unchanged when the memory is accessed. |
| 6 | Memory Type Bit-C | 0: Internal Memory is accessed. 1: The Local I2C port is used to access External Memory. |
| 5,4 | Memory Type Bit-B,A | Internal Memory 11: n/a 10: read/write Internal EEPROM 01: read/write RAM. 00: read/write Object's Default property. | Local I2C port addressing: 11: n/a 10: Uses 7-Bit addressing. 01: Uses 10-Bit addressing. 00: Uses 23-Bit addressing. |
| 3 | Reserved | |
| 2 - 0 | Block Size | The number of bytes to read/write when accessing Memory This value is 0 based. I.E. 000 reads 1 byte and 111 reads 8 bytes. |
Some common Memory Type values are:
- 0: Read/Write an Object's default property.
- 16 to 23: Read/Write a block of memory from 1 to 8 bytes from RAM, Increment Memory Address to next block.
- 32 to 39: Read/Write a block of memory from 1 to 8 bytes from the Internal EEPROM, Increment Memory Address to next block.
- 64 to 71: Read/Write a block of memory from 1 to 8 bytes from the External Memory, Increment Memory Address to next block.
- 144 to 151: Read/Write a block of memory from 1 to 8 bytes from RAM, Keep Memory Address the same.
- 160 to 167: Read/Write a block of memory from 1 to 8 bytes from the Internal EEPROM, Keep Memory Address the same.
- 192 to 199: Read/Write a block of memory from 1 to 8 bytes from the External Memory, Keep Memory Address the same.
Examples of these common Memory Type are shown in latter sections.
Memory Address
Each time memory is accessed, the Memory Address control register is used to determine where the accessed memory is. The Memory Address is a 16-Bit value that is used to specify the memory's address. To set the memory address, the Set Address command "J" is used. To read the value in the Memory Address, the Read Address command "I" is used.
Example: To set the memory address to "126", and then read what the Memory Address is set to, Send "\0V", Receive "v" Send "126J", Receive "j" Send "I", Receive "126i"
Being a 16-Bit value, the Memory Address can handle memory addresses from 0 up to 65535 which allows addressing 64k byte EEPROMs.
Example: To set the memory address to "65535", and then read what the Memory Address is set to, Send "\0V", Receive "v" Send "65535J", Receive "j" Send "I", Receive "65536i"
When reading a block of memory from RAM or EEPROM, the Memory Address is increased by the number of bytes read or written. This allows a subsequent memory access to occur without needing to re-specify the next memory address. This auto increment function can be overridden by specifying a 1 in the 7th bit of the Memory Type control register previously discussed.
Sub Address
The Sub Address has a dual purpose. When accessing RAM, it is used for block and bit address and when accessing External Memory, it is used as an I2C device address. To set the Sub Address, the Set Sub Address command "L" is used. To read the Sub Address the Read Sub Address command "K" is used.
Example: To set the Sub Address to "84", and then read the Sub Address, Send "\0V", Receive "v" Send "84L", Receive "l" Send "K", Receive "84k"
The values to use for the Sub Address are discussed in more detail in latter sections. |
Accessing an Object's Default Property |
| | Accessing an Object's default property is the simplest form of the SCP protocol. To read and write an Object's default property, the Memory Type control register should be set to 0, the Memory Address control register needs to be set to the address of the Object to access, and if writing to the Object, the value to write needs to be specified. Once the conditions are met to access the Object's default property, the Set Memory command "N" is used to set the default property and the Read Memory command "M" is used to read the default property. If accessing the Object's default property is done immediately after entering into SCP mode, then setting the Memory Type control register to 0 can be skipped because is set to 0 by the SCP initialization routines. Note: The following examples expect that the ooPIC program currently running has an oByte Object dimensioned first. This creates an Object at address 126. Also note that the address of any Object dimensioned in an ooPIC application can be found by examining its address property which can be viewed by expanding the Object Icon in the Object window.
Example: To write a value of 2 to the default property of the Object at address 126, and then read it back. Send "\0V", Receive "v" Send "126J", Receive "j" Send "2N", Receive "n" Send "M", Receive "2m"
Accessing an Object's default property activates critical Object routines that are required when the Object's default property changes. In the last example, writing a value of 2 to an oByte Object also set the Object's non-zero property to 1. Writing a 0, would have cleared the non-zero property to 0. Writing without the Acknowledge Commands command can also be done,
Example: To write a value of 2 to the default property of the Object at address 126, without any verification. Send "\0126J2N"
If the SCP Mode is not exited and the Memory Address and Memory Type values are not changed after being set, the default Object property may be read repeatedly by reissuing the Read Memory "M" command.
Example: To read the default property of the Object at address 126, which contains the value of 2, three times, Send "\0V", Receive "v" Send "126J", Receive "j" Send "M", Receive "2m" Send "M", Receive "2m" Send "M", Receive "2m"
Likewise, the value may be written repeatedly.
Example: To write 2, 3 and 4 consecutively to the default property of the Object at address 126, Send "\0V", Receive "v" Send "126J", Receive "j" Send "2N", Receive "n" Send "3N", Receive "n" Send "4N", Receive "n"
When accessing an Object whose default property is signed, negative numbers are indicated by a dash "-" preceding the value.
Example: To read the default property of an oChar Object whose Value property is - 25, Send "\0V", Receive "v" Send "126J", Receive "j" Send "M", Receive "-25m"
Likewise, negative numbers may be written.
Example: To write to the default property of an oChar Object with the value of -10, Send "\0V", Receive "v" Send "126J", Receive "j" Send "-10N", Receive "n" Send "M", Receive "-10m"
|
Accessing RAM Memory |
| | RAM in the ooPIC is organized into 4 banks (0 to 3) of 128 bytes each. To read from RAM memory, the Memory Type 1 and the desired Memory Address is specified after which the Read Memory command "M" is issued. The returned block of memory is formatted in 2-character per digit Hexadecimal.
Example: To read the 2 bytes of RAM that are used by an oByte Object at address 126 when the oByte's Value property has been set to a value of 5, Send "\0V", Receive "v" Send "126J", Receive "j" Send "145H", Receive "h" (145 = ( [Read 2 bytes] - 1) + ( [Memory Type 1] * 16) + [128 do not auto increment the address.] ) Send "M", Receive "AA05m" Note that the 8-Bit Value property of the oByte Object, which was 5, was located at address 127 and therefore the Read Memory command retrieved its value.
To write to RAM memory, the Memory Type 1 and the desired Memory Address is specified followed by the values of the memory to write which are specified in 2-character per digit Hexadecimal followed by the Store Memory command "N".
Example: To write the value of the last RAM location of Bank 0 in the ooPIC when a single oByte has been programmed in, Send "\0V", Receive "v" Send "127J", Receive "j" Send "144H", Receive "h" (144 = ( [Read 1 byte] - 1) + ( [Memory Type 1] * 16) + [128 do not auto increment the address.] ) Send "06N", Receive "n" Note that the 8-Bit Value property of the oByte Object was located at address 127 and therefore the write command set its value to 6. Read 2 Bytes example above is done once again, the returned value will be "AA06m".
Note: It is critical that the values to be written are properly formatted in 2-character per digit Hexadecimal. Not doing so will cause erroneous data to be written. Most of the data in the ooPIC is stored at the bit level and each single byte of RAM is shared with multiple data elements. When writing to the ooPIC's RAM memory, special care must be taken to write only the bits that are applicable to the data element being written. To accomplish this, the Sub Address control register is used to select the bits that are being accessed. Within the Sub Address control register are values that indicate how many bits to read, and where in the byte to read them from. The following table shows the mapping of the Sub Address with accessing RAM:
| Bit(s) | Use | Description |
| 7 - 6 | Bank Number | One of the 4 Banks of RAM |
| 5 - 3 | Bit Shift | The number of positions to left-shift the bits to match the bit position in RAM 000 = 0 bits, 001 = 1 bit, 111 = 7 bits |
| 2 - 0 | Number of Bits | The number of bits to access. 000 = 8-Bits, 001 = 1-Bit, 111 = 7-Bit, |
Some common Sub Addresses for RAM access are:
- 0: Selects all 8-Bits
- 1: Selects the lower 1-Bit
- 57: Selects the upper 1-Bit
- 4: Selects the lower 4-Bits
- 36: Selects the upper 4-Bits
Example: To write a value to only the upper 4 bit positions of the last RAM location of Bank 0 in the ooPIC when a single oByte has been programmed in, a Sub Address of 36 is used. Send "\0V", Receive "v" Send "127J", Receive "j" Send "144H", Receive "h" Send "36L", Receive "l" 36 = ( [Select 4-Bits]) + ( [Shift 4 bits] * 8) Send "0FN", Receive "n" Note that the 8-Bit Value property of the oByte Object was located at address 127 and therefore the write command set its upper 4-Bits to 1. If the Read 2 Bytes example above is done once again, the returned value will be "AAF6m".
Likewise, any bits can be read.
Example: To read and write a value to only the upper 4 bit positions of the last RAM location, Send "\0V", Receive "v" Send "127J", Receive "j" Send "144H", Receive "h" Send "0L", Receive "l" This selects all 8-bits. (0 = ( [Select 8-Bits]) + ( [Shift 0 bits] * 8) ) Send "00N", Receive "n" This writes a 0 to the 8-bits. Send "36L", Receive "h" This selects the upper 4-bits. (36 = ( [Select 4-Bits]) + ( [Shift 4 bits] * 8) ) Send "0FN", Receive "n" This writes "1111" to the 4 bits. Send "M", Receive "0Fn" This reads what is in the upper 4 bits. Send "0L", Receive "h" This selects all 8-bits. (0 = ( [Select 8-Bits]) + ( [Shift 0 bits] * 8) ) Send "M", Receive "F0n" This reads all 8-bits.
|
Accessing Internal EEPROM Memory |
| | The ooPIC II+ has 256 bytes of Internal EEPROM memory. To write to the Internal EEPROM, the Memory Type 2 and the desired Memory Address is specified followed by the values of the memory to write which are specified in 2-character per digit Hexadecimal followed by the Store Memory command "N".
Example: To write the hex(01234567) to the first locations of of the Internal EEPROM. Send "\0V", Receive "v" Send "0J", Receive "j" Send "160H", Receive "h" (163 = ( [Select 1 bytes] - 1) + ( [Memory Type 2] * 16) + [128 do not auto increment the address.] ) Send "01N", Receive "n"
NOTE: It is critical that the values to be written are properly formatted in 2-character per digit Hexadecimal. Not doing so will cause erroneous data to be written. Also NOTE that the internal EEPROM needs time to write each byte, therefor if more than one byte is sent via the "N" command, only the first byte will be written. Finally NOTE that reading the internal EEPROM does not require bit shifting, so leave the sub-address set to 0 (0L) for this type of access. To read from the Internal EEPROM memory, the Memory Type 2 and the desired Memory Address is specified after which the Read Memory command "M" is issued. The returned block of memory is formatted in 2-character per digit Hexadecimal.
Example: To read the 4 bytes of Internal EEPROM at address 0 written in the example above, Send "\0V", Receive "v" Send "0J", Receive "j" Send "160H", Receive "h" Send "M", Receive "01m"
|
Accessing Program EEPROM Memory |
| | Accessing the ooPIC's I2C Program EEPROM takes some additional steps. In normal operation, the ooPIC is continuously accessing the program EEPROM via the Local I2C bus. Before the SCP can access this EEPROM, it must interrupt the normal access to the EEPROM. This is done with either the Stop Program command "S" or the Reset and Stop command "X". Both of these commands stop the normal I2C access which makes the Local I2C bus available for the SCP Module to use. If access to the EEPROM is attempted before the program has been stopped, the normal command response will be replaced with a "*" to indicate that the command was unsuccessful. After the program has been stopped and the Local I2C bus placed into Serial Control Mode , the program can be resumed with the Start Program command "T". When accessing the EEPROM, its I2C address must be specified with the Sub Address. For the program EEPROM in socket E0, this address is 80.
Example: To read the first 2 bytes from the Program EEPROM at I2C address 80, Send "\0V", Receive "v" Send "S", Receive "s" (Program is now stopped) Send "0J", Receive "j" Send "65H", Receive "h" (65 = ( [Select 2 bytes] - 1) + ( [Memory Type 4] * 16) ) Send "80L", Receive "l" (80 = I2C address of EEPROM ) Send "M", Receive "0B80m" Note that the first byte of "0B" may be different depending on the version of the program in the EEPROM. Also note that the Memory Type was not set to inhibit auto increment and that if the Read Memory Command is pressed again, SCP will return the next 2 bytes in EEPROM.
After accessing the I2C port, the program may be resumed with the Start Program command "T". Note that during the last example, and Objects and Virtual Circuits continue running even when the program flow had discontinued. If the Objects and Virtual Circuits need to be stopped when accessing the EEPROM, then the Reset and Stop command "X" needs to be used instead of the Stop Program command "S".
Send "T", Receive "t" (Program is now running from where it stopped. Note that if the Reset and Stop command was used to stop the program, the Start Program command will cause the program execution to start at the MAIN( ) sub procedure.
Writing data to the Program EEPROM requires special care. If a section of the Program EEPROM is overwritten that the remaining parts of the executing program is expecting to remain unchanged, unexpected results can occur including system lockups that can only be recovered by performing a Removed EEPROM Reset. Generally, if data has been written to the EEPROM, such as a new program, then the ooPIC will need to be reset so that it will reinitialize the new program. The Reset Command "W" is used to reset the ooPIC.
Example: To write the following program into the EEPROM,
| Dim R As New oDio1 Sub Main() R.ioline = 7 R.direction = cvoutput Do R = ooPIC.HZ1 Loop End Sub |
Send "\0V", Receive "v" Send "X", Receive "s" (The ooPIC is now reset and the program is stopped.) Send "0J", Receive "j" Send "67H", Receive "h" Send "80L", Receive "l" Send "0B802901N", Receive "s" Send "01098789N", Receive "s" Send "001D8900N", Receive "s" Send "0E810729N", Receive "s" Send "B90029BEN", Receive "s" Send "28CE29B0N", Receive "s" Send "89001481N", Receive "s" Send "8189001DN", Receive "s" Send "8100FFFFN", Receive "s" Send "W" Note that no command response code was received after the Reset Command and that after the reset, the ooPIC is no longer in Serial Control Mode.
It is possible to write data into the EEPROM without resetting the ooPIC. When doing so, care must be taken to not overwrite the program currently being executed. |
Resetting the ooPIC |
| | There are two methods to reset the ooPIC with SCP. The first method is the Reset and Run Command "W" which drops out of SCP Mode, resets the ooPIC and then begins running the application program from the MAIN( ) sub procedure. The second is the Reset and Stop Command "X" which resets the ooPIC and sets the SCP Mode to verbose on, program stopped.
Example: To start and stop the program, Send "\0V", Receive "v" Send "W" Note that no command response code was received after the Reset Command and that after the reset, the ooPIC is no longer in Serial Control Mode.
Example: To write the following program into the EEPROM, Send "\0V", Receive "v" Send "X", Receive "s" (The ooPIC is now reset and the program is stopped.) Send "T", Receive "t" (Program is now running from the MAIN( ) sub procedure.)
The Reset and Stop Command "X" is also useful for when the ooPIC needs to discontinue driving the I/O lines, because resetting the ooPIC will cause all the I/O lines to go to a HI-Z logic state and will cause all the Objects and virtual circuits to discontinue operating which in the case of hardware objects, will result in discontinuing operation of their connected hardware. |
Single Step |
| | The Single Step command puts the ooPIC's application program into single-step mode. In firmware version B.2.0, the Step property was added to the ooPIC object. When the Step property is set to 1, the ooPIC's Paused property will be set to 1 after each ooPIC instruction executes, thereby giving the user the ability to single step through the program. The Start Single Step command "P" set the Step property to 1 and also clears the Paused property to 0 so that a single instruction gets executed. issuing the Start Single Step command "P" repeatedly, will execute one instruction per issue. The Stop Single Step command "O" exits the single step mode by clearing both the Step and the Paused property which results in the program resuming.
Example: To single step through the program, Send "\0V", Receive "v" Send "0J", Receive "j" Send "P", Receive "p" (Turn on single step and execute one instruction) Send "P", Receive "p" (execute one instruction) Send "P", Receive "p" (execute one instruction) Send "P", Receive "p" (execute one instruction) Send "P", Receive "p" (execute one instruction) Send "0", Receive "o" (Turn off single step and resume program)
Note that the Step and Paused properties are also available to the ooPIC's application program. This gives the program the ability to stop at a preprogrammed place and then wait for SCP to instruct it to resume. |
Branching to Routines |
| | The Branch to Address command "Y" is used to call and execute any sub function in the ooPIC's application program. When branched to, the called sub function will interrupt the current program flow. The interrupted program flow is then returned to when the sub function ends. To use the Branch to Address command, the address of the routine must be specified. After the Branch to Address command has been issued a lower case "y" is returned. If the Branch to Address command was unsuccessful, then the "*" character is returned. Note that the return character is returned before the called sub function begins execution and that there is no automatic indication returned that the sub function has completed. If an indication that the sub function has ended is needed, then it must be coded into the application program at the end of the sub function. A discovery routine which outputs an XML formatted list of Objects dimensioned within the current ooPIC application program is located at address 16.
Example: To call the discovery routine, Send "\0V", Receive "v" Send "16J", Receive "j" Send "Y", Receive "y<XML Object DATA> BUG: Actually, this command sequence, while it works, will not output any XML object structure. The example is still good to show how to call a subroutine though.
|
SCP Commands |
| |
| The following table lists the SCP commands. |
Command
| Function
| Description
|
\ | Begin Escape Sequence | The Escape character is the first character of a two character Escape Sequence. The Escape character is followed with a singe digit which represents the Serial Node of the ooPIC to communicate with. SCP Mode is entered when the received Serial Node is either 0, or matches the ooPIC.SNode property value. If the received Serial Node is not 0 and does not match the ooPIC.SNode property then SCP Mode is turned off. The Escape character can be issued at any time. |
0 to 9 A to F | Numbers. | As digits are received, they are stored into the serial port's input buffer. |
G | Read Memory Type | Reads the 8-Bit Memory Type control register and sends its value out the serial port. A "g" is returned when the Read Memory Type command is completed. |
H | Store Memory Type | Stores a value into the 8-Bit Memory Type control register. Store Memory Type is preceded with the decimal number to be stored. An "h" is returned when Store Memory Type is completed. |
I | Read Memory Address | Reads the 16-Bit Memory Address control register and sends its value out the serial port. An "i" is returned when the Read Memory Address command is completed. |
J | Store Memory Address | Stores a value into the 16-Bit Memory Address control register. Store Memory Address is preceded with the decimal number to be stored. A "j" is returned when Store Memory Address is completed. |
K | Read Sub Address | Reads the 8-Bit Sub Address control register and sends its value out the serial port. An "k" is returned when the Read Sub Address command is completed. |
L | Store Sub Address | Stores a value into the 8-Bit Sub Address control register. Store Sub Address is preceded with the decimal number to be stored. A "l" is returned when Store Sub Address is completed. |
M | Read Memory | Reads the Memory specifies by the control registers and sends its values formatted in 2-character per digit Hexadecimal out the serial port. An "m" is returned when the Read Memory command is completed unless; If accessing the Local I2C bus and the program execution has not been stopped, then Read Memory will return an "*". If accessing the Local I2C bus and the addressed I2C device does not acknowledge, then then Read Memory will return an "!". |
N | Store Memory | Stores value into the Memory specifies by the control registers. Store Memory is preceded with the value to be stored formatted in 2-character per digit Hexadecimal. An "n" is returned when the Store Memory command is completed unless; If accessing the Local I2C bus and the program execution has been stopped, then Read Memory will return an "s". If accessing the Local I2C bus and the program execution has not been stopped, then Read Memory will return an "*". If accessing the Local I2C bus and the addressed I2C device does not acknowledge, then then Read Memory will return an "!". |
O | Exit Single Step | Exits Single Step Mode. An "o" is returned when the Exit Single Step command has completed. |
P | Start Single Step | Starts Single Step Mode. Start Single Step also steps once. A "p" is returned when Start Single Step command has completed. |
Q | Query Buffer | Returns the contents of the serial port's input buffer. An "q" is returned when Request Buffer command has completed. |
R | Clear Buffer | Clears the contents of the serial port's input buffer. An "r" is returned when Clear Buffer command has completed. |
S | Stop Program | Stops the program execution, which makes the Local I2C bus available for use by the SCP Module. A "s" is returned when Stop Program has complete unless; If there is no EEPROM in the E0 socket, then then Stop Program will return an "!". If the program execution has already been stopped, then Stop Program will return an "*". Note: Exiting SCP Mode does not restart the program. Note: Any active virtual circuits are not affected by this command and will continue to operate. |
T | Start Program | Returns the Local I2C bus to Program Execution Mode which results in the application program resuming from where it was paused. A "t" is returned when Start Program has complete. If the Local I2C bus was already in Program Execution Mode, this command has no effect. |
U | Stop Acknowledge Commands | Sets the other commands to a silent mode where the return character is not sent over the serial port after the commands completes unless the command is sending data.
|
V | Start Acknowledge Commands | Sets the other commands to a verbose mode where the return character is sent over the serial port after the commands completes. An "v" is returned when Start Acknowledge Commands command has completed. |
| W | Reset and Run | Resets the ooPIC and runs the program in the E0 EEPROM. Upon reset, the ooPIC will no longer be in Serial Control Mode. No character is returned to confirm that the Reset command has completed. |
| X | Reset and Stop | Resets the ooPIC and resumes SCP Mode with the Local I2C bus available for use by the SCP Module. A "s" is returned when the Reset and Stop command has complete unless; If there is no EEPROM in the E0 socket, then then Reset and Stop command will return an "!". |
| Y | Branch to Address | Branches to the EEPROM address specified. |
| Z | Version | Returns the current serial node number and the internal ooPIC firmware number. A "z" is returned when the Version command has completed. |
|
|