USB on MK20DX256VLL10 vs MK20DX256VLH7

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB on MK20DX256VLL10 vs MK20DX256VLH7

Jump to solution
1,305 Views
fentrias
Contributor I

I am exploring porting software built for MK20DX256VLH7. It uses USB and works fine on the MK20DX256VLH7. We substituted the CPU with the MK20DX256VLL10 (to get more pins and speed) but now the USB does not work properly. Using the same firmware on the MK20DX256VLL10, everything else seems fine (I2C, pins, etc). In the debugger, after plugging it in, I can see it calls the interrupt for USB USBRST and it will also process SOFTOKEN regularly. But that's it. It will not receive the TOKDNE events when the host sends it's SETUP packets. I can see the packets come from the computer using a USB analyzer.

Are there any differences between the USB module on the MK20DX256VLL10 and MK20DX256VLH7? Any ideas of how to troubleshoot this?

0 Kudos
1 Solution
1,138 Views
mjbcswitzerland
Specialist V

Hi Fen

There are a couple of "minor" changes needed when moving from the K20M72 to the K20M100:
1. The K20M100 has an MPU which needs to be disabled for USB to be able to operate:
Add
MPU_CESR = 0; // allow concurrent access to MPU controller
2. The crossbar switch configuration is not identical and so you need to change the USB master from master M3 (on K20M72) to master M4 on the K20M100:
FMC_PFAPR |= FMC_PFAPR_M4AP_RD; [or |= 0x00000100]
otherwise the USB controller will not have rights to read from flash (less efficient USB drivers may not use direct flash access so this will not always be needed)
3. After changing the operating speed ensure that the USB controller clock is still exactly 48MHz. The following code can be used to check it at run time:

        if ((SIM_CLKDIV2 & SIM_CLKDIV2_USBFRAC) != 0) {
            if (((USB_CLOCK_SOURCE/(((SIM_CLKDIV2 >> 1) & 0x07) + 1)) * 2) != 48000000) {
                unsigned long _USB_CLOCK_SOURCE = USB_CLOCK_SOURCE;
                unsigned long _SIM_CLKDIV2 = SIM_CLKDIV2;
                _EXCEPTION("USB Clock not 48MHz!!!!!!");
            }
        }
        else {
            if ((USB_CLOCK_SOURCE/(((SIM_CLKDIV2 >> 1) & 0x07) + 1)) != 48000000) {
                unsigned long _USB_CLOCK_SOURCE = USB_CLOCK_SOURCE;
                unsigned long _SIM_CLKDIV2 = SIM_CLKDIV2;
                _EXCEPTION("USB Clock not 48MHz!!!!!!");
            }
        }

where you can define to have the clock speed that you have (eg. MCGPPLCK is usual for these two processors)
for USB_CLOCK_SOURCE
4. Ensure that the HW has a low ESD capacitor (>= 2.2uF) close to VOUT33 for USB transceiver reliability.


Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html
Kinetis K20:
- http://www.utasker.com/kinetis/FRDM-K20D50M.html
- http://www.utasker.com/kinetis/TWR-K20D50M.html
- http://www.utasker.com/kinetis/TWR-K20D72M.html
- http://www.utasker.com/kinetis/TEENSY_3.1.html
- http://www.utasker.com/kinetis/tinyK20.html
USB: http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF
USB composites: http://www.utasker.com/kinetis/USB_Device.html
USB-CDC host<->device video: https://www.youtube.com/watch?v=XhISV1czIo4&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q&index=16

Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M


For better, faster, cheaper product developments consider uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html

View solution in original post

0 Kudos
7 Replies
1,139 Views
mjbcswitzerland
Specialist V

Hi Fen

