完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嘿,人们。我用的是PIC32 MX27 0F256D Rev A2,带有8MHz晶体。CPU和外围总线在40MHz。我的测试代码只包括USB设备通用HID和time5设置为溢出每1ms,并切换RA4每个溢出。PC USB和集线器不知道它是连接的。如果我在USB上评论与USB相关的3行,禁用USB,RA4引脚上观察到的波形是正确的,反相RA4电平每1ms。当使用USB时,RA4呈现一种奇怪的行为,在D+PIN从1到0的同时开始。D+PIN总是在1,短脉冲到0。图片附上。定时器4 IP=7,IS=3i在修订版A2(矿)有USB问题的32 MX27 0F256D的勘误表上,但目前我不知道如何根据勘误表进行必要的更改。关于USB库,它是从2010左右的一个旧版本的Microchip应用程序库中提取的。首先在MPLAB 8上开发了32 MX795F512L,后来导入了MPLAB X用于同一MCU,直到这里USB设备和USB代码工作。然后,(现在)我希望相同的代码MX27 0F256D,因为它们的USB模块是相同的,包括寄存器名和位。我只需要改变中断寄存器号以匹配32 MX70F256D、USB IPC7BITS、U1IP=4、IPC7BITS U1IS=0在UBJHALLIPPIC32上。HI下载了最后的Microchip库应用程序,在文件夹中没有找到32 MX。有人对此有想法吗?当做。
以上来自于百度翻译 以下为原文 Hey people. I'm using a PIC32MX270F256D rev A2 with 8MHz crystal. Cpu and peripheral bus at 40Mhz. Supplied with Pickit3. My test code includes only USB device generic HID and Timer5 set to overflow each 1ms, and toggle RA4 each overflow. PC USB and HUB are not recognizing it as connected. If I comment the 3 lines related to USB on main, disabling USB, the wave observed on RA4 pins is correct, inverting RA4 level each 1ms. When USB is used, RA4 presents a strange behavior that starts at the same time that D+ pin goes from 1 to 0. D+ pin is constantly in 1 with short pulses to 0. Pictures attached. Timer 4 IP = 7, IS = 3 I saw on errata of 32MX270F256D that revision A2 (mine) has USB issue, but currently I don't know how to make correctly the necessary changes according to errata. About the USB library, it's extracted from an old version of Microchip application libraries from around 2010. It was firstly developed on MPLAB 8 for 32MX795F512L, later imported to MPLAB X for the same MCU, and until here USB device and USB code was working. Then (now) I would like the same code for MX270F256D, since their USB modules are identical, including register names and bits. I only had to change the interrupt register number to match 32MX270F256D, USB IPC7bits.U1IP = 4, IPC7bits.U1IS = 0 on u***_hal_pic32.h. I did download of last Microchip libraries for applications and found nothing for 32MX on folders. Someone have idea about that? Regards. // DEVCFG3 // USERID = No Setting #pragma config PMDL1WAY = ON // Peripheral Module Disable Configuration (Allow only one reconfiguration) #pragma config IOL1WAY = ON // Peripheral Pin Select Configuration (Allow only one reconfiguration) #pragma config FUSBIDIO = OFF // USB USID Selection (Controlled by Port Function) #pragma config FVBUSONIO = OFF // USB VBUS ON Selection (Controlled by USB Module) // DEVCFG2 #pragma config FPLLIDIV = DIV_2 // PLL Input Divider (2x Divider) #pragma config FPLLMUL = MUL_20 // PLL Multiplier (20x Multiplier) #pragma config UPLLIDIV = DIV_2 // USB PLL Input Divider (2x Divider) #pragma config UPLLEN = ON // USB PLL Enable (Enabled) #pragma config FPLLODIV = DIV_2 // System PLL Output Clock Divider (PLL Divide by 2) // DEVCFG1 #pragma config FNOSC = PRIPLL // Oscillator Selection Bits (Primary Osc w/PLL (XT+,HS+,EC+PLL)) #pragma config FSOSCEN = OFF // Secondary Oscillator Enable (Disabled) #pragma config IESO = OFF // Internal/External Switch Over (Disabled) #pragma config POSCMOD = XT // Primary Oscillator Configuration (Primary osc enabled) #pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin (Disabled) #pragma config FPBDIV = DIV_1 // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/q) #pragma config FCKSM = CSDCMD // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled) #pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler (1:1048576) #pragma config WINDIS = OFF // Watchdog Timer Window Enable (Watchdog Timer is in Non-Window Mode) #pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Disabled (SWDTEN Bit Controls)) #pragma config FWDTWINSZ = WINSZ_25 // Watchdog Timer Window Size (Window Size is 25%) // DEVCFG0 #pragma config JTAGEN = OFF // JTAG Enable (JTAG Disabled) #pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select (Communicate on PGEC1/PGED1) #pragma config PWP = OFF // Program Flash Write Protect (Disable) #pragma config BWP = OFF // Boot Flash Write Protect bit (Protection Disabled) #pragma config CP = OFF // Code Protect (Protection Disabled) void main (void) { IoInit(); MyClockInit(PB_CLOCK); //USB Init //OSCCONbits.UFRCEN = 0; //while (!OSCCONbits.ULOCK) {} InitializeUSBSystem(); USBDeviceAttach(); //Interrupts INTConfigureSystem( INT_SYSTEM_CONFIG_MULT_VECTOR ); INTEnableInterrupts(); while (TRUE) { ProcessUSB(); } } UINT32 myClockCount = 0; BOOL MyClockInit( UINT pbClk ) { UINT32 counts; UINT32 div; if( pbClk >= 1000 ) { pbClk /= 1000; div = 1; do { counts = MY_CLOCK_PERIOD * pbClk / div; div <<= 1; }while( counts > 0xFFFF ); div >>= 1; if( div == 1 ) div = 0; else if( div == 2 ) div = 1; else if( div == 4 ) div = 2; else if( div == 8 ) div = 3; else if( div == 16 ) div = 4; else if( div == 32 ) div = 5; else if( div == 64 ) div = 6; else if( div == 256 ) div = 7; else return FALSE; T5CON = 0; Nop(); T5CONbits.TCKPS = div; TMR5 = 0; PR5 = counts - 1; IEC0bits.T5IE = 0; IFS0bits.T5IF = 0; IPC5bits.T5IP = 7; IPC5bits.T5IS = 3; IEC0bits.T5IE = 1; myClockCount = 0; T5CONbits.ON = 1; return TRUE; } return FALSE; } UINT32 MyClock(void) { return myClockCount; } void __ISR( _TIMER_5_VECTOR, IPL7SOFT ) Timer5Handler(void) { IFS0bits.T5IF = 0; myClockCount++; if( myClockCount == 0 ) SoftReset(); PIN_LED = !PIN_LED; //RA4 return; } Attached Image(s) |
|
相关推荐
3个回答
|
|
最后一个范围的照片看起来像一个“硬件线索”,而不是具体的软件。我这样说是因为下降的边缘不是很快,它只是一点点地运走,然后当USB线再次变高的时候变得很快。假设PIC没有被重置或类似的东西…也假设USB继续工作?如果1,你不切换RA4,或者切换另一个端口上的其他行,会发生什么?2)如果使用定时器的一些非整数int速率会发生什么,比如选择一些不能同步到USB脉冲的东西?我有一些奇怪的问题与软件崩溃和重置PIC导致引脚“运球”这样,但重置并不立即明显,因为一个或另一个原因…(我没想到调用一个简单的函数,比如“Sttok()”会导致处理器复位!-(活到老学到老…)
以上来自于百度翻译 以下为原文 That last scope photo looks like a "hardware clue" not specifically software. I say this because the falling edge is not fast, it just sort of dribbles down to nothing, then gets fast when the USB line goes high again. Assuming that the PIC is not being reset or something like that.... Also assuming that the USB continues to be working? What happens if, 1) You don't toggle RA4 or if you toggle some other line on another port? 2) What happens if you use some non integer int rate for the timer - like choose something that won't sync up to the USB pulsing? I have had weird issues with software crashing and resetting the PIC causing the pins to "dribble" off like this, but the reset was not immediately obvious because of one reason or another.... (And I did not expect that calling a simple function like "strtok()" would cause a processor reset! ;-) Live and learn....) HTH |
|
|
|
支持PIC32 MX的PLIB的最后版本是V2013-0615。IIRC,它支持PIC32MX2xx。尝试安装一个通用异常处理程序(在论坛中搜索一个),看看GE是否导致重置。
以上来自于百度翻译 以下为原文 The last version of PLIB that supports PIC32MX is v2013-06-15. IIRC it supports PIC32MX2xx. Try installing a general exception handler (search the forums for one) to see if a GE is causing a reset. |
|
|
|
问题是中断向量号。例如,我的USB设备应用程序代码使用矢量45作为PIC32MX795F512L,我改为30(PIC32MX270F256D u***矢量),现在一切正常。
以上来自于百度翻译 以下为原文 The problem was the interrupt vector number. My USB device app code was using vector 45 for PIC32MX795F512L for example, I changed to 30 (PIC32MX270F256D u*** vector), and now it's all working fine. |
|
|
|
只有小组成员才能发言,加入小组>>
5283 浏览 9 评论
2055 浏览 8 评论
1968 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3231 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2276 浏览 5 评论
820浏览 1评论
709浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
652浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
710浏览 0评论
605浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-12 04:31 , Processed in 0.961127 second(s), Total 46, Slave 41 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号