• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: USART中斷接收資料問題
#2
版主
版主


查看用戶資訊
會發生接收 Overrun Error 一般是沒有使用中斷方式接收,帶你試用中斷接收照理說應不會有此現象發生。建議用MPLAB SIM 下的 Stopwatch 檢查一下中斷函數所執行的時間是否小於一個Byte 的接收時間。

發表於: 2009/4/24 13:57
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


USART中斷接收資料問題
#1
中級會員
中級會員


查看用戶資訊
目前小弟遇到一個問題
就是使用中斷接收資料一直OERR 發生溢位
可是之前寫都沒問題 就最近突然發生這問題

所有副程式和其他中斷都關掉了
只留下USART中斷接收
主程式MAIN裡面只有留一個 while 空迴圈再跑

可是通常檢查接收的資料buffer
只收到前面三各byte
就發生OERR了....
後面資料都不見了.....

會發生OERR我知道是因為資料來不及接收
造成buffer被塞滿了

請問這問題要怎麼處理?
是否有大大可以指點一下....

有試過檢查當RCSTA1bits.OERR = 1
就去把RCSTA1bits.CREN置0再置1
這樣可以把OERR清0並重新啟動中斷接收副程式
可是這樣做的話
之前沒收到的資料還是不見了
等於整個資料封包我只收到頭跟尾
但中間這一段都流失了


以下是USART中斷接收資料副程式

#pragma code low_vector = 0x18
void low_interrupt(void)
{
_asm GOTO USART_RX_ISR _endasm
}
#pragma code

#pragma interruptlow USART_RX_ISR
void USART_RX_ISR(void)
{
byte tmp;

if(PIR1bits.RCIF == 1)
{
tmp = Read1USART();
if(tmp == 0xCC)RxCount = 0;
RxBuff[RxCount] = tmp;
if(++RxCount >= 50)RxCount = 0;
PIR1bits.RCIF =0;
}
}

發表於: 2009/4/23 11:42
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... ]

教育訓練中心

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