chipKIT-core v1.3.0 and v1.3.1 released

Announcements for new builds and MPIDE enhancements
rasmadrak
Posts: 218
Joined: Mon Aug 15, 2011 9:21 pm
Location: Sweden
Contact:

Re: chipKIT-core v1.3.0 and v1.3.1 released

Post by rasmadrak » Thu Dec 15, 2016 10:31 am

I have verified that it is indeed serial data corruption caused by the MAX32-board.
The software on the Arduino waits for a sync byte from the ChipKIT, before fetching 12 additional bytes where each bit is corresponding to on/off state for that light etc. Even if I send all 0's except for the first byte (character 'S') the lights goes crazy.

If I enable debugmode on the Arduino, which basically overwrites any input from the serial-port, it correctly lights up the current debug light. However - the status that is sent back to ChipKIT over serial gets corrupted, but sometimes show correct value. Usually 254 or 255 is returned instead of any number below 100. (Theory: Could probably be explained with Serial return -1 ie "nothing" and I load it into a byte... ).

Since no other card is using non-standard baud rates, I suspect it could be related to that in the new IDE?
If I half the read speed to 250 000 from 500 000, I believe the communication to be more stable. However, since I installed the new Arduino IDE+core I cannot compile the Arduino board any more... :roll: So I can't confirm or test completely different baud rates yet. I also cannot yet confirm if it's a problem with just Serial2, or that it simply manifests there due to higher/non-standard speeds.

But the problem is basically:
With the old version I can use super high serial speeds without a glitch.
With the new IDE I (presumably) cannot use anything higher than 56700 baud reliably.
The same hardware configuration runs beautifully compiled on the old IDE code base, whereas the new code base fails miserably even with a standard "blink" sketch that sends the byte equivalent of "S000000000000" over Serial2.

User avatar
majenko
Site Admin
Posts: 2165
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: chipKIT-core v1.3.0 and v1.3.1 released

Post by majenko » Thu Dec 15, 2016 11:16 am

The new IDE will have no bearing on the software that runs on the board - it is merely an interface.

Things may have changed slightly in the core as regards the UART software though, but not enough to cause the symptoms you describe. My immediate thought is it's a problem of baud-rate error percentage, but at 500,000 baud both chips (should) give 0% since it's working with nice round numbers. Also that code hasn't changed for years, if ever.

So I can't see it being a serial communication (low level) problem. It could be an issue with your code, though, which is executing differently since you are compiling with a newer version of GCC with slightly different optimization. If you share the serial portion of your code we can take a look and see if there is anything that could possibly cause the symptoms you mention.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

rasmadrak
Posts: 218
Joined: Mon Aug 15, 2011 9:21 pm
Location: Sweden
Contact:

Re: chipKIT-core v1.3.0 and v1.3.1 released

Post by rasmadrak » Mon Dec 19, 2016 10:52 am

Thanks for your reply, Majenko. :)
I will double check the test sketch I used tonight as I currently do not have access to it, but as I wrote in my previous reply I've tried using Serial2 with a bare minimum clean sketch as well, like so (pseudo):

Code: Select all

setup()
{
	Serial2.begin(500000);
}

loop()
{
	//The code below is pretty much pseudo: 
	
	char outbytes[13];
	outbytes[0] = 'S';  //sync byte.
	for (i = 1; i < 13; i++)
		outbytes[i] = 0;    //fill up all "light slots" with zeros. 
		
	Serial2.write(outbytes, 13);   //send 13 bytes of light data to Arduino.
}
The sketch (when using proper commands) should send 'S' sync char to the Arduino, which will then wait until it gets the remaining 12 bytes of light data. In this case, all lights should be off (all zeros). Using the new IDE, or at least the native code in the new IDE, the lights flicker. That means the Arduino is getting additional non-zero data or interpreting the sync byte as light data for reasons unknown.

Edit:
Just to be clear -
The code has absolutely no issues on the old MPIDE I was/am using. There I can run several DSPI's, 3 hardware serial ports and almost all pins on the Max32 simultaneously without any hiccups. But that laptop is singing the final verse now....

User avatar
majenko
Site Admin
Posts: 2165
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: chipKIT-core v1.3.0 and v1.3.1 released

Post by majenko » Mon Dec 19, 2016 1:08 pm

Are you sure the Arduino can physically cope with that quantity of data being hurled at it at such a great speed? You are most likely overwhelming the receive buffer on the Arduino and getting data loss.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

rasmadrak
Posts: 218
Joined: Mon Aug 15, 2011 9:21 pm
Location: Sweden
Contact:

Re: chipKIT-core v1.3.0 and v1.3.1 released

Post by rasmadrak » Mon Dec 19, 2016 9:09 pm

I'm not 200% sure, but it has no problem coping using the old compiler. However - it can of course be that the new computer, new compiler, new code base and what not runs much faster (possibly even with different optimization options) so that the Arduino gets swamped, just like you suggested.

Here's the actual code, by the way:

Code: Select all

	byte outbytes[13];
        outbytes[0] = 'S';
	int c=0;
	byte outbyte=0;
	for (byte a=12; a > 0; a--)
   {
		outbyte=0;
		for (int i=7; i >= 0; i--, c++)
		{ 
			bitWrite(outbyte, i, light[c]->value);   
		}
		outbytes[a]=outbyte;
   }

	Serial2.write(outbytes, sizeof(outbytes));   
I'll try lowering the speed, since it's really kind of overkill at the moment anyway, approximately 80 times faster than it needs to be. I'm just afraid that I'll spend too long sending light updates when I could do processing etc. But I'll check! \m/

rasmadrak
Posts: 218
Joined: Mon Aug 15, 2011 9:21 pm
Location: Sweden
Contact:

Re: chipKIT-core v1.3.0 and v1.3.1 released

Post by rasmadrak » Mon Dec 19, 2016 9:24 pm

It seems you're absolutely right, Majenko. Not that I'm all that surprised, though... :D

If I slow down the sending, throwing a maximum of a byte or so every 20ms the Arduino manages to keep up with the basic-example. I'll try implementing the same workaround (for now) in the proper code and we'll see if that's the problem for sure!

Edit:

Confirmed. It works fine in the proper code as well with 56700 baud instead!
Lower or higher doesn't work, so it would seem I accidentally found a weird sweetspot where everything worked before. Oh well, happy camper here and I can now focus on writing the game rules instead. 8-)

http://poormanspinball.blogspot.se

Post Reply