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

論壇索引


Board index » All Posts (a780917a)




接收串列傳輸數據
#11
高級會員
高級會員


各位好, 小弟想用PIC16LF1823接收一組24個bit的串列數據,數據是一個20bit的數值,後4位是符號位。
目前是用char tb[23]陣列儲存起來,但要加總時就變得相當麻煩,想問看看該怎麼簡化呢?

發表於: 2022/4/12 10:04
頂部


Re: UART傳輸與接收問題
#12
高級會員
高級會員


感謝Dark大跟版大的回覆
真的是TX程式的問題,多加一行while(!TXSTAbits.TRMT);,問題就改善了。
又學到一課,太棒了

發表於: 2021/2/8 8:24
頂部


UART傳輸與接收問題
#13
高級會員
高級會員


各位好:
我使用兩個PIC16F1823要做UART傳輸,丟一筆三位數的資料, 並用七段顯示器顯示數值
我有把百位,十位,各位,拆開來用ASCll傳輸
我遇到的問題是, 當數值從299 要跳到300時 有時數值會偶爾出現 200 或399, 感覺只有其中一兩個位數先變化
尤其在有干擾源的情況下狀況更嚴重,
我已經在接收端增加許多限制避免漏收就讀出,但狀況依然沒有完全改善
9600 8bit
TX:(放在主程式的While迴圈)
while(1)
{
Speed_V = Speed_Command;
uart_tb[0] = 0xA5;
uart_tb[1] = (Speed_V/100) +'0';
uart_tb[2] = ((Speed_V/10)%10) +'0';
uart_tb[3] = (Speed_V%10)+'0';
uart_tb[4] = Er_F +'0';
uart_tb[5] = 0x0D;
EUSART_Write(uart_tb[k]);
if(k++ == 5)
{
//Speed;
k = 0;
}
}

RX:(用中斷接收)
void User_UART_ISR(void)
{
while (EUSART_DataReady)
{
if(FlagReg1.Uart_FLAG == 0)
{
value = EUSART_Read();
if(value = 0xA5)
{
FlagReg1.Uart_FLAG = 1;
k = 0;
}
}
else
{
value = EUSART_Read();
uart_tb[k] = value;
k++;
if(k==5 && value == 0x0D)
{
if(uart_tb[0] >= 0x30 && uart_tb[1] >= 0x30 && uart_tb[2] >= 0x30)
{
Speed_S = (uart_tb[0]-'0') *100 + (uart_tb[1]-'0') *10 + (uart_tb[2]-'0');
Speed_Value = Speed_S * 1;
}
uart_tb[0] = 0;
uart_tb[1] = 0;
uart_tb[2] = 0;
FlagReg1.Uart_FLAG = 0;
}
}
}
}

發表於: 2021/2/2 11:03
頂部


UART不共地的接線方式
#14
高級會員
高級會員


大家好,因原本在使用UART通訊是將兩個共地的MCU做傳輸,接線方式是
4C線(Vcc,gnd,RX(TX),TX(RX))
這次想將兩組有各自電源供應的MCU做通訊,這樣RX與TX之間是不是需要加光藕器做電源隔離呢?或者與其他裝置連線時,電路是否需要做隔離設計
謝謝。

發表於: 2020/6/10 14:17
頂部


MPLAB X IDE的腳位設定問題
高級會員
高級會員



發表於: 2019/5/14 10:26
頂部



« 1 (2) 3 4 5 ... 8 »



:::

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... ]

教育訓練中心

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