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