dspic30f4011 uart 與vb做傳送接收
|
||||
---|---|---|---|---|
中級會員
|
我有一各疑問 想麻煩各位大大 幫我解決 我做uart的部份 與vb做傳送接收 可是我打出來的程式 盡然連build all都過不了 可以幫我看看以下程式是否有錯誤
功能是 1.vb打32傳送給晶片接收 之後顯示在lcd出現2 2.晶片一直傳送給vb 送的值是0x55 麻煩各位大大 幫我一下 萬分感激 謝謝 #define __dsPIC30F4011__ #include <p30F4011.h> #include <uart.h> #include "C30EVM_LCD.h" // 將LCD函式的原型宣告檔案含入 _FOSC(CSW_FSCM_OFF & XT_PLL8); // XT with 8xPLL oscillator, Failsafe clock off _FWDT(WDT_OFF); // Watchdog timer disabled _FBORPOR(PBOR_OFF & MCLR_EN); // Brown-out reset disabled, MCLR reset enabled _FGS(CODE_PROT_OFF); // Code protect disabled void Init_UART(void); void delay (unsigned int dly); void long_delay (unsigned char l_dly); const char My_String1[]=" COUNT= " ; // 宣告字串於 Program Memory (因為 const 宣告) //char My_String2[]=" dsPIC Compiler " ; // 宣告字串於 Data Memory void _ISR _U1RXInterrupt(void) { unsigned int i; unsigned char table[10]={0x55}; unsigned char buf[3]={0}; if (DataRdyUSART()) { getcUART1(buf,3); if(sizeof(buf)!=0) { LCD_Cmd(0x80); LCD_Cmd(0x86); for(i=0;i<3;i++) Send_data(buf[i]); long_delay(1); } } else { putcUART1(table); long_delay(1); } IFS0bits.U1RXIF = 0 ; } int main( void ) { Init_UART(); OpenLCD( ) ; // 使用 OpenLCD( )對 LCD 模組作初始化設定 // 4 bits Data mode // 5 * 7 Character setcurLCD(0,0) ; // 使用 setcurLCD( ) 設定游標於 (0,0) putrsLCD( My_String1 ) ; // 將存在 Program Memory 的字串使用 // putrsLCD( ) 印出至 LCD // setcurLCD(0,1) ; // 使用 setcurLCD( ) 設定游標於 (0,1) // putsLCD( My_String2 ) ; // 將存在 Data Memory 的字串使用 // putsLCD( ) 印出至 LCD while(1) ; // Forever loop } /*void INTx_IO_Init(void) { INTCON2 = 0x001E; IFS0bits.INT0IF = 0; IEC0bits.INT0IE = 1; }*/ /*void __attribute__((__interrupt__)) _INT0Interrupt(void) { IFS0bits.INT0IF = 0; }*/ void Init_UART(void) { /* Holds the value of baud register */ unsigned int baudvalue; /* Holds the value of uart config reg */ unsigned int U1MODEvalue; /* Holds the information regarding uart TX & RX interrupt modes */ unsigned int U1STAvalue; /* Turn off UART1module */ CloseUART1(); /* Configure uart1 receive and transmit interrupt */ ConfigIntUART1(UART_RX_INT_EN & UART_RX_INT_PR6 & UART_TX_INT_DIS & UART_TX_INT_PR2); /* Setup the Buad Rate Generator */ baudvalue = 95; //UxBRG = ( (FCY/Desired Baud Rate)/16) – 1 //UxBRG = ( (7372800*2/9600)/16-1) = 95 /* Configure UART1 module to transmit 8 bit data with one stopbit. Also Enable loopback mode */ U1MODEvalue = UART_EN & UART_IDLE_CON & UART_DIS_WAKE & UART_DIS_LOOPBACK & UART_DIS_ABAUD & UART_NO_PAR_8BIT & UART_1STOPBIT & UART_ALTRX_ALTTX; U1STAvalue = UART_INT_TX_BUF_EMPTY & UART_TX_PIN_NORMAL & UART_TX_ENABLE & UART_INT_RX_CHAR & UART_ADR_DETECT_DIS & UART_RX_OVERRUN_CLEAR; OpenUART1(U1MODEvalue, U1STAvalue, baudvalue); return; } 以下是顯示錯誤: 123.c: In function `_U1RXInterrupt': 123.c:26: error: too many arguments to function `ReadUART1' 123.c:38: warning: passing arg 1 of `WriteUART1' makes integer from pointer without a cast
發表於: 2008/1/4 22:53
|
|||
|