Pulsing White after flashing SW

I am working on porting a stepper motor shield, and the SW is now compiling without error, but after flashing this particular SW the Spark enters a white pulsing state. The only way out is to do a factory reset, and then I can load other SW no problem. So I don’t think there is something wrong with the Spark, more likely the SW.

I put my .ino, .cpp, and .h files here GitHub files, if anyone would like to have a glance a the code or give any other hints to what could be wrong.

Appreciate any help!

Thanks!

Does it go through the standard Blinking Green > Blinking Cyan before pulsing white?

1 Like

No, directly to pulsing white. The reset button does not work either it goes straight to white. No core is found when connected through USB and running spark serial monitor. The only thing that works it to set back to flashing yellow and flags the whole thing.

This usually indicates a problem communicating with the TI CC3000 WiFi chip at start-up.

Is your core, by any chance, cold? Like near 0 F or -18 C.

2 Likes

Or, are you by chance drawing a lot of power from the core? (or the core’s power supply)? How is the core supplied with power?

1 Like

So I have tried two different power sources, I have my 3,7V LiPo battery and from the USB port, and there is no difference - it goes into white pulsing state.

When I have the stepper motor SW in the core, the core is pretty much “cold”, putting my finger on the CC3000 it’s hard to determine if any heat at all is coming from this chip, it feels like room temperature.

When I load a different SW into the core, the chip gets warm, maybe even too warm, I’m not sure. I also got a strange message from my MAC that the USB port was drawing a lot of power…so maybe the core is broke after all?

I did mess up earlier though, when I by accident had the 3,7V battery plugged in and then also put in the USB cable…so double power (or is there a block for that on the Spark?).

It’s just weird that with one SW it is cyan pulsing and I can reach the serial port through USB, but with the stepper SW it is white pulsing and no contact with the spark over serial.

Would you mind verifying that if you flash, say, the D7 blink demo/example it still works but with the stepper code it does not? I want to make sure the core is still in working order now. Thanks!

I reflashed the core and ran the Tinker app on my phone, and I can control the blue led with D7 button. For this test I ran with the USB cable. I also tested to run of my 3.7V battery, with no USB cable, and it also seems to work…

I now also tried to flash the core myself with the example code of the flashing led, and it seems to work too…I flashed wirelessly.

int LED = D7; // This one is the built-in tiny one to the right of the USB jack

void setup() {
  pinMode(LED, OUTPUT);
}

// This routine gets called repeatedly, like once every 5-15 milliseconds.
// Spark firmware interleaves background CPU activity associated with WiFi + Cloud activity with your code. 
// Make sure none of your code delays or blocks for too long (like more than 5 seconds), or weird things can happen.
void loop() {
  digitalWrite(LED, HIGH);   // Turn ON the LED pins
  delay(1000);               // Wait for 1000mS = 1 second
  digitalWrite(LED, LOW);    // Turn OFF the LED pins
  delay(1000);               // Wait for 1 second in off mode
}

Alright. I’ll try to look into this tomorrow. @Dave suggested to me that perhaps your constructors are killing it. Could you trying something in the mean time? Comment our everything in your stepper example. Throw in the D7 blink code (pinmode in the setup and blink in the loop). See if that works (it should). Now uncomment the stepper library include line (#include "TMC26XStepper.h"). Flash that and see what happens. Then the stepper object constructor (the TMC26XStepper tmc26XStepper = TMC26XStepper(200,2,6,7,700); part). Flash that and see if that works.

Interesting...so this part works:

And this part works:

But when I uncomment the constructor object, it goes into white pulsing mode after flashing :frowning: ...it seems like you are on to something...

1 Like

constructors on global objects run before the setup function, so anything that hits the hardware (writing serial, setting pin modes), can sometimes have unintended side effects. I thought we had workarounds in place for most of those, but maybe this is something new! :slight_smile:

Does it work if you construct the object inside the setup function?

Thanks,
David

1 Like

Yes! This makes a difference! Placing TMC26XStepper tmc26XStepper = TMC26XStepper(200,2,6,7,1700); inside the Setup, seems to do the trick - except that I also had to put the same code in the loop, otherwise the use of the constructor such as tmc26XStepper.setSpreadCycleChopper(2,24,8,6,0); would generate a compiler error.

Can I make it global somehow, so I don’t have to put the definition in the loop?

Do you think this is a general issue, or just a characteristics of this specific program?

Thanks for your help!

You should be able to put TMC26XStepper tmc26XStepper; above setup() (as a global) and then tmc26XStepper = TMC26XStepper(200,2,6,7,1700); in the setup(). The first will define the variable type and the second will actually create the object. Try that out

Thanks!

I tried it with the following error:

steppershield.cpp:27:15: error: no matching function for call to 'TMC26XStepper::TMC26XStepper()'
void loop();
^
steppershield.cpp:27:15: note: candidates are:
In file included from steppershield.cpp:26:0:
TMC26XStepper.h:124:2: note: TMC26XStepper::TMC26XStepper(int, int, int, int, unsigned int, unsigned int)
TMC26XStepper(int number_of_steps, int cs_pin, int dir_pin, int step_pin, unsigned int current, unsigned int resistor=150);

But I should be able to write TMC26XStepper tmc26XStepper = TMC26XStepper(200,2,6,7,1700); above the setup? So do you think there is a bug elsewhere in the .h or.cpp files or in the Spark environment? I feel a bit lost here…

Would you mind posting your whole code again? We can figure this out

@harrisonjones, I extracted all the code I have, and I updated the github at https://github.com/heon74/TMC26XExample.

In the readme.md you will find the exact changes I have made to the files.

The code as is there compiles error free but puts the Core in flashing white.

In this code I did not move the constructor inside the setup() just for you to see the code that compiles error free but sends the Core into white flashing.

Thanks, let me know what I can do to help.

Any luck? Thanks!