There are a couple of "minor" changes needed when moving from the K20M72 to the K20M100:
1. The K20M100 has an MPU which needs to be disabled for USB to be able to operate:
Add
MPU_CESR = 0; // allow concurrent access to MPU controller
2. The crossbar switch configuration is not identical and so you need to change the USB master from master M3 (on K20M72) to master M4 on the K20M100:
FMC_PFAPR |= FMC_PFAPR_M4AP_RD; [or |= 0x00000100]
otherwise the USB controller will not have rights to read from flash (less efficient USB drivers may not use direct flash access so this will not always be needed)
3. After changing the operating speed ensure that the USB controller clock is still exactly 48MHz. The following code can be used to check it at run time:

        if ((SIM_CLKDIV2 & SIM_CLKDIV2_USBFRAC) != 0) {
            if (((USB_CLOCK_SOURCE/(((SIM_CLKDIV2 >> 1) & 0x07) + 1)) * 2) != 48000000) {
                unsigned long _USB_CLOCK_SOURCE = USB_CLOCK_SOURCE;
                unsigned long _SIM_CLKDIV2 = SIM_CLKDIV2;
                _EXCEPTION("USB Clock not 48MHz!!!!!!");
            }
        }
        else {
            if ((USB_CLOCK_SOURCE/(((SIM_CLKDIV2 >> 1) & 0x07) + 1)) != 48000000) {
                unsigned long _USB_CLOCK_SOURCE = USB_CLOCK_SOURCE;
                unsigned long _SIM_CLKDIV2 = SIM_CLKDIV2;
                _EXCEPTION("USB Clock not 48MHz!!!!!!");
            }
        }

where you can define to have the clock speed that you have (eg. MCGPPLCK is usual for these two processors)
for USB_CLOCK_SOURCE
4. Ensure that the HW has a low ESD capacitor (>= 2.2uF) close to VOUT33 for USB transceiver reliability.


Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html
Kinetis K20:
- http://www.utasker.com/kinetis/FRDM-K20D50M.html
- http://www.utasker.com/kinetis/TWR-K20D50M.html
- http://www.utasker.com/kinetis/TWR-K20D72M.html
- http://www.utasker.com/kinetis/TEENSY_3.1.html
- http://www.utasker.com/kinetis/tinyK20.html
USB: http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF
USB composites: http://www.utasker.com/kinetis/USB_Device.html
USB-CDC host<->device video: https://www.youtube.com/watch?v=XhISV1czIo4&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q&index=16

Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M


For better, faster, cheaper product developments consider uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html

0 Kudos
1,138 Views
fentrias
Contributor I

Thank you very much! That worked like a charm.

As a follow up, I'm also having some problem with I2S and before descending into that rabbit hole I thought I would ask if there is any difference between I2S in K20M72 and K20M100. I use I2S0 to communicate but it does not seem to send anything on the K20M100.

0 Kudos
1,138 Views
mjbcswitzerland
Specialist V

Fen

The K20M72 has a I2S/SAI controller but the K20M100 has an I2S controller.

Unfortunately these are not compatible and so you will need a different set of headers and a different driver for its operation. The audio interface features are of course not present.

Regards

Mark

0 Kudos
1,138 Views
fentrias
Contributor I

Thanks again for your quick response.

Perhaps I am looking at the wrong manual for the MK20DX256VLL10 (5N22D)

chip. I use document K20P100SF2V2RM.pdf, which I got from

https://www.nxp.com/docs/en/reference-manual/K20P100M100SF2V2RM.pdf

For the MK20DX256VLH7, I use document K20P64M72F1RM.pdf.

In the K20P100SF2V2RM document, chapter 51 describes the I2S/SAI, which is

virtually identical to document K20P64M72F1RM.

On Fri, Jan 26, 2018 at 10:23 AM, mjbcswitzerland <admin@community.nxp.com>

0 Kudos
1,138 Views
mjbcswitzerland
Specialist V

Fen

If you have a revision 2 device then yes it does have the same I2C/SAI as the K20M72.
I was comparing with the V1 part (probably incorrectly since most - but not all - stock today are V2s).
Beware however because sometimes a V1 part may still be delivered by distributors so code should check to be sure....

Regards

Mark

0 Kudos
1,138 Views
fentrias
Contributor I

Mark,

Thanks again for answering my questions. How do I check whether it's a V1

or V2?

Also, am I to infer that the I2S works identically and the initialization

is the same so it's likely that my problem is a bug of some sort in my code

or a mistake in wiring, etc?

On Fri, Jan 26, 2018 at 12:28 PM, mjbcswitzerland <admin@community.nxp.com>

0 Kudos
1,138 Views
mjbcswitzerland
Specialist V

Fen

V1 parts are marked 256Z and the V2 parts just 256.

The revision can also be read in the register SIM_SDID.

I am not so familiar with the I2S to be able to answer questions about compatibility without knowing which clock sources and modes you use: but I believe that internal clock sources are compatible and also all pin multiplexing.

Regards

Mark

0 Kudos