What is the proper way to obtain the preprogrammed MAC address from a Teensy 3.6 ??
The following test program uses the previously published "read_t3_mac_word" code snippit that works well on a Teensy 3.2 and but only obtains a half correct answer when used with a Teensy 3.6...
This example returns 04:E9:E5:04:E9:E5 for all of my Teensy 3.6s. The first three bytes are as expected but the last three bytes are not correct.
Question #1 - What is the correct way to obtain the second half of the MAC address ?
Question #2 - This program fails if the CPU Speed is above 120MHz.
At CPU speeds above 120MHz the program returns 00:00:00:00:00:00
I have followed the experiments others have used to read Teensy 3.6 EEPROM at speeds above 120MHz but wonder if there is now an accepted or suggested best way to obtain the MAC address from Teensy 3.6 EEPROM at the higher speeds.
Thanks very much for your interest and support !
The following test program uses the previously published "read_t3_mac_word" code snippit that works well on a Teensy 3.2 and but only obtains a half correct answer when used with a Teensy 3.6...
Code:
// Enter a MAC default address
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // default test mac address
/** Retrieve Ethernet MAC from Teensy 3 */
void read_t3_mac_word(uint8_t word, uint8_t loc) {
// To understand what's going on here, see
// "Kinetis Peripheral Module Quick Reference" page 85 and
// "K20 Sub-Family Reference Manual" page 548.
FTFL_FCCOB0 = 0x41; // Selects the READONCE command
FTFL_FCCOB1 = word; // read the given word of read once area
// -- this is one half of the mac addr.
FTFL_FSTAT = FTFL_FSTAT_CCIF; // Launch command sequence
while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) {
// Wait for command completion
}
*(mac + loc) = FTFL_FCCOB5; // collect only the top three bytes,
*(mac + loc + 1) = FTFL_FCCOB6; // in the right orientation (big endian).
*(mac + loc + 2) = FTFL_FCCOB7; // Skip FTFL_FCCOB4 as it's always 0.
}
void setup() {
delay(1000); // allow time for Windoze USB to reconnect
// Open serial communications and wait for port to open:
Serial.begin(9600);
// this check is only needed on the Leonardo:
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("...Teensy 3.6 Read MAC Address Test Starting...");
read_t3_mac_word(0xe, 0); // get mac address unique to this teensy
read_t3_mac_word(0xf, 3);
Serial.printf("\nMy MAC Address is %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
Serial.printf("\n...Done - Looping Forever...\n");
}
void loop() {
}
This example returns 04:E9:E5:04:E9:E5 for all of my Teensy 3.6s. The first three bytes are as expected but the last three bytes are not correct.
Question #1 - What is the correct way to obtain the second half of the MAC address ?
Question #2 - This program fails if the CPU Speed is above 120MHz.
At CPU speeds above 120MHz the program returns 00:00:00:00:00:00
I have followed the experiments others have used to read Teensy 3.6 EEPROM at speeds above 120MHz but wonder if there is now an accepted or suggested best way to obtain the MAC address from Teensy 3.6 EEPROM at the higher speeds.
Thanks very much for your interest and support !