• slider image 442
  • slider image 477
  • slider image 479
  • slider image 480
  • slider image 481
  • slider image 482
:::


Browsing this Thread:   1 Anonymous Users






Re: dsPIC uart接收問題
#4
版主
版主


查看用戶資訊
眼睛除錯很累人,請參考一下教育訓練光碟下 16-bit 教材裡有一份 "dsPIC30F Module Training" 裡面有一份 dsPIC30F4011 UART 的講解及範例可以參考看看。

http://www.microchip.com.tw/RTC/RTC_DVD/

發表於: 2021/1/20 10:50
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: dsPIC uart接收問題
#3
新會員
新會員


查看用戶資訊
參照:

Ryang wrote:
單看程式容易誤判,最簡單的方式就是先用示波器測量一下 UART 的波形及分析所傳述的資料為何?

示波器最重要,資料在上面一目了然。

Ryang您好:
我有用示波器去量測Arduino的傳輸端是有波形的,代表應該Arduino是有傳出去的,可是在dsPIC端的U1RXREG還是沒有收到任何資料。
還有其他可能造成這種情況的原因嗎?

發表於: 2021/1/20 9:18
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: dsPIC uart接收問題
#2
版主
版主


查看用戶資訊
單看程式容易誤判,最簡單的方式就是先用示波器測量一下 UART 的波形及分析所傳述的資料為何?

示波器最重要,資料在上面一目了然。

發表於: 2021/1/19 13:00
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


dsPIC uart接收問題
#1
新會員
新會員


查看用戶資訊
最近使用dsPIC30f3011這個晶片在做與arduino端傳資料的動作
但不知道是arduino端的問題還是dsPIC這端的問題
PIC這邊都收不到資料,可是URXDA都是為1(datasheet上說為1代表有值)
但U1RXREG都沒有值跑出來
有沒有大神可以幫忙解惑
感激萬分

code如下:
uart.c:
#include
#include
#include "uart.h"

void InitUART1(void);
void InitUART2(void);


#define FCY (unsigned long)20000000 //add your operating frequency
#define UART1_BAUD 9600

#define UBRG1_VALUE (FCY/UART1_BAUD)/16 - 1


void WriteUART1(unsigned int data)
{
while (U1STAbits.TRMT==0);
if(U1MODEbits.PDSEL == 3)
U1TXREG = data;
else
U1TXREG = data & 0xFF;
}
void WriteUART1dec2string(unsigned int data)
{
unsigned char temp;
temp=data/1000;
WriteUART1(temp+'0');
data=data-temp*1000;
temp=data/100;
WriteUART1(temp+'0');
data=data-temp*100;
temp=data/10;
WriteUART1(temp+'0');
data=data-temp*10;
WriteUART1(data+'0');
}
void WriteStringUART1(const char * s)
{
while(*s)
WriteUART1(*s++);
}

void InitUART1(void)
{
U1BRG = UBRG1_VALUE; // baud rate 9600
U1MODEbits.ALTIO=0; //備用的I/O
U1MODEbits.STSEL=0; //1-stop bit
U1MODEbits.PDSEL=0; //No Parity,8-data bits
U1MODEbits.ABAUD=0; //Autobaud Disabled
U1MODEbits.USIDL=0;

U1STAbits.URXISEL = 3; // Interrupt flag bit is set for every character received.
IPC2bits.U1RXIP = 5; // UART1 Receive Interrupt Priority = 4.
U1STAbits.OERR = 0; // Clear the Receive Overflow Flag.
IFS0bits.U1RXIF = 0; // Clear the UART1 Receive Interrupt flag.
//IEC0bits.U1TXIE = 0;
IEC0bits.U1RXIE = 1; // enable UART1 Receive Interrupt.
U1MODEbits.UARTEN = 1;
U1STAbits.UTXEN=1;
}

main:
#include
#include
#include
#include "uart.h"

//--------------------------Device Configuration------------------------
_FOSC(CSW_FSCM_OFF & XT_PLL16);
_FWDT(WDT_OFF);
_FBORPOR(PBOR_ON & BORV_20 & PWRT_64 & MCLR_EN);
//----------------------------------------------------------------------


#define FCY 20000000
void DelayNmSec(unsigned int N);
char Rxdata;
void __attribute__((__interrupt__)) _U1RXInterrupt(void)
{
IFS0bits.U1RXIF = 0;
Rxdata = U1RXREG;
}
int main(void)
{
InitUART1();
return;
}

arduino端:

unsigned int Txdata;
int x;
int y;
int z;
int w=0;

void setup() {
Serial3.begin(9600);
}

void loop() {
x=random(100);
y=random(100);
z=x+y;

Txdata=(z&(256-1));


Serial3.write(Txdata);
Serial3.println(Txdata);


}

發表於: 2021/1/18 15:34
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... ]

教育訓練中心

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