【发布时间】:2020-05-18 18:15:36
【问题描述】:
我使用 UART 将 ESP8266 与 ATmega8 连接。我根据值 ATmega8 将一些值从 ESP8266 发送到 ATmega8 向 ESP8266 发送回一些值,这工作正常,但几个小时后,ATmega8 在重置 ATmega8 后发送数据它工作正常,但几个小时后又再次发送它停止发送数据。
//ESP8266 CODE
Serial.write(post_data);
delay(2000);
String port_status = "";
if (Serial.available()) {
incomingByte = Serial.read();
delay(2000);
if(incomingByte == 70) {
pin_status = '0';
}
if(incomingByte == 79) {
pin_status = '1';
}
}
//ATMEGA8 CODE
int main() {
unsigned char reccive;
unsigned char ch;
while(1) {
while(! (UCSRA & (1<<RXC)));
{
reccive = UDR;
ch = ' ';
if(reccive == 'A') {
reccive = ' ';
_delay_ms(500);
ch = 'O';
while(! (UCSRA & (1<<TXC)));
{
UDR = 'O';
_delay_ms(500);
}
}
else {
ch = 'F';
while(! (UCSRA & (1<<TXC)));
{
UDR = 'F';
_delay_ms(500);
}
}
}
}
}
【问题讨论】:
标签: esp8266 uart serial-communication atmega