咨詢ch372傳輸數(shù)據(jù)格式的問(wèn)題

現(xiàn)在準(zhǔn)備用ch372b+msp430f149做a/d采集,然后把數(shù)據(jù)送到pc顯示,現(xiàn)在430發(fā)送字節(jié),pc采用提供的ch372debug界面可以接收到該字節(jié),我的問(wèn)題是我想顯示的不是字節(jié),而是10進(jìn)制的數(shù)字,該怎么修改?謝謝

ch372debug顯示的就是數(shù)字 只是16進(jìn)制的


請(qǐng)把你寫的下位機(jī)程序?qū)懴聛?lái)好嗎


好的#include #include "CH372V_Init_MSP430.h" unsigned char WatchPoint,itemp; unsigned char buffer[64],buffer1[64]; unsigned int k=0; unsigned char temp1,temp2; double temp; //發(fā)送單字節(jié)命令 void CH372V_SendCMD1(unsigned char Command) { CH372V_DIR = 0xFF; CH372V_OUT = Command; //發(fā)送數(shù)據(jù) CH372V_A0_HI; //A0=1命令 CH372V_CS_LO; //CS有效 CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 CH372V_CS_HI; //CS無(wú)效 } //發(fā)送單字節(jié)數(shù)據(jù) void CH372V_SendData(unsigned char data) { CH372V_DIR = 0xFF; CH372V_OUT = data; //發(fā)送數(shù)據(jù) CH372V_A0_LO; //A0=數(shù) CH372V_CS_LO; //CS有效 CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 CH372V_CS_HI; //CS無(wú)效 }

//接收數(shù)據(jù) unsigned char CH372V_RecData(void) { unsigned char data; CH372V_DIR = 0x00; CH372V_A0_LO; //A0=1命令 CH372V_CS_LO; //CS有效 CH372V_RD_LO; //WR有效 _NOP();_NOP();_NOP(); data=CH372V_IN; CH372V_RD_HI; //WR無(wú)效 CH372V_CS_HI; //CS無(wú)效 _NOP(); return data; } //設(shè)置VID和PID void CH372V_SetVIDPID(void) { CH372V_DIR = 0xFF; CH372V_OUT = 0x12; CH372V_CS_LO; //CS有效 CH372V_A0_HI; //A0=1命令 CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 _NOP();_NOP();_NOP(); itemp = (unsigned char)(CH372V_VID&0xff); //VID低字節(jié) CH372V_OUT = 0x48;//itemp; CH372V_A0_LO; //A0=0數(shù)據(jù) CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 _NOP();_NOP();_NOP(); itemp = (unsigned char)((CH372V_VID>>8)&0xff); //VID高字節(jié) CH372V_OUT = 0x43;//itemp; CH372V_A0_LO; //A0=0數(shù)據(jù) CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 _NOP();_NOP();_NOP(); itemp = (unsigned char)(CH372V_PID&0xff); //PID低字節(jié) CH372V_OUT = 0x37;//itemp; CH372V_A0_LO; //A0=0數(shù)據(jù) CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 _NOP();_NOP();_NOP(); itemp = (unsigned char)((CH372V_PID>>8)&0xff); //PID高字節(jié) CH372V_OUT = 0x55;//itemp; CH372V_A0_LO; //A0=0數(shù)據(jù) CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 CH372V_CS_HI; //CS無(wú)效 _NOP();_NOP();_NOP(); }

//發(fā)送帶有返回的單字節(jié)命令 unsigned char CH372V_SendCMD2(unsigned char Command,unsigned char Parameter) { unsigned char result; CH372V_DIR = 0xFF; CH372V_OUT = Command; //發(fā)送數(shù)據(jù) CH372V_CS_LO; //CS有效 CH372V_A0_HI; //A0=1命令 CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 _NOP();_NOP();_NOP(); CH372V_OUT = Parameter; //發(fā)送數(shù)據(jù) CH372V_A0_LO; //A0=0命令 CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 Delayt(2); CH372V_DIR = 0x00; CH372V_RD_LO; //RD有效 _NOP();_NOP();_NOP(); result = CH372V_IN; //讀取數(shù)據(jù) CH372V_RD_HI; //RD無(wú)效 CH372V_CS_HI; //CS無(wú)效 CH372V_DIR = 0xFF; return result; }

