The change I did was to add a call to the code that reads in the serial number, if it finds that it is going to go into HSRUN mode. I also added code into that call that made it only do stuff once. So in all other cases the current code path to call the function is still done.
Welcome back,For affected MCU's (K66 only? Unless K64 has similar issue if it OC's over 120 MHz with similar limitation?) I envisioned this as something done on 'boot' before HSRUN is active so a static copy (like you suggest 'only once') was always present? In any case with a uniform TEENSY_Ser#() the same code could be used on boot with USB, or by any 'user'.
Wondering if PJRC planning mini_beta of K64 units? Since I have K66 & Ethernet Beta boards I opted for T_3.6 SIX pack , so I won't have any K64's until they go retail.
I was AWOL 3 weeks - now back home and should be online in coming days, once I unpack.
With a uniform function() to Drop/Restore HSRUN - the end user could do this and also batch EEPROM I/O so such things can be usable. It would compromise clock specific items during that time - but better than losing functionality, or having end user hacks. With 'plenty' of RAM - some/all of the EEPROM could be cached for R/W access and quickly sync'd with :: eeprom_read_block() and eeprom_write_block() [ or _dword() ?]
I suspect KurtE already knows, but others thinking about the 3.5 as a drop in replacement, the touchRead function does not work on the 3.5. It should work on the 3.6. Also, the back row of pins (Vbattery, 3.3v, ground, program, DAC) have been relocated.I have not heard anything either about T3.5 beta, but thought these might be interesting as a drop in upgrade, that still gives me 5v tolerance. Obviously one issue will be the size of the board not fitting where the T3.2 would fit. Will talk more about this on another thread. So I ordered the 2+2 Kickstarter.
Welcome back,
I think you are right that maybe there should be some caching scheme for EEPROM. In my case often I only read from the EEPROM at startup. Maybe things like Servo offsets and the like. I may then have a special mode I go into that allows me to update these settings, but again this is in an isolated portion of the code.
I have not heard anything either about T3.5 beta, but thought these might be interesting as a drop in upgrade, that still gives me 5v tolerance. Obviously one issue will be the size of the board not fitting where the T3.2 would fit. Will talk more about this on another thread. So I ordered the 2+2 Kickstarter.
Hm, ok, does this work with disabled usb and/or lower fcpu or teensy 3.2?
CPU SPEED: 240MHz , COM3
MAC: 0x000000000000
Serial: 0
CPU SPEED: 180MHz , COM3
MAC: 0x000000000000
Serial: 0
CPU SPEED: 120MHz, COM6
MAC: 0x04E9E5032345
Serial: 205637
CPU SPEED: 96MHz, COM6
MAC: 0x04E9E5032345
Serial: 205637
CPU SPEED: 48MHz, No USB Emulated Serial
MAC: 0x04E9E5032345
Serial: 205637
Cmason Code / THT T3_mac.zip
CPU SPEED: 120MHz, COM6
Chip MAC ID == 04: E9: E5: 04: E9: E5
Teensy Serial# 3220210
Reading 128-bit UniqueID from Teensy 0017FFFF FFFFFFFF 4E453506 1001001E
Frank,
I tried your code on my T3.6-r3 and get the following results:
uint64_t readMAC() {
[B] static uint64_t mac = 0;
if ( 0 == mac ) {[/B]
MAC: 0x04E9E5032347
Serial: 205639
CPU is T_3.6 F_CPU =120000000
MAC: 0x04E9E5032347
Serial: 205639
CPU is T_3.6 F_CPU =240000000
MAC: 0x04E9E5032347
Serial: 205639
CPU is T_3.6 F_CPU =180000000
Perhaps the best solution would be to read the area in the startup code, before everything else.
Perhaps the best solution would be to read the area in the startup code, before everything else.
static uint32_t usb_init_serialnumber_called = 0;
void usb_init_serialnumber(void)
{
char buf[11];
uint32_t i, num;
if (usb_init_serialnumber_called)
return;
[URL="https://github.com/KurtE/cores/blob/4276f875c101fe43687247e4917b1cc4700d1e93/teensy3/usb_desc.c#L1219"]// 'num' collect code here[/URL]
usb_init_serialnumber_called = num; // NOTE - this is 32 bit and is *10 in some cases
}
FTFL_FSTAT = FTFL_FSTAT_CCIF;
while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) {}
// if we need faster than the crystal, turn on the PLL
#if defined(__MK66FX1M0__)
#if F_CPU > 120000000
[B] FTFL_FCCOB0 = 0x41;
FTFL_FCCOB1 = 0x07;
FTFL_FSTAT = FTFL_FSTAT_CCIF;
while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) {}
[/B] SMC_PMCTRL = SMC_PMCTRL_RUNM(3); // enter HSRUN mode
while (SMC_PMSTAT != SMC_PMSTAT_HSRUN) ; // wait for HSRUN
#endif
MAC: 0x04E9E5032347
Serial: 205639
CPU is T_3.6
F_CPU =240000000
I've created a library that helps to retrieve the Serial and MAC from within your sketch:
...
Works with Teensy LC, Teensy 3.0 .. 3.6 and in HS_RUN-Mode.
uint8_t mac[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
Serial.printf("MAC: 0x%012llX\n", teensyMAC());
I was using T3Mac.h on the Teensy 3.2 and it worked without defining:
How does this one work?Code:uint8_t mac[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
I wonder that:
only shows 14 digits?Code:Serial.printf("MAC: 0x%012llX\n", teensyMAC());
Serial: 1679610
MAC: 0x04E9E5029019
It's a format string...What does "0x%012llX\n" do?
uint8_t mac[] =
Ethernet.begin(mac, ip, dnsServer, gateway, subnet);
// Set MAC via DS18B20
void setupEthernet(){
byte i;
byte dsAddress[8];
Serial.println( "Searching for DS18B20..." );
oneWire.reset_search(); // Start the search with the first device
if (!oneWire.search(dsAddress)) {
Serial.println( "None found. Using default MAC address." );
} else {
Serial.println( "Success! Setting MAC address:" );
Serial.print( " DS18B20 ROM =" );
for( i = 0; i < 8; i++) {
Serial.write(' ');
Serial.print( dsAddress[i], HEX );
}
Serial.println();
// Offset array to skip DS18B20 family code, and skip mac[0]
mac[1] = dsAddress[3];
mac[2] = dsAddress[4];
mac[3] = dsAddress[5];
mac[4] = dsAddress[6];
mac[5] = dsAddress[7];
}
Serial.print( " Ethernet MAC =" );
for( i = 0; i < 6; i++ )
{
Serial.write( ' ' );
Serial.print( mac[i], HEX );
}
Serial.println();
startEthernet();
}
uint64_t mac64;
uint8_t mac[6];
mac64 = teensyMAC();
mac[0] = mac64 >> 40;
mac[1] = mac64 >> 32;
mac[2] = mac64 >> 24;
mac[3] = mac64 >> 16;
mac[4] = mac64 >> 8;
mac[5] = mac64;
Ethernet.begin( mac, ..
D0 50 99 2A 3D F6
or
D0:50:99:2A:3D:F6
uint64_t mac64;
uint8_t mac[6];
// Set MAC via Teensy serial
void setupEthernet() {
byte i;
Serial.println("Reading MAC from hardware..." );
mac64 = teensyMAC();
mac[0] = mac64 >> 40;
mac[1] = mac64 >> 32;
mac[2] = mac64 >> 24;
mac[3] = mac64 >> 16;
mac[4] = mac64 >> 8;
mac[5] = mac64;
Serial.println("Success! Setting MAC address:");
Serial.print(" Ethernet MAC =");
for( i = 0; i < 6; i++ ) {
Serial.write(' ');
Serial.print("0x");
Serial.print(mac[i], HEX);
}
Serial.println();
Serial.printf(" Test 1 = 0x%012llX\n", mac[i], HEX);
Serial.printf(" Test 2 = 0x%012llX\n", mac[i]);
Serial.printf(" Test 3 = 0x%012llX\n", mac64);
Serial.printf(" Test 4 = 0x%012llX\n", teensyMAC());
Serial.println();
startEthernet();
}
Reading MAC from hardware...
Success! Setting MAC address:
Ethernet MAC = 0x4 0xE9 0xE5 0x3 0xA7 0xAE
Test 1 = 0x001000000000
Test 2 = 0x001B00000000
Test 3 = 0x04E9E503A7AE
Test 4 = 0x04E9E503A7AE
for( i = 0; i < 6; i++ ) {
Serial.write(' ');
Serial.printf("%02X", mac[i]);
}