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

Thread: Custom Teensy Board Help

  1. #1
    Junior Member
    Join Date
    Jul 2018
    Posts
    1

    Custom Teensy Board Help

    Hi,
    for my current project i was working with the Teensy 3.2. Now, i want to etch a PCB, and solder a Cortex-M4 (MK20DX256VLH7) to the board, replacing the Teensy.

    My goal is, that the microcontroller on my PCB is easily programmable with USB and the Arduino IDE (Like the Teensy).
    Therefore, i want to buy the MKL04Z32 chip from the Teensy-Strore. It says it contians the bootloader.
    If i connect it like in the Teensy 3.2 schematic, it should work right away, right?

    I got a few questions to the schematic.
    1. Is the USB port really directly connected to the MK20DX256VLH7? Arduino for example requires a USB to UART converter chip - is it built-in in the MK20DX256VLH7?
    2. Another thing, which confuses me is: why is there a quartz with just 16Mhz shown in the schematic? The specs of the Teensy 3.2 say, that its CPU speed is 72Mhz. Is the 16Mhz crystal just used for the communication with the memory chip?
    3. Why is there a LP38691? isn't its ouput voltage 5v?

    4. My last question is, do i need the RESET switch? When i start programmin the Teensy3.2 with the Arduino IDE, i don't have to press any button, therefore i will not put one on my PCB. Is this recommended? I don't get where i should put the button anyways, because the only one i can see in the schematic is connected to the "prog" output of the board, which is just going to GND (so not connected to the microcontroller) - can you explain why?

    Are there any things i have to consider also, when creating my custom Teensy board?

    Sorry for my noob questions and thanks in advance.
    Mick
    Last edited by mick1114; 07-01-2018 at 02:25 PM.

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,759
    Before committing to much to this project you may want to spend some time with the references for the chip, possibly starting with https://www.pjrc.com/teensy/K20P64M72SF1.pdf

    1. The Teensy MK20 core has internal USB hardware which is why the Teensy can be a wide range of USB devices under software control - note the PCB layout for the USB lines is critical to get right.
    2. Have not checked what this particular chip does but most fast micro controller use some form of phase lock loop based step up of a lower frequency but high precision clock. This component is also critical to get right and is a failure point on a number of custom Teensy projects.
    3. The LP38691 comes in a range of output voltages, this one is there to produce 3.3V regulated power. If your project already has high quality 3.3V then you can use that.
    4. You do not necessarily need the reset pad but you will need the program button in some form (could be a jumper or similar). If you are buying bare MK20s they will not arrive with Teensy blink pre loaded so you will need to trigger the bootloader IC at least once to get the initial code load onto the Mk20. If you are loading good code from then on then the button will not be needed since the running software in the MK20 handles things. If you write code that puts the Mk20 into unwakable deep sleep or non functional USB modes you will need that button to unbrick things.


    If you do a forum search for custom Teensy and check the sales page for the bootloader IC you will find a number of threads on projects like this. It is certainly possible but a number of design elements need to be got right so make sure you budget both for the time to achieve this and for multiple board runs to iterate to something that works.

  3. #3
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,624
    Working and thinking like an engineer means studying data sheets and reference manuals of all components before. If you had done this, you had found the answers as follows:
    1. The MK20DX256 has its own integrated USB “engine”, no need for external converters as on the outdated and asthmatic Arduino.
    2. As all modern MCUs, the 16MHz act just as reference clock. The real CPU frequency of 72, 96, or even 120MHz(overclock) is generated via an internal and software configurable FLL/PLL circuit.
    3. As all modern MCUs, the MK20DX256 works on 3.3V to allow increased speed and lower power dissipation. It’s output levels on the analog and GPIO pins is from 0 to 3.3V. The digital inputs have an internal protection circuit to allow 5V signals for compatibility with older external hardware.
    4. The push button on the Teensy board is not a reset switch, it’s a program switch which allows to put the Teensy in bootloader mode in case it hangs and can not longer react on the bootloader commands from the USB port.

    There are many things to consider when designing a custom PCB for a MCU, like taking care of parasitic inductances when routing the power supply lines, careful low impedance layout of the ground plane, and so on. Nothing Teensy specific, just the rules which apply for all high speed low voltage CMOS circuits. In ever case, such a PCB should not be one’s first project, it’s definitively ways beyond beginner level and you should already have acquired some experience with mixed signal circuit design.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,596
    Quote Originally Posted by mick1114 View Post
    When i start programmin the Teensy3.2 with the Arduino IDE, i don't have to press any button, therefore i will not put one on my PCB. Is this recommended?
    Definitely not recommended.

    To see why, in the Tools > CPU Speed menu, choose one of the options for slower than 24 MHz. Then upload a LED blink program.

    Because the USB communication requires >= 24 MHz, Teensy 3.2 won't be able to communicate at all by USB, but it will happily run your program at that slow speed. Without USB, Arduino can't ask Teensy to automatically reboot. You will have to press the button to upload another program after that no-USB blink.

    Every Teensy is made with that button so you have a way to recover after uploading programs which fail to keep the USB communicating. There are lots of other ways, like disabling all interrupts or entering low power modes where the USB is turned off. Most people never hit these cases when doing ordinary Arduino programming. But as soon as you start messing with writing low-level libraries or using interrupts in "creative" ways, you'll probably need the button to recover from bad uploads.

    I don't get where i should put the button anyways, because the only one i can see in the schematic is connected to the "prog" output of the board, which is just going to GND (so not connected to the microcontroller) - can you explain why?
    The button connects to the MKL02 or MKL04 chip, not to the main processor. When you press the button, or short the PROG pin to ground, that tells the MKL02 chip to take control and force the main processor into bootloader mode.

    When you first build your board, you *WILL* have to press the button, because the MK20 chip comes blank. It can't communicate on USB and respond to Arduino, because it doesn't have any code (and in fact it will repeatedly reset itself, because the watchdog is enabled by default and there's no program to manage the watchdog timer). So even if you are certain you'll never upload a bad program, at least for the very first time you'll need some way to pulse PROG low, so the MKL04 chip takes control and lets you do the first upload.

    On every Teensy we make here, as a final test before it goes into the anti-static bag, we do an upload by manually pressing the button. Even though the bed-of-nails test verifies the USB works to the test pads on the bottom of the board, and the PROG signal works to the pad on the side, this final test is how we physically verify the button and USB connector really work. It also means Teensy comes ready-to-use when you take it out of the bag. But what you don't see is we really do test every single board and press the button as part of the final test.

    Are there any things i have to consider also, when creating my custom Teensy board?
    Yes, they're explained on the web page. The most common rookie mistake is poor routing near the crystal. The crystal is very sensitive, so it must not have any digital traces routed directly underneath. If using 4+ layers, as long as there's an unbroken ground plane under the crystal on later 2, then traces on layers 3 & 4 are ok.

    That page as links to several conversations where we've helped people diagnose problems with their custom boards. Reading those old threads can give you a pretty good idea of the mistakes and misunderstandings other people have faced.
    Last edited by PaulStoffregen; 07-01-2018 at 11:17 PM.

Posting Permissions

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