完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,这是我第一次尝试在一个微控制器上实现/使用USB,这是一个相当大的挑战。我使用的是PIC32 MM000 64 GPM028,它应该作为USB主机来连接到一个连接的三星平板电脑,但是我不能让它工作。我需要做一个主机,因为我也想能够为平板电脑提供电源。我目前使用的软件是:μMPLAB X IDE V4.10μC MCC V3.45.1(核心V4.35)×XC32 V2.10μBug框架Lite,由Microchip技术库版本1.25.5从核心V4.15构建。错误UBSCANNONTRONETRATE和USB StimeMaCin进入保持状态。在许多其他关于USB主机问题的帖子中常见的问题是错误的USB时钟设置或内部振荡器的使用。我有一个外部石英晶体。它是一个+50ppm的12MHz石英晶体,它应该给我一个48 MHz的USB时钟速度,只有2400赫兹的偏差(0.00005%)。在“MCC系统模块”中,我选择了一个频率为12MHz的“外部时钟”,PLL分频器是1:4,乘法器是8:1。MCC中产生的频率为SysCLK/PBCK 24MHz,USB时钟为48 MHz。(MCC没有显示任何关于一个错误的USB时钟的警告/错误)。在“MCC的MLA USB主机Lite”中,我用“HID供应商”标示了最多1个HID设备和8的数据大小。堆的4096字节。最小的堆栈大小是64字节。我也定期调用我的.c.while循环中的USB主机任务。下面的输出显示了通过UART2(460800的BurdRead)打印到终端的USB总线主机调试输出。(注:我从它中删除了‘一’毫秒定时器ISR],而我只是。打印U1EIR每一行[除非它改变]……U1EIR中的10h的误差值是:BtoEF=总线周转时间错误标志BIT这一类型的错误发生在超过数据包(EOP)的前一个结束的空闲时间超过16比特时。我的5V电源来自平板的230V交流充电器。这也是与VBUS连接的,是我的PIC的3.3V电压调节器。这也是连接到VUSB 3V3的。我的USB连接到平板电脑:UBS55V从充电器USB连接到5V -连接到D的PIC USB连接+连接到D+的PIC USB接口没有连接GND连接到Grundif我没有错,VBUS被配置为输入和仅监测总线的电压,并且主要使用USB作为设备。如果支持OTG,只使用VBUSON/UBSID。但是,关于我的时钟的一个问题可能是错误的基频,但是MCC没有抱怨。在第27节中。“USB ON GO(OTG)”(DS61126)“第3页上的注释5是说:USB PLL UFIN要求:4 MHz & lt=UFL& lt=5兆赫,将购买一个4MHz +50ppm的新石英晶体来解决我的问题吗?或者可以选择3的PLL分频器吗?我的振荡器是不是错了?如果不是,什么会引起我的问题?我遗漏了一些函数调用吗?USB是错误的吗?谢谢你,我明天早上七点之前不能回答。
以上来自于百度翻译 以下为原文 Hi, this is my first time trying to implement/use USB on a Microcontroller and it's a pretty big challange. I'm using a PIC32MM0064GPM028 which should act as a USB-Host to communicate to a connected Samsung Tablet, but i can't get it working. I need to act as a host because i want also be able to supply the tablet with power. The software i'm currently using is: # MPLAB X IDE v4.10 # MCC v3.45.1 (Core v4.35) # XC32 v2.10 # USB Framework Lite by Microchip Technology Library version 1.25.5 built from core v4.15 The problem that i get is the error USB_CANNOT_ENUMERATE and the USB statemachine enters into the holding state. A common problem in many other posts regarding USB-Host problems was a wrong USB Clock setup or the use of the internal oscillator. I do have an external quartz crystal. It's a 12MHz quartz crystal with +-50ppm, which should give me a USB clock speed of 48MHz with a deviation of only 2400Hz (0.00005%). In "MCC#System Module" i selected "External Clock" with a frequency of 12MHz.My PLL divider is 1:4 and my multiplier is 8:1. The resulting frequencies shown in MCC are 24MHz for SYSCLK/PBCLK, and 48MHz for USB Clock. (MCC does not show any warnings/errors regarding a wrong USB-Clock.) In "MCC# MLA USB Host Lite" i've ticked "HID Vendor" with a maximum of 1 HID devices and a data size of 8. I'm initializing the TPL with the following Vendor- and ProductId which i've read via the Windows Device Manager. I did allocate 4096 Bytes for the heap. The minimum stack size is 64 Bytes. -------- u***_host_config.h -------- #define USB_SUPPORT_HOST #define NUM_TPL_ENTRIES 1 ... -------- u***_host_config.c -------- ... USB_TPL u***TPL[] = { // INIT_VID_PID(VendorId, ProductId), Configuration, ClientDriver, {flags} // INIT_CL_SC_P(Class, SubClass, Protocol), Configuration, ClientDriver, {flags} {INIT_VID_PID(0x04E8, 0x6860), 0, 0, {0}} }; I'm also calling USBHostTasks in my main.c while-loop on a regular basis. -------- main.c -------- int main(void) { SYSTEM_Initialize(); // When using interrupts, you need to set the Global Interrupt Enable bits. // Enable the Global Interrupts INTERRUPT_GlobalEnable(); // Disable the Global Interrupts //INTERRUPT_GlobalDisable(); ... while (StateMachine_isActive()) { StateMachine_action(); ... USBHostTasks(); ... } } The following output shows the u***_host.c debug output which is printed to a terminal via UART2 (Baudrate of 460800). (Note: I removed the '~' [One Millisecond Timer ISR] from it and i'm only printing the U1EIR once each line [unless it changes]...) Error value of 10h in U1EIR is: BTOEF = Bus Turnaround Time-out Error Flag bit -------- USB-host debug output -------- ***** System Initialized ***** HOST: Initializing DETACHED state. ***** EVENT_VBUS_REQUEST_POWER ***** [> HOST: Starting settling delay. HOST: Resetting the device. HOST: Reset recovery. HOST: Reset complete. HOST: Getting Device Descriptor size. #10h( BTOEF )!#!#!#!#!#!#!#!#!#!= HOST: Getting Device Descriptor size. #10h( BTOEF )!#!#!#!#!#!#!#!#!#!= HOST: Getting Device Descriptor size. #10h( BTOEF )!#!#!#!#!#!#!#!#!#!= HOST: Resetting the device. HOST: Reset recovery. HOST: Reset complete. HOST: Getting Device Descriptor size. #10h( BTOEF )!#!#!#!#!#!#!#!#!#!= HOST: Getting Device Descriptor size. #10h( BTOEF )!#!#!#!#!#!#!#!#!#!= HOST: Getting Device Descriptor size. #10h( BTOEF )!#!#!#!#!#!#!#!#!#!= HOST: Resetting the device. HOST: Reset recovery. HOST: Reset complete. HOST: Getting Device Descriptor size. #10h( BTOEF )!#!#!#!#!#!#!#!#!#!= HOST: Getting Device Descriptor size. #10h( BTOEF )!#!#!#!#!#!#!#!#!#!= HOST: Getting Device Descriptor size. #10h( BTOEF )!#!#!#!#!#!#!#!#!#!= HOST: Holding. ***** EVENT_CANNOT_ENUMERATE ***** The attached schematic shows my wiring: # CHARGER is my 5V power supply which comes from the 230V AC-Charger of the tablet. This is also connected to VBUS. # LDO is my 3.3V voltage regulator for the PIC. This is also connected to VUSB3V3. # TABLET is my USB-Connection to the tablet: USB_5V is connected to 5V from CHARGER USB_D- is connected to D- of the PIC USB_D+ is connected to D+ of the PIC USB_ID is not connected GND is connected to Ground If i'm not mistaken, VBUS is configured as input and only monitors the voltage of the bus and is mainly used if USB is used as a device. VBUSON/USB_ID would only be used if OTG is supported. One problem regarding my clock might be a wrong base frequency though, but MCC doesn't complain about it. In "Section 27. “USB OnThe-Go(OTG)” (DS61126)" note 5 on page 3 is saying: USB PLL UFIN requirements: 4 MHz <= UFIN <= 5 MHz # Would buying a new quartz crystal with 4MHz +-50ppm fix my problem? Or is it possible to select a PLL-Divider of 3? # Is my type of oscillator wrong? # If not what could cause my problems? # Am i missing some function calls? # Is the USB-Setup wrong? Thank you in advance EDIT Note: I'll not be able to answer before tomorrow morning 7 o'clock. Attached Image(s) |
|
相关推荐
3个回答
|
|
我没有做任何事情与PIC32毫米,但你应该能够预降低到4MHz,正如你所说的。如果不能做到这一点,那就太疯狂了。
以上来自于百度翻译 以下为原文 I have not done anything with the PIC32MM, but you should be able to prescale down to 4MHz, as you say. It would be crazy NOT to be able to do that. |
|
|
|
你好,我再次查看了数据表并检查了SPLLCON寄存器。3的PLL分频器是不可能的。
以上来自于百度翻译 以下为原文 Hi, i've looked into the datasheet again and checked the SPLLCON register. A PLL-Divider of 3 is not possible. Attached Image(s) |
|
|
|
嗨,现在看来工作了。我从UBS.HooHythHID.c/h切换到UbxHooStAuth.Gn.c/h(可以在Microchip GITHUB RePO中找到),并在UbclicliDRVTABLE中替换初始化和EvestHANDLE函数。除了CDC和HID之外,我不知道通用主机为什么不能在MCC中选择。不管怎样,设备连接和分离事件都被正确地检测到了。我现在试着谈谈平板电脑。
以上来自于百度翻译 以下为原文 Hi, it seems to work now. I switched from u***_host_hid.c/h to u***_host_generic.c/h (which can be found at the Microchip Github repo) and replaced the Initialization- and EventHandler-Function in the u***ClientDrvTable. I don't know why the generic host is not selectable in MCC in addition to CDC and HID... Anyways - the device attach and detachevents get detected correctly. I'll try now to talk to the tablet... |
|
|
|
只有小组成员才能发言,加入小组>>
5132 浏览 9 评论
1985 浏览 8 评论
1914 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3153 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2213 浏览 5 评论
699浏览 1评论
589浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
470浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
606浏览 0评论
497浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-5 05:55 , Processed in 1.683739 second(s), Total 83, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号