CH582M_CDC設(shè)備請(qǐng)求描述符失敗

打了5塊樣板,同一個(gè)程序不斷下載測(cè)試,有一個(gè)板子一直正常,其它板子時(shí)好時(shí)壞,什么原因呢?怎樣查找錯(cuò)誤?故障時(shí)候掃描不到usb port,設(shè)備管理器提示未知設(shè)備(設(shè)備請(qǐng)求描述符失敗)

#include?"CH58x_common.h"
#include?"main.h"
#include?"ads1110.h"
#include?"atk_lora_01.h"
extern?void?InitUSBDevPara(void);
extern?void?InitUSBDevice(void);
extern?void?USB_IRQProcessHandler(?void?);
extern?UINT8?SendUSBData(UINT8?*p_send_dat,UINT16?send_len);

extern?UINT8?Ep1DataOUTLen?;
extern?UINT8?Ep1DataOUTFlag?;
extern?UINT8?Ep1OUTDataBuf[MAX_PACKET_SIZE];

uint8_t?lora_send_data_process(uint8_t*?txbuf,int32_t?dat);

//#define?LORA_MASTER_MODE
//#define?LORA_SLAVE_MODE

volatile?uint32_t?lora_AUX_flage?=?FALSE;
uint16_t?aux_timeout=1000;
uint8_t?ads1110_delay?=?10;
int32_t?adcValue=0;
uint8_t?adc_txBuf[20];
uint8_t?lora_txCnt=0;

uint16_t?master_add?=?0x1000;
uint16_t?slave_addr?=?0x0001;
uint8_t?master_channel?=?20;


void?DebugInit(?void?)
{
????GPIOB_SetBits(led1_pin);
????GPIOB_ModeCfg(?led1_pin,?GPIO_ModeOut_PP_5mA?);
????GPIOB_ModeCfg(?vout_pin,?GPIO_ModeOut_PP_20mA?);
}

