Other Parts Discussed in Thread: HALCOGEN
Hello,
I am having trouble sending messages from the microcontroller to a touchscreen. What's supposed to happen is, I send a message to the touchscreen such as "co2_level=100\r", and the touchscreen is supposed to decode the message and change the value to 100 (or whatever else I send it). Here's a picture of how the communication looks (the SIO/serial part is what I'm having trouble with):
https://i.imgur.com/RbIpzs0.png
The issue I'm having is, sending one message to the touchscreen works perfectly fine (it changes its value), but sending consecutive messages does not work properly. Here are some debugging logs I see from the touchscreen:
[SIO] received => "co2_level=100^J"
[SIO] sending => "co2_level=100^J"
[TIO] received => "co2_level=100"; from sio-agent
[TIO] found key => "co2_level="; returning => "co2_input.text=%s"
[TIO] sending => "co2_input.text=100"
[TIO] sending => "^J"
[QML] message available on socket
[QML] item available: "co2_input" "text" "100"
[SIO] received => ""
[SIO] sending => ""
As you can see, the next message I send is shown as an empty string "". I'm not sure why sending consecutive messages shows up as an empty string, like the message is getting dropped.
I'm using the SCI module (sciREG3 specifically). Here are some things I made sure of:
1) The TX pin from the microcontroller is connected to the RX pin of the touchscreen
2) sciREG3 driver is enabled, and the peripheral is enabled as well in Halcogen
3) The baud rate is the same between the microcontroller and touchscreen (I even changed them to different values and I get the same problem), as well as the number of stop bits, data bits, and parity/flow control.
4) I'm allowing sufficient time between each send. I have a (for i = 0; i < 1000000; ++i) between each send
One weird thing to note: when I send messages to the touchscreen via a terminal instead of the microcontroller, I have no issues. Consecutive messages get sent perfectly fine and no messages get dropped. This leads me to believe there's something wrong with the microcontroller. Tech support from the touchscreen company also agree.
Here's a snippet of my code:
uint8_t msg1[] = "co2_level=100\r";
uint8_t msg2[] = "co2_level=200\r";
int i = 0;
int main(void)
{
/* USER CODE BEGIN (3) */
sciInit();
for (i = 0; i < 1000000; ++i);
sciSend(sciREG3, sizeof(msg1), msg1);
for (i = 0; i < 1000000; ++i);
sciSend(sciREG3, sizeof(msg2), msg2);
while (1);
/* USER CODE END */
return 0;
}
Here's a zip file of my project: