Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 9 months ago. This question has been closed. Reason: Off Topic
RS-485通信の送受信切り替えが上手くいきません。
RS-485規格通信の実験をしているのですが、入力・出力を切り替えるのに使うピン(D4)の動作タイミングがUART出力と合いません。 UARTはボーレートは2Mbps, データビットは8bit, 1bit ストップビット, パリティなしです。
main.cpp
#include "mbed.h"
Serial rs485(D8, D2, 2e6);
Serial pc(USBTX, USBRX, 9600);
DigitalOut dir(D4);
int main()
{
while(1) {
dir.write(true);
rs485.putc(0x54);
dir.write(false); //←送信終了後、レスポンスの監視の為に同時に切り替えたい。
wait_us(18);
while(rs485.readable()){ //←受信できない
pc.putc(rs485.getc());
}
wait_us(120);
}
}
mbed上で実現できる範囲で対策すべき点はありませんか。