USB problem on PK40 Kwikstick v4

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

USB problem on PK40 Kwikstick v4

1,337 Views
StefanHyl
Contributor I

Hello,

I have a Kwikstik board and I wanted to test the USB port especially the virtual com feature.

First i tried to build the example code but IAR compiler has a limit of 32k so that did not work.

Then i found the "Freescale MQX 3.7", tried the virtual_com example building with IAR. It receives chars but does not send any to PC. The code is so huge so i did not try to find the problem here.

After lots of tries with code downloaded from the Freescale site, (some are buggy), i finaly found CMXUSB_LITE_V1.

This code (not written for K40) seemed nicely written and documented, so i started porting it to K40 and GCC.

 

Now when all that is done, i have the same problem. It does receive characters but fails to send to PC.

When this happends I stop it and investigate,

My bdt look like this,

(gdb) x/128x  BDTMemory
0x20000000 <BDTMemory>:         0xc8    0x00    0x08    0x00    0xe0    0xe6 0xff    0x1f  0 rx even
0x20000008 <BDTMemory+8>:       0x00    0x00    0x00    0x00    0xe8    0xe6 0xff    0x1f    rx odd
0x20000010 <BDTMemory+16>:      0x60    0x00    0x00    0x00    0x60    0xe0 0xff    0x1f    tx even
0x20000018 <BDTMemory+24>:      0x00    0x00    0x00    0x00    0x60    0xe0 0xff    0x1f    tx odd
0x20000020 <BDTMemory+32>:      0x00    0x00    0x00    0x00    0x00    0x00 0x00    0x00  1
0x20000028 <BDTMemory+40>:      0x00    0x00    0x00    0x00    0x00    0x00 0x00    0x00
0x20000030 <BDTMemory+48>:      0x00    0x00    0x00    0x00    0x00    0x00 0x00    0x00
0x20000038 <BDTMemory+56>:      0x00    0x00    0x00    0x00    0x00    0x00 0x00    0x00
0x20000040 <BDTMemory+64>:      0x00    0x00    0x00    0x00    0x00    0x00 0x00    0x00  2
0x20000048 <BDTMemory+72>:      0x00    0x00    0x00    0x00    0x00    0x00 0x00    0x00
0x20000050 <BDTMemory+80>:      0x88    0x00    0x01    0x00    0x98    0xe6 0xff    0x1f    tx even
0x20000058 <BDTMemory+88>:      0x00    0x00    0x00    0x00    0x00    0x00 0x00    0x00
0x20000060 <BDTMemory+96>:      0x00    0x00    0x00    0x00    0xf0    0xe6 0xff    0x1f  3 rx even
0x20000068 <BDTMemory+104>:     0xc8    0x00    0x20    0x00    0x10    0xe7 0xff    0x1f    rx odd
0x20000070 <BDTMemory+112>:     0x00    0x00    0x00    0x00    0x00    0x00 0x00    0x00
0x20000078 <BDTMemory+120>:     0x00    0x00    0x00    0x00    0x00    0x00 0x00    0x00

 

It seems that the hardware fails to send for some reason, i can not figure it out. In <BDTMemory+80> it wants to send

1 character (on that address that ADDR points to I have a '1').

 

and the USB registers looks like this,