int?main()
{
????SetSysClock(?CLK_SOURCE_PLL_60MHz?);

????DebugInit();??//PA9
????printf("start\n");

????InitUSBDevPara();
????InitUSBDevice();
????PFIC_EnableIRQ(?USB_IRQn?);

????I2CInit();
????ads1110_mode(SINGLE_MODE|PGA1|SPS15|DRDY);

????lora_GPIO_cfg();

????TMR0_TimerInit(?FREQ_SYS?/?10?);??????????????????//?設(shè)置定時(shí)時(shí)間?100ms
????TMR0_ITCfg(?ENABLE,?TMR0_3_IT_CYC_END?);??????????//?開(kāi)啟中斷
????PFIC_EnableIRQ(?TMR0_IRQn?);
????vout_on();
????lora_Sta?=?receiveSta;
????while(1)
????{

????????//????????SYS_ResetExecute();
//????????DelayMs(10);
//????????led1_toggle;
????????switch?(lora_Sta)?{
????????case?receiveSta:
????????????loraRxCnt?=?0;
????????????while(LORA_AUX_IN()?==?GPIO_High_Level)
????????????{
????????????????lora_AUX_flage?=?1;
????????????}
#ifdef?LORA_MASTER_MODE
????????????if(Ep1DataOUTFlag?==?1){
????????????????Ep1DataOUTFlag?=?0;
????????????????lora_clear_rxbuf();
????????????????for?(uint8_t?i?=?0;?i?<?Ep1DataOUTLen;?++i)?{
????????????????????loraRxBuf[i]?=?Ep1OUTDataBuf[i];
????????????????}
????????????????lora_Sta?=?sendSta;
????????????}else?if(lora_AUX_flage?==1){
????????????????lora_AUX_flage?=0;
????????????????SendUSBData(loraRxBuf,loraRxCnt);//?strlen(loraRxBuf));
????????????}
#else
????????????if(Ep1DataOUTFlag?==?1){
????????????????Ep1DataOUTFlag?=?0;
????????????????lora_clear_rxbuf();
????????????????for?(uint8_t?i?=?0;?i?<?Ep1DataOUTLen;?++i)?{
????????????????????loraRxBuf[i]?=?Ep1OUTDataBuf[i];
????????????????}
????????????????if((loraRxBuf[0]?==?'A')?&&?(loraRxBuf[1]?==?'T')){
????????????????????lora_Sta?=?configrueSta;
????????????????}
????????????????else?{
???????????????????//?getADS1110(&adcValue);
????????????????????lora_Sta?=?sendSta;
????????????????}
????????????}else?if(lora_AUX_flage?==1){
????????????????lora_AUX_flage?=0;
???????????????//?getADS1110(&adcValue);

????????????????if((loraRxBuf[0]?==?'A')?&&?(loraRxBuf[1]?==?'T')){
????????????????????lora_Sta?=?configrueSta;
????????????????}
????????????????else?{
????????????????????lora_Sta?=?sendSta;
????????????????}
????????????}
#endif


????????????break;
????????case?sendSta:
#ifdef?LORA_MASTER_MODE
????????????SendUSBData(loraRxBuf,?strlen(loraRxBuf));
????????????strcpy(loraRxBuf,"AT+CWMODE=0\r\n");
????????????if(lora_set_model(DISABLE,loraRxBuf)==FALSE){
????????????????strcpy(adc_txBuf,?"ERROR");
????????????}
????????????DelayMs(50);
????????????lora_sendData(adc_txBuf,?strlen(adc_txBuf));
????????????SendUSBData(adc_txBuf,?strlen(adc_txBuf));
????????????lora_clear_rxbuf();
????????????lora_Sta?=?receiveSta;
#else
????????????//SendUSBData(loraRxBuf,?loraRxCnt);
????????????strcpy(loraRxBuf,"AT+CWMODE=0\r\n");
????????????if(lora_set_model(DISABLE,loraRxBuf)==FALSE){
????????????????strcpy(adc_txBuf,?"ERROR");
????????????}
????????????adc_txBuf[0]?=?master_add>>8;
????????????adc_txBuf[1]?=?master_add?&?0x00ff;
????????????adc_txBuf[2]?=?master_channel;
????????????adc_txBuf[3]?=?adcValue>>24;
????????????adc_txBuf[4]?=?adcValue>>16;
????????????adc_txBuf[5]?=?adcValue>>8;
????????????adc_txBuf[6]?=?adcValue;
????????????DelayMs(50);
????????????lora_sendData(adc_txBuf,?7);
????????????SendUSBData(adc_txBuf,?7);
????????????lora_clear_rxbuf();
????????????lora_Sta?=?receiveSta;
#endif
????????????break;
????????case?configrueSta:
????????????lora_set_model(ENABLE,loraRxBuf);
????????????DelayMs(50);
????????????lora_sendCMD(loraRxBuf);
????????????aux_timeout?=?1000;
????????????while(LORA_AUX_IN()?==?GPIO_Low_Level){
????????????????DelayMs(1);
????????????????if(aux_timeout--?==?0){
????????????????????break;
????????????????}
????????????}
????????????aux_timeout?=?1000;
????????????while(LORA_AUX_IN()?==?GPIO_High_Level){
????????????????DelayMs(1);
????????????????if(aux_timeout--?==?0){
????????????????????break;
????????????????}
????????????}
????????????SendUSBData(loraRxBuf,?strlen(loraRxBuf));
????????????lora_clear_rxbuf();
????????????lora_Sta?=?receiveSta;
????????????break;
????????default:lora_Sta?=?receiveSta;
????????break;
????????}
????????USB_IRQProcessHandler();
????????//????????if(ads1110_delay?==?0){
????????//????????????ads1110_delay=5;
????????//????????????getADS1110(&adcValue);
????????//????????????sprintf(txBuf,"%d\r\n",adcValue);
????????//????????????SendUSBData(txBuf,strlen(txBuf));
????????//????????????GPIOB_InverseBits(led1_pin);
????????//????????}
????????//?注意當(dāng)主頻為80M時(shí),Sleep睡眠喚醒中斷不可調(diào)用flash內(nèi)代碼。
????????//????????LowPower_Sleep(?RB_PWR_RAM30K?|?RB_PWR_RAM2K?);???????//只保留30+2K?SRAM?供電
????????//????????HSECFG_Current(?HSE_RCur_100?);?????//?降為額定電流(低功耗函數(shù)中提升了HSE偏置電流)
????}
}

