ch375調(diào)試中斷問(wèn)題

void CH375_INIT() { unsigned char i; unsigned char xdata str[20]; lcd_init() ;

CH375_WR_CMD_PORT(CMD_CHECK_EXIST); //測(cè)試CH375是否正常工作 CH375_WR_DAT_PORT(0x55); //寫(xiě)入測(cè)試數(shù)據(jù) i = CH375_RD_DAT_PORT(); //返回?cái)?shù)據(jù)應(yīng)該是測(cè)試數(shù)據(jù)取反

if(i != ~0x55) { for ( i=80; i!=0; i-- ) { CH375_WR_CMD_PORT(CMD_RESET_ALL); //多次重復(fù)發(fā)命令,執(zhí)行硬件復(fù)位 */ CH375_RD_DAT_PORT(); } CH375_WR_CMD_PORT(0); delay_ms(15); //延時(shí)50ms sprintf(str,"####################"); print_str(2,0,str); } CH375_WR_CMD_PORT(CMD_SET_USB_MODE); CH375_WR_DAT_PORT(0x02); //設(shè)置為使用內(nèi)置固件的USB設(shè)備方式 */ delay_ms(50); i = CH375_RD_DAT_PORT(); if(i == CMD_RET_SUCCESS) { sprintf(str,"枚舉成功!%bx ",CMD_RET_SUCCESS); print_str(1,0,str); } else { sprintf(str,"枚舉失敗!%x ",CMD_RET_ABORT); print_str(1,0,str); } /*******************外部中斷0初始化*************************/ IT0 = 0; //低電平觸發(fā) EX0 = 1; //開(kāi)外部中斷0 EA = 1; //開(kāi)中斷總開(kāi)關(guān) }

void CH375_ISR() interrupt 0 using 2 { unsigned char status = 0; unsigned char i, length; unsigned char buffer[20]; uchar xdata str2[20]; EA = 0;

CH375_WR_CMD_PORT(CMD_GET_STATUS); //獲取中斷狀態(tài)并取消中斷請(qǐng)求 status = CH375_RD_DAT_PORT(); //獲取中斷狀態(tài) sprintf(str2,"status: %bx ",status); print_str(2,0,str2); switch (status) { //分析中斷狀態(tài)處理 case USB_INT_EP2_OUT: //批量端點(diǎn)下傳成功 { CH375_WR_CMD_PORT(CMD_RD_USB_DATA); //從當(dāng)前USB中斷的端點(diǎn)緩沖區(qū)讀取數(shù)據(jù)塊,并釋放緩沖區(qū) length = CH375_RD_DAT_PORT(); //首先讀取后續(xù)數(shù)據(jù)長(zhǎng)度 for(i=0; i { buffer[i] = CH375_RD_DAT_PORT(); //接收數(shù)據(jù)包 } buffer[i] = '\0'; CH375_WR_CMD_PORT(CMD_WR_USB_DATA7); // 向USB端點(diǎn)2的發(fā)送緩沖區(qū)寫(xiě)入數(shù)據(jù)塊 CH375_WR_DAT_PORT(length); // 首先寫(xiě)入后續(xù)數(shù)據(jù)長(zhǎng)度,回傳剛接收到的數(shù)據(jù)長(zhǎng)度 for ( i=0;i< length; i++) { CH375_WR_DAT_PORT(buffer[i]+1); // 數(shù)據(jù)取反后返回,由計(jì)算機(jī)應(yīng)用程序測(cè)試數(shù)據(jù)是否正確 */ } break; } case USB_INT_EP2_IN: //批量數(shù)據(jù)上傳成功 { CH375_WR_CMD_PORT(CMD_UNLOCK_USB); //釋放當(dāng)前USB緩沖區(qū) break; } default: { //其它中斷,未用到,解鎖后退出即可 CH375_WR_CMD_PORT(CMD_UNLOCK_USB); //釋放當(dāng)前USB緩沖區(qū) break; } } // EA = 1; }

想問(wèn)沁恒的工程師們一個(gè)問(wèn)題,我最近做一個(gè)項(xiàng)目,用的是華邦單片機(jī)做USB設(shè)備開(kāi)發(fā),CH375枚舉成功,發(fā)送數(shù)據(jù)后也能響應(yīng)中斷,但是在中斷服務(wù)程序中用CH375_WR_CMD_PORT(CMD_GET_STATUS);獲得中斷狀態(tài),返回中斷狀態(tài)傎都是0,測(cè)中斷引腳一直為低電平,也就是說(shuō)CH375_WR_CMD_PORT(CMD_GET_STATUS)命令執(zhí)行不成功,不然的話(huà),這個(gè)引腳會(huì)變成高電平,請(qǐng)問(wèn)我的說(shuō)法是不是正確?上面貼的是初始化和中斷程序,問(wèn)題急待解決,匆吝賜教!


熱門(mén)產(chǎn)品 : CH390:以太網(wǎng)控制器芯片

下面的字體怎么變成這樣,我沒(méi)有設(shè)置啊,再貼下

void CH375_INIT() { unsigned char i; unsigned char xdata str[20];

lcd_init()

CH375_WR_CMD_PORT(CMD_CHECK_EXIST); //測(cè)試CH375是否正常工作 CH375_WR_DAT_PORT(0x55); //寫(xiě)入測(cè)試數(shù)據(jù) i = CH375_RD_DAT_PORT(); //返回?cái)?shù)據(jù)應(yīng)該是測(cè)試數(shù)據(jù)取反

if(i != ~0x55) { for ( i=80; i!=0; i-- ) { CH375_WR_CMD_PORT(CMD_RESET_ALL); //多次重復(fù)發(fā)命令,執(zhí)行硬件復(fù)位 */ CH375_RD_DAT_PORT(); } CH375_WR_CMD_PORT(0); delay_ms(15); //延時(shí)50ms sprintf(str,"####################"); print_str(2,0,str); } CH375_WR_CMD_PORT(CMD_SET_USB_MODE); CH375_WR_DAT_PORT(0x02); //設(shè)置為使用內(nèi)置固件的USB設(shè)備方式 */ delay_ms(50); i = CH375_RD_DAT_PORT(); if(i == CMD_RET_SUCCESS) { sprintf(str,"枚舉成功!%bx ",CMD_RET_SUCCESS); print_str(1,0,str); } else { sprintf(str,"枚舉失敗!%x ",CMD_RET_ABORT); print_str(1,0,str); } /*******************外部中斷0初始化*************************/ IT0 = 0; //低電平觸發(fā) EX0 = 1; //開(kāi)外部中斷0 EA = 1; //開(kāi)中斷總開(kāi)關(guān) }

void CH375_ISR() interrupt 0 using 2 { unsigned char status = 0; unsigned char i, length; unsigned char buffer[20]; uchar xdata str2[20]; EA = 0;

CH375_WR_CMD_PORT(CMD_GET_STATUS); //獲取中斷狀態(tài)并取消中斷請(qǐng)求 status = CH375_RD_DAT_PORT(); //獲取中斷狀態(tài)

sprintf(str2,"status: %bx ",status); print_str(2,0,str2); switch (status) { //分析中斷狀態(tài)處理 case USB_INT_EP2_OUT: //批量端點(diǎn)下傳成功 { CH375_WR_CMD_PORT(CMD_RD_USB_DATA); //從當(dāng)前USB中斷的端點(diǎn)緩沖區(qū)讀取數(shù)據(jù)塊,并釋放緩沖區(qū) length = CH375_RD_DAT_PORT(); //首先讀取后續(xù)數(shù)據(jù)長(zhǎng)度 for(i=0; i{ buffer = CH375_RD_DAT_PORT(); //接收數(shù)據(jù)包 } buffer = '\0'; CH375_WR_CMD_PORT(CMD_WR_USB_DATA7); // 向USB端點(diǎn)2的發(fā)送緩沖區(qū)寫(xiě)入數(shù)據(jù)塊 CH375_WR_DAT_PORT(length); // 首先寫(xiě)入后續(xù)數(shù)據(jù)長(zhǎng)度,回傳剛接收到的數(shù)據(jù)長(zhǎng)度 for ( i=0;i< length; i++) { CH375_WR_DAT_PORT(buffer+1); // 數(shù)據(jù)取反后返回,由計(jì)算機(jī)應(yīng)用程序測(cè)試數(shù)據(jù)是否正確 */ } break; } case USB_INT_EP2_IN: //批量數(shù)據(jù)上傳成功 { CH375_WR_CMD_PORT(CMD_UNLOCK_USB); //釋放當(dāng)前USB緩沖區(qū) break; } default: { //其它中斷,未用到,解鎖后退出即可 CH375_WR_CMD_PORT(CMD_UNLOCK_USB); //釋放當(dāng)前USB緩沖區(qū) break; } } // EA = 1; }

想問(wèn)沁恒的工程師們一個(gè)問(wèn)題,我最近做一個(gè)項(xiàng)目,用的是華邦單片機(jī)做USB設(shè)備開(kāi)發(fā),CH375枚舉成功,發(fā)送數(shù)據(jù)后也能響應(yīng)中斷,但是在中斷服務(wù)程序中用CH375_WR_CMD_PORT(CMD_GET_STATUS);獲得中斷狀態(tài),返回中斷狀態(tài)傎都是0,測(cè)中斷引腳一直為低電平,也就是說(shuō)CH375_WR_CMD_PORT(CMD_GET_STATUS)命令執(zhí)行不成功,不然的話(huà),這個(gè)引腳會(huì)變成高電平,請(qǐng)問(wèn)我的說(shuō)法是不是正確?上面貼的是初始化和中斷程序,問(wèn)題急待解決,匆吝賜教!


/******************************************* CH375B驅(qū)動(dòng)程序V0.1 MCU:W78E356A OSC:40MHz *******************************************/ #include #include

#include "CH375INC.H" #include "W78E365.H"

/******************************************* INT:pin12(INT0) CH375_CS:此引腳接地 CH375_WR:p10 CH375_RD:p11 CH375_A0:p12

********************************************/ #define OSC 24 #define CH375_DQ P0

sbit CH375_RD = P1^4; sbit CH375_A0 = P1^6; sbit CH375_WR = P1^7;

extern void lcd_init(); extern void print_str(unsigned char x,unsigned char y,unsigned char *str); extern void usart_print(unsigned char *str);

//******************************************************** //晶體用 40MHz //******************************************************** void delay_us(int n) { uchar i;

while(n--) { for( i = 0;i<(OSC/12);i++) { ; } } }

void delay_ms( int n) { while(n--) { delay_us(1000); } }

void CH375_WR_CMD_PORT( unsigned char cmd ) { delay_us(2); CH375_DQ = cmd; CH375_A0 = 1; //選擇CH375的命令口 CH375_RD = 1; CH375_WR = 0; _nop_();_nop_(); CH375_WR = 1; CH375_A0 = 0; CH375_RD = 1; P0 = 0xff; delay_us(2); }

void CH375_WR_DAT_PORT( unsigned char dat ) { delay_us(1); CH375_DQ = dat; CH375_A0 = 0; CH375_RD = 1; CH375_WR = 0; _nop_();_nop_(); //CH375_WR產(chǎn)生寬度至少為80nS的低電平脈沖 CH375_WR = 1; CH375_A0 = 0; CH375_RD = 1; P0 = 0xff; delay_us(1); }

unsigned char CH375_RD_DAT_PORT(void) { unsigned char dat = 0; delay_us(2); P0 = 0xFF; //將數(shù)據(jù)端口設(shè)置為輸入 CH375_A0 = 0; CH375_RD = 0; CH375_WR = 1; dat = P0; CH375_RD = 1; CH375_A0 = 0; delay_us(2); return dat; }

void CH375_INIT() { unsigned char i; unsigned char xdata str[20]; lcd_init() ;

CH375_WR_CMD_PORT(CMD_CHECK_EXIST); //測(cè)試CH375是否正常工作 CH375_WR_DAT_PORT(0x55); //寫(xiě)入測(cè)試數(shù)據(jù) i = CH375_RD_DAT_PORT(); //返回?cái)?shù)據(jù)應(yīng)該是測(cè)試數(shù)據(jù)取反

if(i != ~0x55) { for ( i=80; i!=0; i-- ) { CH375_WR_CMD_PORT(CMD_RESET_ALL); //多次重復(fù)發(fā)命令,執(zhí)行硬件復(fù)位 */ CH375_RD_DAT_PORT(); } CH375_WR_CMD_PORT(0); delay_ms(15); //延時(shí)50ms sprintf(str,"####################"); print_str(2,0,str); } CH375_WR_CMD_PORT(CMD_SET_USB_MODE); CH375_WR_DAT_PORT(0x02); //設(shè)置為使用內(nèi)置固件的USB設(shè)備方式 */ delay_ms(50); i = CH375_RD_DAT_PORT(); if(i == CMD_RET_SUCCESS) { sprintf(str,"枚舉成功!%bx ",CMD_RET_SUCCESS); print_str(1,0,str); } else { sprintf(str,"枚舉失敗!%x ",CMD_RET_ABORT); print_str(1,0,str); } /*******************外部中斷0初始化*************************/ IT0 = 0; //低電平觸發(fā) EX0 = 1; //開(kāi)外部中斷0 EA = 1; //開(kāi)中斷總開(kāi)關(guān) }

void CH375_ISR() interrupt 0 using 2 { unsigned char status = 0; unsigned char i, length; unsigned char buffer[20]; uchar xdata str2[20]; EA = 0;

CH375_WR_CMD_PORT(CMD_GET_STATUS); //獲取中斷狀態(tài)并取消中斷請(qǐng)求 status = CH375_RD_DAT_PORT(); //獲取中斷狀態(tài) sprintf(str2,"status: %bx ",status); print_str(2,0,str2); switch (status) { //分析中斷狀態(tài)處理 case USB_INT_EP2_OUT: //批量端點(diǎn)下傳成功 { CH375_WR_CMD_PORT(CMD_RD_USB_DATA); //從當(dāng)前USB中斷的端點(diǎn)緩沖區(qū)讀取數(shù)據(jù)塊,并釋放緩沖區(qū) length = CH375_RD_DAT_PORT(); //首先讀取后續(xù)數(shù)據(jù)長(zhǎng)度 for(i=0; i { buffer[i] = CH375_RD_DAT_PORT(); //接收數(shù)據(jù)包 } buffer[i] = '\0'; CH375_WR_CMD_PORT(CMD_WR_USB_DATA7); // 向USB端點(diǎn)2的發(fā)送緩沖區(qū)寫(xiě)入數(shù)據(jù)塊 CH375_WR_DAT_PORT(length); // 首先寫(xiě)入后續(xù)數(shù)據(jù)長(zhǎng)度,回傳剛接收到的數(shù)據(jù)長(zhǎng)度 for ( i=0;i< length; i++) { CH375_WR_DAT_PORT(buffer[i]+1); // 數(shù)據(jù)取反后返回,由計(jì)算機(jī)應(yīng)用程序測(cè)試數(shù)據(jù)是否正確 */ } break; } case USB_INT_EP2_IN: //批量數(shù)據(jù)上傳成功 { CH375_WR_CMD_PORT(CMD_UNLOCK_USB); //釋放當(dāng)前USB緩沖區(qū) break; } default: { //其它中斷,未用到,解鎖后退出即可 CH375_WR_CMD_PORT(CMD_UNLOCK_USB); //釋放當(dāng)前USB緩沖區(qū) break; } } // EA = 1; }


完整的程序已經(jīng)貼上


unsigned char CH375_RD_DAT_PORT(void) { unsigned char dat = 0; delay_us(2); P0 = 0xFF; //將數(shù)據(jù)端口設(shè)置為輸入 CH375_WR = 1; CH375_A0 = 0; CH375_RD = 0; _nop_();_nop_(); dat = P0; CH375_RD = 1; CH375_A0 = 0; delay_us(2); return dat; } 在程序中看到你是外掛了一個(gè)LCD,ch375的片選是直接接地的,LCD 的連線(xiàn)有沒(méi)有和ch375的連線(xiàn)復(fù)用,如果有的話(huà),要注意的是在操作ch375的時(shí)候,不能片選到你的lcd


sbit RS = P1^5; //0:命令,1:數(shù)據(jù) sbit RW = P3^4; //0:寫(xiě)操作,1:讀操作 sbit EN = P3^7; //高電平使能

對(duì),ch375的片選是直接接地的,上面是LCD的控制線(xiàn),LCD數(shù)據(jù)線(xiàn)也是P0端口,數(shù)據(jù)端口復(fù)用這樣會(huì)不會(huì)有問(wèn)題呢?


LCD我是用來(lái)顯示調(diào)試信息的


只要兩個(gè)不同時(shí)操作就可以了,也可以先把lcd那部分去掉,上位機(jī)使用DEBUG372調(diào)試.


是啊,應(yīng)該沒(méi)有問(wèn)題啊,我換了用串口調(diào)試,應(yīng)該說(shuō)能枚舉,證明讀寫(xiě)時(shí)序正常,可為什么中斷之后又不能正常讀寫(xiě)呢?


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

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