Kinetis k20 USB Stack v4.1.1 troubles

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

Kinetis k20 USB Stack v4.1.1 troubles

Jump to solution
2,175 Views
codyrigney
Contributor II

I am having an issue that I thought was similar to some posts on this forum where I am receiving interrupts from the USB, but I never enter the TOK_DNE condition. I am using the USB_CDC_CLASS component of USB Stack v4.1.1.  I thought maybe doing the MPU_CESR = 0 would fix it, but my project doesn't have this variable (I am using CW 10.6 and processor expert, no OS).  So I searched the internet and found this:

#define MPU_BASE_ADDR 0x4000D000

#define MPU_CESR      (*(volatile uint32_t *) (MPU_BASE_ADDR + 0x00))

But I don't know if it's correct because when I set MPU_CESR = 0 the code stops running and in debug I'm stuck in PE_DEBUGHALT(). 

I also saw a post where putting the USB descriptors in RAM fixed the problem, but I don't know where the descriptor is or how to make sure it's in RAM.

I would appreciate anyone's help.  Thank you!

Labels (2)
Tags (2)
1 Solution
1,327 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Cody,

Everything is fine, except lacking a capacitor on VOUT33, please kindly refer to the following for details.

Untitled.png

Hope that helps,


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
15 Replies
1,327 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Cody,

Would you please tell me the part number and mask set of the k20 device? and as I know, there is a CDC demo in the folder of something like "C:\Freescale\Freescale USB Stack v4.1.1\ProcessorExpert\Examples\Device\CDC", did you use that for test? Please kindly help to clarify! Thanks for your patience!


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,327 Views
codyrigney
Contributor II

Hi Kan,

Thank you for responding.  The part number is MK20DX128VLH5.  How can I find the mask set? 

Yes, I did use the demo there for the test.  I copied the component from the test project to my project.  Then I copied the code then called it the same way as the demo in ProcessorExpert.c.

Thanks again!

1,327 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Cody,

The mask set info can be found right below the part number on the top of the device, it is something like "1N86B".

As you mentioned "I copied the component from the test project to my project.  Then I copied the code then called it the same way as the demo in ProcessorExpert.c.", actually I am wondering why you did that, why not use the demo directly? did you apply this demo on a custom board? but even that you may still use the ready demo after changing the clocking settings.


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,327 Views
codyrigney
Contributor II

I tried the demo but it didn't work out for a different reason.  I took the demo project, added my CPU and removed the existing one.  Then I set the CPU clock settings to 48 mhz.  But it won't generate PE code or build.  I get the error:

DescriptionResourcePathLocationType
ERROR: Incorrect toolchain selected in the project settings. Please change your project setting to use 'ARM Toolchain' or change the selected Compiler..USB_CDC_DEVICE_MK40DX256ZVLQ10_PExCodeWarrior ARM C CompilerProcessor Expert Problem

So I changed the toolchain to ARM Toolchain (Which my own project uses), cleaned, generated PE code, then built and I got this:

DescriptionResourcePathLocationType
Undefined : "memcpy"usb_framework.c/USB_CDC_DEVICE_MK40DX256ZVLQ10_PEx/Generated_Codeline 274C/C++ Problem
mingw32-make: *** [USB_CDC_DEVICE_MK40DX256ZVLQ10_PEx.elf] Error 1USB_CDC_DEVICE_MK40DX256ZVLQ10_PExC/C++ Problem
Undefined : "memset"usb_dci.c/USB_CDC_DEVICE_MK40DX256ZVLQ10_PEx/Generated_Codeline 682C/C++ Problem
Undefined : "__aeabi_unwind_cpp_pr1"USB_CDC_DEVICE_MK40DX256ZVLQ10_PExline 0, external location: C:\Users\Cody Rigney\Desktop\USB_CDC_DEVICE_MK40DX256_PEx\FLASH\usb_dci_c.objC/C++ Problem
Undefined : "__init_user"__arm_start.c/USB_CDC_DEVICE_MK40DX256ZVLQ10_PEx/Project_Settings/Startup_Codeline 257C/C++ Problem
Undefined : "__copy_rom_sections_to_ram"__arm_start.c/USB_CDC_DEVICE_MK40DX256ZVLQ10_PEx/Project_Settings/Startup_Codeline 231C/C++ Problem
Undefined : "__init_registers"__arm_start.c/USB_CDC_DEVICE_MK40DX256ZVLQ10_PEx/Project_Settings/Startup_Codeline 179C/C++ Problem
Undefined : "free"usb_dci.c/USB_CDC_DEVICE_MK40DX256ZVLQ10_PEx/Generated_Codeline 463C/C++ Problem
Undefined : "malloc"usb_dci.c/USB_CDC_DEVICE_MK40DX256ZVLQ10_PEx/Generated_Codeline 393C/C++ Problem
Undefined : "__call_static_initializers"__arm_start.c/USB_CDC_DEVICE_MK40DX256ZVLQ10_PEx/Project_Settings/Startup_Codeline 251C/C++ Problem
Specified file 'libc_Thumb_LE_v7M.a' not foundUSB_CDC_DEVICE_MK40DX256ZVLQ10_PExC/C++ Problem
Specified file 'libm_Thumb_LE_v7M.a' not foundUSB_CDC_DEVICE_MK40DX256ZVLQ10_PExC/C++ Problem
Specified file 'FP_fastI_Thumb_LE_v7M.a' not foundUSB_CDC_DEVICE_MK40DX256ZVLQ10_PExC/C++ Problem
Specified file 'librt_Thumb_LE_v7M.a' not foundUSB_CDC_DEVICE_MK40DX256ZVLQ10_PExC/C++ Problem
Undefined : "memset"__arm_start.c/USB_CDC_DEVICE_MK40DX256ZVLQ10_PEx/Project_Settings/Startup_Codeline 229C/C++ Problem

So I can't build the project for my CPU.  It builds if I don't make any changes.  Any ideas?

1,327 Views
BlackNight
NXP Employee
NXP Employee

Hi Cody,

I might give a try with the attached project. It is using the McuOnEclipse Processor Expert components (see McuOnEclipse Releases on SourceForge | MCU on Eclipse) and implements a simple USB-CDC class, based on the USB V4.1.1 sources.

The project contains a S19 file so can load it with the debugger or bootloader (I assume you have the FRDM-K20 board, given that device you mentioned)?

That project is available on GitHub as well: mcuoneclipse/Examples/FRDM-K20D50M/FRDM-K20_CDC at master · ErichStyger/mcuoneclipse · GitHub

I hope this helps,

Erich

1,327 Views
codyrigney
Contributor II

Hi Erich,

Thank you for the suggestion.  I tried using the components and example.  But the device never enumerates.  It stays stuck in the following loop (my LED code added):

while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {

        /* device not enumerated */

        turnOnLED();

        delayMS(50);

        turnOffLED();

        delayMS(10);

      }

I appreciate any more suggestions.

1,327 Views
BlackNight
NXP Employee
NXP Employee

... and the matching tutorial can be found here:

http://mcuoneclipse.com/2013/04/27/usb-cdc-with-the-frdm-k20d50m/

Erich

1,327 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Cody,

Why did you stick on PE demo? Actually there are bare metal CDC demo for K20 50MHz part in USB stack ver 4.1.1, please kindly refer to C:\Freescale\Freescale USB Stack v4.1.1\Source\Device\app\cdc\cw10\kinetis_k20 for more details.

Hope that helps,


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,327 Views
codyrigney
Contributor II

Hi Kan,

I tried the bare metal demo and it did not work for me.  It never got in the if branch here:

if((start_app==TRUE) && (start_transactions==TRUE))

        {

            Virtual_Com_App();

        }

Which looks like the same reason the method Erich suggested isn't working.

In my other project that I use processor expert in, everything else works but the USB components.  I can't figure out what is going wrong.

1,327 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Cody,

If you didn't modify the CDC demo, there might be issue in hardware, would you please share some snapshots of the schematics? Thanks for your patience!


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,327 Views
codyrigney
Contributor II

Hi Kan,

I appreciate the depth at which you are helping me.  I believe the snapshot below should have all the relevant information.  If you need to see another part please let me know.  Thank you!

(Voltage goes to power regulator and does work).

schematicImage.PNG.png

0 Kudos
1,328 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Cody,

Everything is fine, except lacking a capacitor on VOUT33, please kindly refer to the following for details.

Untitled.png

Hope that helps,


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,327 Views
codyrigney
Contributor II

It was a design problem.  Thank you!

0 Kudos
1,328 Views
codyrigney
Contributor II

Thank you Kan.  We will try this and I'll let you know the results we get.  Thanks!

0 Kudos
1,328 Views
codyrigney
Contributor II

Kan,

The mask set is 3N86B.

The board is custom and I didn't know if I could run a demo mean't for a different board.  I didn't see the demo for a k20 processor.  I'll try running the demo directly on the board and report the results.  I'm am relatively new to this hardware and these tools so thank you for the patience.