157
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
returned by the sys.currpll property.
Data in the special configuration section of the EEPROM
Bottom 8 bytes of the EEPROM (accessible through the
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
read-only property of the
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
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
Byte
6
Byte7
Byte8
6
MAC0
MAC1
MAC2
MAC3
MAC
4
MAC5
Checksum
Byte at address 1 must be set to 6- this means, that 6 byte 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
380
269
267
381