完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
|
|
|
|
有代码吗???
|
|
|
|
可以给你QQ我吗??想你学习学习,我的出错了这是我的代码,帮帮我吧 #include #include"BoardConfig.h" char star[]="AT&Fr"; char AT[]="ATr"; //握手信号//3Chars char ATCMGF[]="AT+CMGF=1r"; //text格式//10Chars char ATCMGS[]="AT+CMGS=1392*****0r"; char Data[]="HHH"; //unsigned char ATCSCA[]="AT+CSCA="+8613010980500"r"; void GsmSend(void); void UART0_Init (void); void DelayNS (unsigned int dly); void uart1Puts( char *s); void uart1Putc( char c); unsigned char len; char gsmRxBuf[88] = {0}; //接收GSM模块数据 char gsmRxLen = 0; //接收数据长度 //主程序 void main() { WDTCTL = WDTPW +WDTHOLD; UART0_Init(); // DelayNS(2000);//等待 P1DIR&=~BIT3; P1REN=BIT3; P1OUT=BIT3; P1DIR|=BIT0; while(1) { if((BIT3 & P1IN)==0) { delay_ms(25); if((BIT3 & P1IN)==0) { P1OUT^=BIT0; GsmSend(); P1OUT^=BIT0; while(!(BIT3 & P1IN)); } } } } //uart初始化 void UART0_Init(void) { if (CALBC1_1MHZ==0xFF) // If calibration constant erased { while(1); // do not load, trap CPU!! } DCOCTL = 0; // Select lowest DCOx and MODx settings BCSCTL1 = CALBC1_1MHZ; // Set DCO DCOCTL = CALDCO_1MHZ; P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD UCA0CTL1 |= UCSWRST; UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 109; // 1MHz 9600 UCA0BR1 = 0; // 1MHz 9600 // UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1 UCA0MCTL = 0x10; UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt __bis_SR_register(GIE); // interrupts enabled } //时间延迟 void DelayNS(unsigned int dly) { unsigned int i; for(;dly>0;dly--) for(i=0;i<2000;i++); } void GsmSend(void) { // uart1Puts(star); // delay_ms(2000); uart1Puts(AT); delay_ms(2000); // __delay_cycles(1000000); uart1Puts(ATCMGF); // __delay_cycles(1000000); delay_ms(2000); uart1Puts(ATCMGS); delay_ms(2000); // __delay_cycles(1000000); uart1Puts(Data); delay_ms(2000); // __delay_cycles(10000000); while(!(IFG2 & UCA0TXIFG)); //发送符 UCA0TXBUF=0x1a; // while(!(IFG2 & UCA0TXIFG)); delay_ms(2000); } void uart1Puts( char *s) { while (*s != ' |