chipKIT® Development Platform

Inspired by Arduino™

Chikit Uno and serial communication with Processing

Created Thu, 29 Nov 2012 01:07:02 +0000 by YOBE.


Thu, 29 Nov 2012 01:07:02 +0000

Hello, I am new with Chipkit since last week and lost 1 day trying to setup serial communication with Processing (open source). In the past I used different pic's and never had a problem with Processing.

Basic setup: Send byte serial from Processing to Chipkit and Chipkit sends the byte back as respons.

This works perfect when I use the serial monitor in MPIDE or RealTerm. Only when using Processing this does NOT work!!

But after hours of testing, I found out that you need to give the Chipkit around 4 seconds to setup his serial communication. In other words: when you activate "Serial Monitor", "RealTerm" or Processings and directly send a byte to ChipKit it will hang serial communication. (this was not seen when using Serial monitor or RealTerm because you send the data manual and this takes some seconds between activating the serial setup and sending the first byte)

SO, I hope this could help some people:

When you use Processing in combination with Chipkit:

a. This setup in Processing does NOT work: :( println(Serial.list()); myPort = new Serial(this, Serial.list()[0], 9600); delay(20);
myPort.write(68); // Send "D" to start ChipKit feedback

b. This in Processing does works: :D println(Serial.list()); myPort = new Serial(this, Serial.list()[0], 9600); delay(6000); // CHIPKIT NEEDS TIME TO SETUP SERIAL myPort.write(68); // Send "D" to start ChipKit feedback

Can anybody inform me what is the reason for this? Could be helpfull to understand what is going on inside ChipKit. Or am I completely wrong and need to do it in a different way??? :oops:

If I am right, this should be mentioned somewhere in the manual or serial section of MPIDE.




Thu, 29 Nov 2012 05:37:32 +0000


My guess is that you're activating the bootloader on the chipKIT boards by sending data to it right after opening the port.

Note that this only applies to serial-based boards like the UNO32, MAX32 and uC32, not to USB based boards like the FubarinoSD and FubarinoMini.

What happens is that when you open the port on the PC side, it issues a reset to the chipKIT board. When the chipKIT board resets, it runs its bootloader. The bootloader looks for certain bytes from the PC over the serial port. If it sees them within the first couple seconds after boot, it will then go into 'bootloader mode' where it waits for a whole program download to occur from the PC. If it doesn't see anything during those couple seconds, then it starts running the sketch you'd previously programmed into the board.

So you have to wait until that bootloader has given up listening before you send any data to the chipKIT board.

The simplest thing I've done is to just wait on the PC side until you hear the first byte from the chipKIT board, then start sending data from the PC to the board. On the chipKIT side, open up serial and then send a byte. This will be received by the PC, and then you'll start receiving all of the PC's data. The PC will not confuse the bootloader this way.



Thu, 29 Nov 2012 06:57:02 +0000

Thanks for the feedback. I will program a "Ready" byte on the ChipKit side like you propose. I need to look deeper into the boothload process Regards,