unsigned?int?crc16(unsigned?char?*puchMsg,?unsigned?int?usDataLen)
{
????unsigned?char?i;
????unsigned?int?crc?=?0xffff;
????unsigned?char?TT;
????while?(usDataLen--)?//????????
????{
????????crc?=?crc?^?(*puchMsg);
????????puchMsg++;
????????for?(i?=?0;?i?<?8;?i++)
????????{
????????????TT?=?crc?&?1;
????????????crc?=?crc?>>?1;
????????????crc?=?crc?&?0x7fff;
????????????if?(TT?==?1)
????????????????crc?=?crc?^?0xa001;
????????????crc?=?crc?&?0xffff;
????????}
????}
????return?crc;
}

uint8_t?lora_send_data_process(uint8_t*?txbuf,int32_t?dat){
????uint8_t?result?=?FALSE;
????uint8_t?num?=?0;
????uint16_t?crc?=0;
????txbuf[num++]?=?master_add?>>?8;
????txbuf[num++]?=?master_add;
????txbuf[num++]?=?master_channel;
????txbuf[num++]?=?slave_addr?>>?8;
????txbuf[num++]?=?slave_addr?&?0x00ff;
????txbuf[num++]?=?4;
????txbuf[num++]?=?dat?>>?24;
????txbuf[num++]?=?dat?>>?16;
????txbuf[num++]?=?dat?>>?8;
????txbuf[num++]?=?dat?;
????crc?=?crc16(txbuf,?num);
????txbuf[num++]?=?crc?>>?8;
????txbuf[num++]?=?crc?&?0x00ff;
????lora_sendData(loraTxBuf,?num);
????return?result;
}
uint8_t?receive_data_decode(uint8_t?*buf,uint8_t?len){
????uint8_t?result?=?FALSE;
????uint16_t?crc?=0;
????crc?=?crc16(buf,?len?-?2);
????if(((crc?&?0x00ff)?==?buf[len?-2])?&&?((crc?>>?8)?==?buf[len?-1])){
????????result?=?TRUE;
????}
????else?{
????????result?=?FALSE;
????}
????return?result;
}

__INTERRUPT
__HIGH_CODE
void?TMR0_IRQHandler(?void?)????????//?TMR0?定時(shí)中斷
{
????if?(?TMR0_GetITFlag(?TMR0_3_IT_CYC_END?)?)
????{
????????TMR0_ClearITFlag(?TMR0_3_IT_CYC_END?);??????//?清除中斷標(biāo)志
????????led1_toggle;

????}
}


無(wú)法識(shí)別的設(shè)備有可能跟硬件有關(guān)系,比如芯片焊接不好,外圍電容有問(wèn)題,供電不好。
如果都可以通過(guò)芯片內(nèi)置的BOOT,借助USB接口進(jìn)行下載,那基本可用排除硬件問(wèn)題(因?yàn)閁SB下載時(shí),至少說(shuō)明焊接,供電和USB走線問(wèn)題不大),如果USB下載都不行,那就不用查軟件,先按照焊接,供電,芯片外圍,USB走線查一下硬件問(wèn)題。


上面的代碼在進(jìn)行USB設(shè)備枚舉時(shí),建議使用USB中斷,這樣才能及時(shí)響應(yīng)主機(jī)的命令,因?yàn)榍懊娴耐ㄓ嵾€有比較大的延時(shí),可能造成枚舉失敗,這部分可以參考EVT里面的USB從機(jī)例子進(jìn)行移植。


謝謝,查出來(lái)了,確實(shí)是外圍芯片工作時(shí)序不對(duì)造成卡頓,電腦識(shí)別不了;可以把flash讀寫(xiě)詳細(xì)資料發(fā)一份么?謝謝!個(gè)人信息保護(hù),已隱藏


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频