i just started using Arduino IDE for my XMC1100XMC2Go. Information about the microcontroller can be found here: https://github.com/Infineon/XMC-for-Arduino/wiki/XMC-2Go
I now started with my first codes and want to print things on the serial monitor with this code:
*/
/* For on board LEDs */
#include <LED.h>
/* Create an LED object */
LED Led;
//#define SERIAL_DEBUG 1
int p_LED = 5;
int p_Button = 4;
int i_stateButton = 0;
void setup()
{
Led.Add(LED1); // Configure the LEDs
Led.Add(LED2);
pinMode(p_LED, OUTPUT);
pinMode(p_Button, INPUT);
// Set default state of LEDs
Led.On(LED2);
Led.Off(LED1);
digitalWrite(p_LED, LOW);
Serial.print("Hello World!");
Serial.begin(9600);
}
void loop()
{
Serial.write("Hello World!");
Serial.println(i_stateButton);
delay(200);
Led.Toggle (LED2);
Led.Toggle(LED1);
i_stateButton = digitalRead(p_Button);
//digitalToggle(p_LED);
digitalWrite(p_LED, i_stateButton);
}
I checked under tools that SerialOutput is set to PC (https://github.com/Infineon/XMC-for-Arduino/blob/master/variants/XMC1100/config/XMC1100_XMC2GO/pins_arduino.h#L54)
There are two Ports, COM1 and COM3. I can send new sketches to the microcontroller using COM3. I checked my Serial Monitor and it is set to COM3, too.
Baudrate is for both the same (code and monitor)
Now that i send the above sketch to the microcontroller it stops working. one LED is on and the other is off. But they do no longer change the state. Nothing appears on the monitor.
When i remove the both lines Serial.write("Hello World!"); Serial.println(i_stateButton);
and send the sketch, the LEDs start flashing again.
I'm pretty sure it's a kind of configuration problem, but i cannot find out what it is. Does anyone have an idea?
Serial.begin()
.serial.begin()
is in the setup part. Or does this belong to the loop?Serial.begin()
?Serial.print("Hello World!");
beforeSerial.begin(9600);
Thanks @Edgar Bonet