Platform-dependent Programming Information

Top  Previous  Next

This section contains miscellaneous information that sets this platform apart from other platforms. Various objects described in the Object Reference direct you to this topic in all cases when object capabilities or behavior depend on the platform and, hence, cannot be described in the object reference itself. Each platform section in this manual has its own "Platform-dependent Programming Information" topic. If you are reading documentation top-to-bottom (we have never actually met anyone who does) you can skip this section now.

Supported variable types

This platform supports the following variable types: byte, word, char, short (integer), string, boolean, user-defined structures and enumeration types. Dword, long, and real (float) types are not supported.

There is no need to explicitly configure I/O lines as inputs or outputs

On this platform, each I/O line (controlled by the io object) can be an input and an output at the same time (such lines are sometimes called "quasi-bidirectional"). This is why on this platform the io object does not have io.enabled property.

To sense the state of the external signal applied to the I/O line set the line to HIGH first:

 

 

...

io.num= PL_IO_NUM        'just to select some line as an example

io.state= HIGH                'now we can read the line

x=io.state                        'read line state into x

...

 

 

I/O lines are not "afraid" of "signal competition". That is, you won't damage the line if it is outputting HIGH while external signal is driving it LOW, or vise versa. If the line is driven LOW internally or externally, resulting state if the line is LOW.

 

note_tip-wt

For the hardware-savvy reader: output drivers of I/O lines on this platform are implemented as open collector output with weak pull-up resistor (~20K).

Remapping of I/O lines of the serial port is not possible

All lines of the serial port- TX/W1out/dout output, RX/W1in/din input, RTS/W0out/cout output, and CTS/W0&1in/cin input have fixed positions and cannot be reassigned to different I/O pins of the device. Therefore, on this platform the ser object does not have ser.ctsmap and ser.ctsmap properties.

Explicit configuration of the I/O lines of the serial port as inputs or outputs is not required

Since all I/O lines can serve as inputs and outputs at the same time it is not necessary to explicitly configure serial port lines as inputs or outputs.

Serial port does not have a FIFO buffer

When the serial port is in the UART/full-duplex/flow control mode (ser.mode= PL_SER_MODE_UART, ser.interface= PL_SER_SI_FULLDUPLEX, and ser.flowcontrol= 1- ENABLED) the device is monitoring its CTS input to see if attached serial device is ready to receive more data. If the CTS state changes to "cannot transmit"  the device will stop sending out data immediately. Outgoing serial character that has already started transmitting will be sent out, but no more characters will be sent until the CTS line state changes to "can transmit".

Data in the special configuration section of the EEPROM

Bottom 8 bytes of the EEPROM (accessible through the stor object) are reserved for storing MAC address of the device. On power-up, the MAC address is read out from the EEPROM and programmed into the Ethernet controller. You can always check current MAC through the net.mac read-only property of the net object but there is no direct way to change it. Instead, you can change the MAC address data in the EEPROM. Then, next time the device boots up it will start using this new address.

By default, the area storing MAC address is not accessible to your application- the stor.base property takes care of that. Unless you change it, this property specifies that your application's storage area starts at address 9 (counting from 1). To change MAC, set the stor.base to 1.

MAC address data in the EEPROM has a certain formatting -- you have to follow it if you want the MAC to be recognized by the firmware (TiOS). Here is the format:

 

Byte1

Byte2

Byte3

Byte4

Byte5

Byte6

Byte7

Byte8

6

MAC0

MAC1

MAC2

MAC3

MAC4

MAC5

Checksum

 

The byte at address 1 must be set to 6- this means that 6 bytes of data follow (MAC address consists of 6 bytes). Addresses from 2 to 7 carry actual MAC data. Address 8 stores the checksum, which is calculated like this:

255-(modulo8_sum_of_addr_1_through_7)

Here is a sample code that stores new MAC address into the EEPROM and then reboots the device to make the device load this new MAC:

 

dim s as string

dim x as byte

...

s= "0.2.123.124.220.240"        'supposing, we want to set this MAC

...

...

s=chr(6)+ddval(s)                'added first byte (always 6) and coverted readable MAC into bytes

x=255-strsum(s)                        'calculated checksum and assigned the result to a BYTE variable (!!!)

s=s+chr(x)                                'now our string is ready

 

stor.base(1)                        'will access EEPROM from the bottom

x=stor.set(s,1)                        'save data

if x<>len(s) then                'it is a good programming practive to check the result

       'failed

else

       sys.reboot                        'new MAC set, reboot!

end if

 

...

 

 

There are limitations on what MAC you can set. When loading the MAC into the Ethernet controller the device always resets the first byte of this address to 0. For example, if you set the MAC to 1.2.3.4.5.6 then the actual MAC used by the device will be 0.2.3.4.5.6.

 

note_warning-wt

If you write incorrect MAC data (wrong "length" byte or error in checksum calculation) the device will ignore it and boot up with default MAC, which is 0.1.2.3.4.100.

 

Available network interfaces

This platform only has one network interface -- the Ethernet port.

Device serial number

EM202 devices do not contain a serial number. Therefore, sys.serialnum R/O property and sys.setserialnum method are not available on this platform.

Miscellaneous

Sys object does not support the sys.onsystimerperiod property and the on_sys_timer event generation period is fixed at 0.5 seconds.
Beginning with V2.0, sock.redir and ser.redir methods are no longer supported by this platform.
Also beginning with V2.0, the following functions are no longer supported: date, daycount, hours, minutecount, minutes, month, weekday, year.