(gdb) s_usb
$2 = 0x4                              #1  PERID             
$3 = 0xfb                             #2  IDCOMP            
$4 = 0x33                             #3  REV               
$5 = 0x1                              #4  ADDINFO           
$6 = 0x60                             #5  OTGISTAT          
$7 = 0x0                              #6  OTGICR            
$8 = 0x0                              #7  OTGSTAT           
$9 = 0x84                             #8  OTGCTL            
$10 = 0x4                             #9  ISTAT             
$11 = 0x9f                            #10 INTEN             
$12 = 0x0                             #11 ERRSTAT           
$13 = 0xff                            #12 ERREN             
$14 = 0x0                             #13 STAT              
$15 = 0x81                            #14 CTL               
$16 = 0x6                             #15 ADDR              
$17 = 0x0                             #16 BDTPAGE1          
$18 = 0xc5                            #17 FRMNUML           
$19 = 0x1                             #18 FRMNUMH           
$20 = 0x0                             #19 TOKEN             
$21 = 0x0                             #20 SOFTHLD           
$22 = 0x0                             #21 BDTPAGE2          
$23 = 0x20                            #22 BDTPAGE3          
$24 = 0xd                             #23 ENDPOINT[0].ENDPT 
$25 = 0x15                            #24 ENDPOINT[1].ENDPT 
$26 = 0x15                            #25 ENDPOINT[2].ENDPT 
$27 = 0x19                            #26 ENDPOINT[3].ENDPT 
$28 = 0x0                             #27 ENDPOINT[4].ENDPT 
$29 = 0x0                             #28 ENDPOINT[5].ENDPT 
$30 = 0x0                             #29 ENDPOINT[6].ENDPT 
$31 = 0x0                             #30 ENDPOINT[7].ENDPT 
$32 = 0x0                             #31 ENDPOINT[8].ENDPT 
$33 = 0x0                             #32 ENDPOINT[9].ENDPT 
$34 = 0x0                             #33 ENDPOINT[10].ENDPT
$35 = 0x80                            #34 ENDPOINT[11].ENDPT
$36 = 0x10                            #35 ENDPOINT[12].ENDPT
$37 = 0x42                            #36 ENDPOINT[13].ENDPT
$38 = 0x0                             #37 ENDPOINT[14].ENDPT
$39 = 0x0                             #38 ENDPOINT[15].ENDPT
$40 = 0x0                             #39 USBCTRL;          
$41 = 0x80                            #40 OBSERVE;          
$42 = 0x10                            #41 CONTROL;          
$43 = 0x42                            #42 USBTRC0;          


I find it strange that,

ADDINFO   register contains 1, it indicates host mode?

ENDPT 11, 12, 13 seems to reflect values in OBSERVE, etc..

(I do not know if this is a GDB problem (using SEGGERS Jlink server)),

 

I have run out of guesses, is there anyone that can explain this?

One almost begin to think that the PK version of K40 maybe does not work to transmit, but there is probably a simplier explanation.

/stefan

 

 

0 Kudos
4 Replies

635 Views
ioderentz
Contributor I

Any news about this problem ? I verified the problem on a lot of different PCs with different O.S. (WinXP and Win7 64) Only in one case I can get it working on both sides (RX and TX) :  in all other  cases the PCs does not receives data from Kwikstik .

Any suggestion is welcome.

 

Best regards

0 Kudos

635 Views
StefanHyl
Contributor I

Hello again.

 

I got myself an USB hub (thanks ioderentz) and after that it works great (as long as i run everything from RAM, that is).

 

When running from flash the USB fails, it seems to be a clock problem. I have tried to setup the clock from code in ram (based on errata e2448), i have tried to disable the flash prefetch, but NO it does not work when running from flash.

 

My threads, and LCD display work fine when running in flash. But, i can not test much without a working serial com channel. When running from RAM all my added featurs work as expected.

 

About the original problem,

It is the USB master that controls both tx and rx, so a slave can only respond to packets comming from the master. It is rather strange that a HUB is needed to have this working. On the other hand, the USB spec. uses many pages to the describe the hub functionality. One can guess that the MS driver usbser.sys maybe do not follow the spec. at all points. I also have a real USB com emulator and it only uses 2 endpoints (works fine without a HUB).

Life would have been much easier if kwikstik had a mounted uart driver.

 

/stefan

0 Kudos

635 Views
ioderentz
Contributor I

Hi ,

I finally solved this problem.

It is an Hardware issue : the USB driver uses the internal voltage regulator. To keep it working without oscillation it needs (as indicated in the datasheet) a Capacitor of at least 2.2 uF connected between the Vout pin and GND. In the Kwikstik this is not done : there is only a 0.1 uF capacitor (C34) . Add a 2.2 uF capacitor in parallel to it and all will work fine !!!

 

Best regards

 

 

0 Kudos

635 Views
ioderentz
Contributor I

Hi,

I had a similar problem : try with an USB hub or a different PC.......

0 Kudos