void Delayt(unsigned int dtime) { unsigned int i,j; for(j=0;j for(i=0;i<((MCLK/500)-3);i++); } }

void InitOSC(void) { //MCLK=SMLCLK=4MHz,ACLK=32768 unsigned char i,j; //設(shè)置系統(tǒng)時(shí)鐘 BCSCTL1 = 0x00; //啟動(dòng)XT2晶振,ACLK為XT1(32KHz) BCSCTL2 = 0x88; //MCLK為XT2不分頻;SMCLK為XT2,4MHz j=0; while(1) { IFG1 &= ~OFIFG; //清OSCFault標(biāo)志 for (i=0xFF;i>0;--i); //延時(shí)等待 if ((IFG1 & OFIFG)!=0) { BCSCTL1 = 0x00; //啟動(dòng)XT2晶振,ACLK為XT1(32KHz) BCSCTL2 = 0X88; //MCLK為XT2不分頻,SMCLK為XT2不分頻 j++; //如果檢測(cè)到振蕩器失效,則計(jì)數(shù) if (j>10) //如果計(jì)數(shù)值超過(guò)10次,則認(rèn)為是硬件問(wèn)題 ; //OSCFault(); } else { for (i=0xFF;i>0;--i); //等待振蕩器達(dá)到足夠的幅度 IFG1 &= ~OFIFG; //清OSCFault標(biāo)志 IE1 |= OFIE + ACCVIE; //振蕩器故障,F(xiàn)LASH非法訪問(wèn)中斷允許 break; } } }

void CH372V_Init(void) { //首先初始化端口 CH372V_DIR |= 0xFF; CH372V_WR_HI; //WR無(wú)效 CH372V_WR_DIR |= CH372V_WR; CH372V_RD_HI; //RD無(wú)效 CH372V_RD_DIR |= CH372V_RD; CH372V_CS_HI; //CS無(wú)效 CH372V_CS_DIR |= CH372V_CS; CH372V_A0_HI; //A0=1命令 CH372V_A0_DIR |= CH372V_A0; //第一部分硬件復(fù)位 CH372V_SendCMD1(0x05); Delayt(4000); //延時(shí)40ms //第二部分設(shè)置VID和PID CH372V_SetVIDPID(); //第三部分設(shè)置USB工作模式 WatchPoint = CH372V_SendCMD2(0x15,0x02); _NOP(); //在這里加入斷點(diǎn)觀察WatchPoint }

void main(void) { unsigned char i; WDTCTL = WDTPW + WDTHOLD; P6SEL|=BIT0; ADC12CTL0 = SHT0_8 + ADC12ON+MSC; ADC12CTL1 = SHP+CONSEQ_1; ADC12MCTL0=INCH_0+EOS; ADC12IE=BIT0; //允許中斷 ADC12CTL0 |= ENC; P3DIR|=0XFF; P2IE|=BIT5; P2SEL|=BIT5; P2IES|=BIT5; InitOSC(); CH372V_Init(); // CH372V_SendCMD1(0x06); //CH372V_SendData(0x55); //P3OUT=CH372V_RecData(); //CH372V_SendCMD1(0x06); //CH372V_SendData(0xaa); //P3OUT=CH372V_RecData(); _BIS_SR(GIE); while(1) { ADC12CTL0|= ADC12SC; if(k>=64) { CH372V_SendCMD1(0x2b); CH372V_SendData(64); for(i=0;i<64;i++) {//CH372V_SendData(0x01); CH372V_SendData(buffer1[i]); } } } } #pragma vector=PORT2_VECTOR __interrupt void P2ISR(void) { unsigned char status,length,i;

CH372V_SendCMD1(0X22); status=CH372V_RecData(); /*switch(status) { case 0x02: { CH372V_SendCMD1(0x28); length=CH372V_RecData(); for(i=0;ibuffer[i]=CH372V_RecData(); break; } case 0x0a:{ CH372V_SendCMD1(0x23); break; } default:{ CH372V_SendCMD1(0x23); break; } } */ if(status==0x0a) CH372V_SendCMD1(0x23); } #pragma vector=ADC_VECTOR __interrupt void ADC12_ISR (void) { ADC12CTL0&=~ENC; temp=ADC12MEM0; temp1=temp&0x0ff; temp2=(temp&0xf00)>>8; buffer1[k]=temp1; buffer1[k+1]=temp2; k++; }


#include #include "CH372V_Init_MSP430.h" unsigned char WatchPoint,itemp; unsigned char buffer[64],buffer1[64]; unsigned int k=0; unsigned char temp1,temp2; double temp; //發(fā)送單字節(jié)命令 void CH372V_SendCMD1(unsigned char Command) { CH372V_DIR = 0xFF; CH372V_OUT = Command; //發(fā)送數(shù)據(jù) CH372V_A0_HI; //A0=1命令 CH372V_CS_LO; //CS有效 CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 CH372V_CS_HI; //CS無(wú)效 } //發(fā)送單字節(jié)數(shù)據(jù) void CH372V_SendData(unsigned char data) { CH372V_DIR = 0xFF; CH372V_OUT = data; //發(fā)送數(shù)據(jù) CH372V_A0_LO; //A0=數(shù) CH372V_CS_LO; //CS有效 CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 CH372V_CS_HI; //CS無(wú)效 }

//接收數(shù)據(jù) unsigned char CH372V_RecData(void) { unsigned char data; CH372V_DIR = 0x00; CH372V_A0_LO; //A0=1命令 CH372V_CS_LO; //CS有效 CH372V_RD_LO; //WR有效 _NOP();_NOP();_NOP(); data=CH372V_IN; CH372V_RD_HI; //WR無(wú)效 CH372V_CS_HI; //CS無(wú)效 _NOP(); return data; } //設(shè)置VID和PID void CH372V_SetVIDPID(void) { CH372V_DIR = 0xFF; CH372V_OUT = 0x12; CH372V_CS_LO; //CS有效 CH372V_A0_HI; //A0=1命令 CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 _NOP();_NOP();_NOP();

itemp = (unsigned char)(CH372V_VID&0xff); //VID低字節(jié) CH372V_OUT = 0x48;//itemp; CH372V_A0_LO; //A0=0數(shù)據(jù) CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 _NOP();_NOP();_NOP();

itemp = (unsigned char)((CH372V_VID>>8)&0xff); //VID高字節(jié) CH372V_OUT = 0x43;//itemp; CH372V_A0_LO; //A0=0數(shù)據(jù) CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 _NOP();_NOP();_NOP();

itemp = (unsigned char)(CH372V_PID&0xff); //PID低字節(jié) CH372V_OUT = 0x37;//itemp; CH372V_A0_LO; //A0=0數(shù)據(jù) CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 _NOP();_NOP();_NOP();

itemp = (unsigned char)((CH372V_PID>>8)&0xff); //PID高字節(jié) CH372V_OUT = 0x55;//itemp; CH372V_A0_LO; //A0=0數(shù)據(jù) CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效 CH372V_CS_HI; //CS無(wú)效 _NOP();_NOP();_NOP(); }

//發(fā)送帶有返回的單字節(jié)命令 unsigned char CH372V_SendCMD2(unsigned char Command,unsigned char Parameter) { unsigned char result;

CH372V_DIR = 0xFF; CH372V_OUT = Command; //發(fā)送數(shù)據(jù) CH372V_CS_LO; //CS有效 CH372V_A0_HI; //A0=1命令 CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效

_NOP();_NOP();_NOP();

CH372V_OUT = Parameter; //發(fā)送數(shù)據(jù) CH372V_A0_LO; //A0=0命令 CH372V_WR_LO; //WR有效 _NOP();_NOP();_NOP(); CH372V_WR_HI; //WR無(wú)效

Delayt(2);

CH372V_DIR = 0x00; CH372V_RD_LO; //RD有效 _NOP();_NOP();_NOP(); result = CH372V_IN; //讀取數(shù)據(jù) CH372V_RD_HI; //RD無(wú)效 CH372V_CS_HI; //CS無(wú)效 CH372V_DIR = 0xFF; return result; }

void Delayt(unsigned int dtime) { unsigned int i,j; for(j=0;jfor(i=0;i<((MCLK/500)-3);i++); } }

void InitOSC(void) { //MCLK=SMLCLK=4MHz,ACLK=32768 unsigned char i,j; //設(shè)置系統(tǒng)時(shí)鐘 BCSCTL1 = 0x00; //啟動(dòng)XT2晶振,ACLK為XT1(32KHz) BCSCTL2 = 0x88; //MCLK為XT2不分頻;SMCLK為XT2,4MHz j=0; while(1) { IFG1 &= ~OFIFG; //清OSCFault標(biāo)志 for (i=0xFF;i>0;--i); //延時(shí)等待 if ((IFG1 & OFIFG)!=0) { BCSCTL1 = 0x00; //啟動(dòng)XT2晶振,ACLK為XT1(32KHz) BCSCTL2 = 0X88; //MCLK為XT2不分頻,SMCLK為XT2不分頻 j++; //如果檢測(cè)到振蕩器失效,則計(jì)數(shù) if (j>10) //如果計(jì)數(shù)值超過(guò)10次,則認(rèn)為是硬件問(wèn)題 ; //OSCFault(); } else { for (i=0xFF;i>0;--i); //等待振蕩器達(dá)到足夠的幅度 IFG1 &= ~OFIFG; //清OSCFault標(biāo)志 IE1 |= OFIE + ACCVIE; //振蕩器故障,F(xiàn)LASH非法訪問(wèn)中斷允許 break; } } }

void CH372V_Init(void) { //首先初始化端口 CH372V_DIR |= 0xFF; CH372V_WR_HI; //WR無(wú)效 CH372V_WR_DIR |= CH372V_WR; CH372V_RD_HI; //RD無(wú)效 CH372V_RD_DIR |= CH372V_RD; CH372V_CS_HI; //CS無(wú)效 CH372V_CS_DIR |= CH372V_CS; CH372V_A0_HI; //A0=1命令 CH372V_A0_DIR |= CH372V_A0; //第一部分硬件復(fù)位 CH372V_SendCMD1(0x05); Delayt(4000); //延時(shí)40ms //第二部分設(shè)置VID和PID CH372V_SetVIDPID(); //第三部分設(shè)置USB工作模式 WatchPoint = CH372V_SendCMD2(0x15,0x02); _NOP(); //在這里加入斷點(diǎn)觀察WatchPoint }

void main(void) { unsigned char i; WDTCTL = WDTPW + WDTHOLD; P2IE|=BIT5; P2SEL|=BIT5; P2IES|=BIT5; InitOSC(); CH372V_Init(); _BIS_SR(GIE); while(1) { CH372V_SendCMD1(0x2b); CH372V_SendData(64); for(i=0;i<64;i++) { CH372V_SendData(0xff); } } } #pragma vector=PORT2_VECTOR __interrupt void P2ISR(void) { unsigned char status,length,i;

CH372V_SendCMD1(0X22); status=CH372V_RecData(); /*switch(status) { case 0x02: { CH372V_SendCMD1(0x28); length=CH372V_RecData(); for(i=0;ibuffer=CH372V_RecData(); break; } case 0x0a:{ CH372V_SendCMD1(0x23); break; } default:{ CH372V_SendCMD1(0x23); break; } } */ if(status==0x0a) CH372V_SendCMD1(0x23); }


用下面那個(gè),上面加了ad


謝謝,麻煩你把上位機(jī)的程序也寫下來(lái),好嗎,


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

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