• slider image 442
  • slider image 497
  • slider image 498
  • slider image 499
  • slider image 500
  • slider image 502
:::


Browsing this Thread:   1 Anonymous Users






Re: dspic30f4011 uart 與vb做傳送接收
#2
管理員
管理員


查看用戶資訊
你好,

會發生 Error 的原因如下 :

getcUART1 為一在 uart.h 定義的巨集 , 真正的被叫用函式為 ReadUART1. 而 ReadUART1 是不給參數的 ! 而且會傳回由 UART1 讀到的字元.

看來你想要由 UART1 讀入一字串, 那麼要用的是 getsUART1 才對啦 ! 而且要注意參數的順序喔 :)

祝你順利完成啦 !

發表於: 2008/1/6 22:31
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


dspic30f4011 uart 與vb做傳送接收
#1
中級會員
中級會員


查看用戶資訊
我有一各疑問 想麻煩各位大大 幫我解決 我做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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------