I am using ESP32 to receive data from TI C2000 microcontroller (28027) . The code for the ESP32 is
#include <LiquidCrystal_I2C.h>
#include <HardwareSerial.h>
#define RXD2 16
#define TXD2 17
HardwareSerial SerialPort(2); // use UART2
LiquidCrystal_I2C lcd(0x27,16,4); // set the LCD address to 0x3F for a 16 chars and 2 line display
//HardwareSerial SerialPort(2); // use UART2
int data;
void setup() {
Serial.begin(9600);
SerialPort.begin(9600, SERIAL_8N1, RXD2, TXD2);
lcd.init();
lcd.clear();
lcd.backlight(); // Make sure backlight is on
}
void loop()
{
while(SerialPort.available())
{
lcd.clear();
// data=SerialPort.read();
data=1234;
lcd.setCursor(1,0); //Set cursor to character 1 on line 0
lcd.print(data);
Serial.println(data);
}
}
here if i uncomment the line data=SerialPort.read();
and also keep data=1234 in the second line;
The entire loop only works once.
If i comment data=1234; then the output is 0 (which is shown both in LCD and Serialmonitor and it only shows once.
Is the code written to receive data from an external microcontroller correct?
Post a wiring diagram and/or a photo of the setup. Are the grounds connected? Have you checked wiring continuity? Are you sure data are actually being transmitted?
When I tried this code. I am not getting any information on serial monitor.
I am using GPIO 28 29 (TMS320F28027) for the serial communication. In the watch register of code composer studio I am able to see the change in values. The ground is connected between (TMS320F28027) and ESP32. Please note that both of these microcontrollers are also connected to PC, does this affect the communication.
The baud rate is 9600.
I am attaching the code for both ESP32 . Tx Register for TMS320F28027 is also showing values (screen shot attached)
#include <LiquidCrystal_I2C.h>
#include <HardwareSerial.h>
#define RXD2 16
#define TXD2 17
HardwareSerial SerialPort(2); // use UART2
LiquidCrystal_I2C lcd(0x27,16,4); // set the LCD address to 0x3F for a 16 chars and 2 line display
//HardwareSerial SerialPort(2); // use UART2
uint16_t data;
void setup() {
Serial.begin(9600);
SerialPort.begin(9600, SERIAL_8N1, RXD2, TXD2);
lcd.init();
lcd.clear();
lcd.backlight(); // Make sure backlight is on
}
void loop()
{
// if(SerialPort.available())
// {
// lcd.clear();
// data=SerialPort.read();
// lcd.setCursor(1,0); //Set cursor to character 1 on line 0
// lcd.print(data);
// Serial.println(data);
// }
if (SerialPort.available())
Serial.write(SerialPort.read());
}
What exact "register" are you watching and what values do you see?
Just to name a random name that could be related to it:
Is this the serial-buffer-output-register?
What voltage-level does the TMS320F28027 have? 5V or 3.3V?
You did not provide this detail
To what
baudrate,
parity,
number of startbits
number of stopbits
is the serial interface of the TMS320F28027 configured?
You have put together a system with many parts where each part has many parameters that could be the problem.
At the moment you are using a new code on the arduino from which you do not
know if the arduino-code is working properly
trying to figure out if communication with your TMS320F28027-µC is working.
The method for developping such systems is:
Reduce the system as much as possible.
For testing use "partners" or devices that are well known to work properly
As a first test you should do receiving from your TMS320F28027-microcontroller to a TTL-COM-Port-adapter and look at what you receive in a serial terminal-software.
Or using a 24 MHz 8 channel logic analyser for $15 and record what is happening on the Tx-line of your TMS320F28027-µC.
If for whatever reason the TMS320F28027 does not send anything any testing above the level
of pure hardware-voltages is useless.