Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: MAC Address, PGMONCE question, and COM port specification

  1. #1

    MAC Address, PGMONCE question, and COM port specification

    Couple questions related to custom Teensy boards with fresh MK20 chips and Paul's MINI54:

    1) Has anyone burned anything in to the PROGONCE section of the MK20? Paul puts the MAC address there, but I've been scratching my head on how to access it myself to put a unique code in for each of my devices. I've tried to write a quick sketch based off of the MAC address posts here on the forums, but it doesn't seem to run correctly and since I only get one shot... I want to be sure it's correct. I can post that code also if needed.

    Reference: Page 548-549, http://www.freescale.com/files/32bit...64M50SF0RM.pdf

    2) Does that unique code allow separate Teensy's to show up as different and persistent COM ports? It seems that every Teensy I plug in receives a COM port allocation that stays the same (I'm up to about COM20 due to all of the Teensy's I have plugged in).

    3) If that MAC address doesn't control the behavior of COM port allocation, what does? The custom boards I rolled at home all show up as the same COM port, and I figured that may be due to the fact that all of them have the same values in the MAC address.

    4) Finally, if my thinking for (2) is correct, is it required that the values programmed into the spots where Paul usually burns the MAC address required to also be a valid MAC address? I was just going to use sequentially increasing serial numbers, starting at 0x00.


    Thanks in advance!

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,592
    Quote Originally Posted by kam42 View Post
    but it doesn't seem to run correctly and since I only get one shot... I want to be sure it's correct.
    There are 16 separate 4-byte writable chunks in the "program once" memory. PJRC writes to the last two. If you start at the beginning, you get 14 tries before writing to the 2 that really matter.


    I can post that code also if needed.
    Always a good idea, which is why it's a sticky message on this tech support forum.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,592
    Quote Originally Posted by kam42 View Post
    2) Does that unique code allow separate Teensy's to show up as different and persistent COM ports?
    On Windows, the driver uses the USB serial number to map otherwise-the-same devices to COM port numbers.

    If you're using a blank MK20 chip, the serial number should be 4294967295 on every board. The serial number is initialized by this code in usb_desc.h:

    Code:
    void usb_init_serialnumber(void)
    {
            char buf[11];
            uint32_t i, num;
    
            __disable_irq();
            FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL;
            FTFL_FCCOB0 = 0x41;
            FTFL_FCCOB1 = 15;
            FTFL_FSTAT = FTFL_FSTAT_CCIF;
            while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF)) ; // wait
            num = *(uint32_t *)&FTFL_FCCOB7;
            __enable_irq();
            ultoa(num, buf, 10);
            for (i=0; i<10; i++) {
                    char c = buf[i];
                    if (!c) break;
                    usb_string_serial_number_default.wString[i] = c;
            }
            usb_string_serial_number_default.bLength = i * 2 + 2;
    }
    You can experiment with different serial numbers, without touching the "program once" memory, by simply editing that code in usb_desc.c.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •