Help with USB

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

Help with USB

3,488 Views
arunkumar1989
Contributor I

Hello ,

I am currently trying out the USB module on my K60(MK60FN1MOVLQ12),in device mode.

Basically,i want to accomplish two things:

1.a simple loop back i.e i write something in hyper terminal and the same content should be echoed back to the same terminal.

2.Text written in hyper terminal should be echoed on an LCD

I have read a few forums and it seems we need to add a few user made processor expert modules?

If someone could point me to an example using this /or similar controller,that would help me a lot.

I have tried using the USB_LDD component but i always mess up with the timings.

I have looked at a few tutorials(links below) but some of their PE components are not there in my current PE component library :smileysad:

http://mcuoneclipse.com/2012/10/07/tutorial-usb-cdc-with-the-kl25z-freedom-board/

http://www.steinerberg.com/EmbeddedComponents/Examples/Examples.htm

Please Help

Labels (1)
0 Kudos
29 Replies

1,443 Views
arunkumar1989
Contributor I

Hey Erich

I finally got it to work.There wasn't any problem with the clock settings or any coding of that matter.

I had actually forgotten to give the VREGIN signal which was why i was getting ERR_BUSOFF error.A silly thing whic took me a good week to figure out.Thanks for all your help and support :smileyhappy:,

Arun

P.S: My next goal is to interface an SD card with the k60 processor.Do you have any documentation on that as well?

Thanks again .:)

Arun

0 Kudos

1,443 Views
danielchai
Senior Contributor I

Hi Arun,

I am doing the USB right now and I have the similar problem with you.'

I connect the 5v to VREGIN, but the USB_D+ and USB_D- always low.

I read that when it is enumerated, the USB_D+ should be high.

I am wondering if there is something wrong with our hardware design or some clock configuration.

Could you show me how did you connect USB cable to USB_D+ and USB_D- on the MCU.

Thank you.

-Daniel

0 Kudos

1,443 Views
arunkumar1989
Contributor I

Hello Daniel,

Apologies for such a late reply.

There are only 3 connections which are required.

VREGIN,D+,D-

Capture.PNG.png

Have you tried the sample program in this this thread?

Try debugging it and it would show an error code at some point,which will give you an idea on where the fault may be.

Arun

0 Kudos

1,443 Views
BlackNight
NXP Employee
NXP Employee
0 Kudos

1,443 Views
arunkumar1989
Contributor I

Hi Erich,

I forgot to mention this to you,when debugging i observed some odd things :

The code hangs at this particular ISR.

Capture1.PNG.png

After a little digging , found out that this was linked to the RTC settings.

So when i disabled the RTC Oscillator.So i disabled the RTC module from PE,the code moved forward,but again hit a snag.

Now its hanging at the WAIT1_WaitCycles loop

Capture1.PNG.png

So for a temporary solution i disabled all the wait functions in processorexpert.c and moved forward.

Next ,whe i ran the debugger ,it hanged at

Capture1.PNG.png

digging further into CDC1_App_Task(),i found that it was returning the ERR_BUSOFF (as you can see from above)

Could you shed some light on this error please?

Also i matched my crystal pins with the tower board reference circuit,but still the same result..

0 Kudos

1,443 Views
BlackNight
NXP Employee
NXP Employee

The ERR_BUSOFF means that the device has not been enumerated by the host.

Either you have no USB cable connected, or the drivers are not installed/running on the host.

Erich

0 Kudos

1,443 Views
arunkumar1989
Contributor I

Hey Eric,

I have been trying the USB module for the last week ,but still haven't got the system to recognize the drivers automatically :smileysad: .

I found some changes in your program that would conflict my hardware,please suggest if there is any possible way around them.

Firstly:

In my custom board:

PTE24 = ADC0_SE17/EXTAL1     (We have used this for the 50Mhz External reference clock)

PTA18,PTA19 = EXTAL0 and XTAL0 respectively for the 12MHz crystal.

XTAL32,EXTAL32 for the RTC.

In your example:

PTA18 = EXTAL0:50MHz external reference clock

PTE24,PTE25 = EXTAL0 and XTAL0 respectively for the 12MHz crystal.

Would this interchange of pins be a problem?(I have changed the system oscillator settings from oscillator1 to oscillator0 to compensate the change in the PLL0 section).

Secondly:

I noticed that in the tower board ,you are using a USB mini AB connector for communication,but i have a standard USB B connector socket in my custom board.Would that make any major difference in communication?

0 Kudos

1,443 Views
BlackNight
NXP Employee
NXP Employee

The choice of USB connector (mini, micro, etc) does not matter, as it is only the physical size.

But the clock settings and quartz used matters for sure. I have seen many designs not working with USB because of this, either because the microcontroller has problem, or the clock circuit was wrong or not correct (wrong C's, traces too long, inprecise quartz, etc). So it could be many issues with your design. What worked best for my own custom designs was to *exactly* use the same circuit as on a working evel board (like the tower module).

Or at least to use a working hardware as reference point. You might hook up your working Tower system with a scope and compare the clock and USB signals with your design?

0 Kudos

1,443 Views
arunkumar1989
Contributor I

My mask number is 3N96B.

And yeah there is no communication b/t pc and device.,although i still am getting 5v in the vcc line.My custom hardware has got the same clock settings as the k60 tower board,a 12 mhz crystal and a 50 mhz reference clock.

0 Kudos

1,446 Views
arunkumar1989
Contributor I

Nope it did not show up automatically,after i completed all those steps in my previous step it showed up(and remains there even when i unplug my device)?

I ran you .elf file as well,same result :smileysad:

0 Kudos

1,443 Views
BlackNight
NXP Employee
NXP Employee

Then the microcontroller is not talking 'USB' to the host PC.

Are you using the TWR-K60F120M with the TWR-SER? Can you check the jumper settings?

I have silicon mask 0N96B, maybe you have a different silicon?

Note that my .elf program only works on the TWR-K60F120M: it will not run on your custom board as you have different clocking.

0 Kudos

1,446 Views
arunkumar1989
Contributor I

Hey Erich,

I tried but i think its not working correctly.

Let me run you though it one tiny step at time. -;),perhaps you may find what i am doing wrong here:

1.I was able to program the controller successfully with the new code.

2.Then i connected my cable to my hardware first ,then the PC side usb port

3.No change or hardware detected in device manager.

(Running on win 7(32 bit) by the way)

4.In device manager,

I click Action->Add new legacy hardware->next->select the "Instal the hardware that i manually select from the list(Advanced)"->i select PORTS(COM & LPT) and click next->click on "Have Disk"-> a window pops up from which i point it my the cdc.inf file->Model i select as "Freescale CDC Device" ->click next->click next->windows warning appears(click install anyway)->finally i get a "Completing add hardware wizard" with a code 10 error .

error_usb.png

0 Kudos

1,446 Views
BlackNight
NXP Employee
NXP Employee

Hi Arun,

Has that 'Freescale CDC Device' shown up automatically in your device manager? I see it in your screenshot, but your text tells me that the device manager did not 'see' it automatically?

The thing is this: Windows needs to automatically detect that there is a new device. If not, then the USB device is not communicating.

I think I have never used the old Freescale legacy ARM compiler with the USB stack (I switched over to gcc as it has better performance), so it could be that the compiler/linker has not aligned the USB buffer descriptors?

Any chance that you could try things with CodeWarrior and gcc?

Can you program the .elf I have provided above with the TWR-K60F120M?

See

http://mcuoneclipse.com/2012/04/30/flashing-with-a-button-and-a-magic-wand/

Standalone Flash Programmer | MCU on Eclipse

how to download just an S19 or ELF file.

0 Kudos

1,446 Views
arunkumar1989
Contributor I

Edit:

Never mind the previous error,once i restarted code warrior and cleaned the project the errors vanished :smileyhappy:.

But i am facing another problem: device not recognized in pc(device manager),any legacy hardware i need to install before connecting my hardware to pc?

Also these are the changes i had done to your reference project which you had uploaded in your previous post.:

I had to change my timing settings a bit:

My External Crystal pins are PTA18 & PTA19

My external reference clock pin is PTE24

so,i had to use system oscillator 0,not system oscillator 1 in PLL0 settings.

I removed the LED1,2,3 components from my code.,using only FSL_USB_stack and WAIT.

0 Kudos

1,446 Views
BlackNight
NXP Employee
NXP Employee

Yes, you need Windows point to the .inf file present in

TWR-K60F120M_USB_CDC\Documentation\cdc.inf

see Tutorial: USB CDC with the KL25Z Freedom Board | MCU on Eclipse and search for cdc.inf

Then your device should be recognized.

See as well

http://mcuoneclipse.com/2012/03/15/usb-cdc-reloaded/

Erich

0 Kudos

1,446 Views
arunkumar1989
Contributor I

Hi Erich,

I am getting a bunch of errors after doing all the changes,any idea what may be causing this ?

error_usb.png

And it is able to generate the .afx file in-spite of the errors being generated. !!

0 Kudos

1,446 Views
BlackNight
NXP Employee
NXP Employee

Hi Arun,

this is 10.3, right?

Have you loaded the latest (released yesterday) *.PEupd files from GitHub?

Try close the project and open it again (project > close). Maybe the problem goes away. It might be one of the issues of 10.3 I was aware of (that's why 10.4 is much better in my view).

If this still does not help: can you post your project?

Erich

0 Kudos

1,446 Views
arunkumar1989
Contributor I

PS: i have already installed USB STACK ver 4.3

0 Kudos

1,446 Views
BlackNight
NXP Employee
NXP Employee

Hello Arun,

I think you wanted to say 'USB stack 4.1.1' as this is the latest one I'm aware of, as there is no such 4.3?

I want to thank Carlos for the nice mentioning of my work :smileyhappy:.

He is correct: I have not published a K60F120M USB example. Until right now!

Carlos is correct: the clock settings are the most difficult part, and in addition the K60 on my TWR-K60F120M board had a silicon issue too :-(.

So I decided to document the steps and workaround in a blog post:

USB with the TWR-K60F120M and TWR-K70F120M | MCU on Eclipse

For reference, I have attached to this reply my project with all sources generated, so you have something to try out.

Please check the jumper settings in above post, and then you should be able to use a terminal to the board and see the characters echoed.

Erich

1,446 Views
peterweatherall
Contributor I

Erich

What is required to reconfigure this project for HS USB using the TWR-SER2 board? Can this be done through PE? Thanks

0 Kudos