Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 9 months ago.
mbed currupts after running this>> code!
The hardware is all fine, mbed is all fine, I have noted that if the function in run(putting the post_frame_moreLEDS_testing() or post_frame_moreLEDS_testing_part2() function is inserted within the IF conditions and then loading it on the mbed messes up some thing that even if it is corrected in the future code that is loaded on the mbed even after formatting it won't let the mbed work as it was working before)
Everything works! fine ,I have a binary from that I compiled on point before compiling this code with the following run(): Below is also posted with post_frame_moreLEDS_testing() code;
//-------------------------------------------------------------------------------------------------------------------------------------// void run(int size1, int size2) // Call this function with needed parameters of size to get the size for strips LIT part running from Left to Right AND Right to Lef { for(a ; a <= (STRIP_LENGTH + size2 + 3); a++) { if(LEDlength_changer == true) { if (checkX) { if(wave1_endLED <= size2+1) { wave1_startLED = 1; wave1_endLED = INCR_wave1++; } else { INCR_wave1 = 1; wave1_startLED++; wave1_endLED = wave1_startLED + size2; } fill_color(0xFFFFFF, wave1_startLED, wave1_endLED); if((wave1_endLED + 1) == (STRIP_LENGTH + size2 + 3)) { wave1_startLED = 0; wave1_endLED = 0; counter_waves = 0; checkX = false; pc.printf("wave 1 done"); } if((wave1_endLED + 1) == (STRIP_LENGTH)) { checkX_part2 = true; a = 0; //pc.printf("hereeeee"); } post_frame_moreLEDS_testing(0x000000, wave1_startLED, wave1_endLED, wave2_startLED, wave2_endLED, wave3_startLED, wave3_endLED, wave4_startLED, wave4_endLED); //char cVal[32]; //sprintf(cVal,"%d",wave1_endLED); //pc.printf(cVal); } if (checkX_part2) { if(wave1_endLED_part2 <= size2+1) { wave1_startLED_part2 = 1; wave1_endLED_part2 = INCR_wave1_part2++; } else { INCR_wave1_part2 = 1; wave1_startLED_part2++; wave1_endLED_part2 = wave1_startLED_part2 + size2; } fill_color(0xFFFFFF, wave1_startLED_part2, wave1_endLED_part2); if((wave1_endLED_part2 + 1) == (STRIP_LENGTH + size2 + 3)) { wave1_startLED_part2 = 0; wave1_endLED_part2 = 0; counter_waves = 0; checkX_part2 = false; pc.printf("wave 1 part2 done"); if((wave1_endLED_part2 + 1) == (STRIP_LENGTH + 3)) { checkX_part3 = true; } } } if (checkX_part3) { if(wave1_endLED_part3 <= size2+1) { wave1_startLED_part3 = 1; wave1_endLED_part3 = INCR_wave1_part3++; } else { INCR_wave1_part3 = 1; wave1_startLED_part3++; wave1_endLED_part3 = wave1_startLED_part3 + size2; } fill_color(0xFFFFFF, wave1_startLED_part3, wave1_endLED_part3); if((wave1_endLED_part3 + 1) == (STRIP_LENGTH + size2 + 3)) { wave1_startLED_part3 = 0; wave1_endLED_part3 = 0; counter_waves = 0; checkX_part3 = false; pc.printf("wave 1 part3 done"); } } if (checkX1) { if(wave2_endLED <= size2+1) { wave2_startLED = 1; wave2_endLED = INCR_wave2++; } else { INCR_wave2 = 1; wave2_startLED++; wave2_endLED = wave2_startLED + size2; } fill_color(0xFFFFFF, wave2_startLED, wave2_endLED); if((wave2_endLED + 1) == (STRIP_LENGTH + size2 + 3)) { wave2_startLED = 0; wave2_endLED = 0; counter_waves = 0; checkX1 = false; pc.printf("wave 2 done"); } } if (checkX2) { if(wave3_endLED <= size2+1) { wave3_startLED = 1; wave3_endLED = INCR_wave3++; } else { INCR_wave3 = 1; wave3_startLED++; wave3_endLED = wave3_startLED + size2; } fill_color(0xFFFFFF, wave3_startLED, wave3_endLED); if((wave3_endLED + 1)== (STRIP_LENGTH + size2 + 3)) { wave3_startLED = 0; wave3_endLED = 0; counter_waves = 0; checkX2 = false; pc.printf("wave 3 done"); } } if (checkX3) { if(wave4_endLED <= size2+1) { wave4_startLED = 1; wave4_endLED = INCR_wave4++; } else { INCR_wave4 = 1; wave4_startLED++; wave4_endLED = wave4_startLED + size2; } fill_color(0xFFFFFF, wave4_startLED, wave4_endLED); if((wave4_endLED + 1) == (STRIP_LENGTH + size2 + 3)) { wave4_startLED = 0; wave4_endLED = 0; counter_waves = 0; checkX3 = false; pc.printf("wave 4 done"); } } //post_frame_moreLEDS_testing_part2(0x000000, wave1_startLED_part2, wave1_endLED_part2, wave2_startLED_part2, wave2_endLED_part2, wave3_startLED_part2, wave3_endLED_part2, wave4_startLED_part2, wave4_endLED_part2); //wait_ms(4); //wait(1); } } }
post_frame_moreLEDS_testing() code:
//Main Animation function// //Takes the current strip color array and pushes it out MULTIPLE LEDS RUNNING void post_frame_moreLEDS_testing (long LEDcolor, int startLED, int endLED, int startLEDX, int endLEDX, int startLEDX1, int endLEDX1, int startLEDX2, int endLEDX2) { for(int LED_number = 0 ; LED_number < (STRIP_LENGTH + 32) ; LED_number++) { //Serial.println("j"); //Serial.println(freeMemory()); if(startLED == LED_number) { for(startLED; startLED <= endLED; startLED++) { //Serial.println(count); if(checkX) { this_led_color = shiftUp(); } else { this_led_color = 0; } for(char color_bit = 23 ; color_bit != 255 ; color_bit--) { //Feed color bit 23 first (red data MSB) CKI = 0x00; long mask = 1L << color_bit; //The 1'L' forces the 1 to start as a 32 bit number, otherwise it defaults to 16-bit. if(this_led_color & mask) SDI = 0xff; else SDI = 0x00; CKI = 0xff; } } //Pull clock low to put strip into reset/post mode CKI = 0x00; wait_us(500); } if(startLEDX == LED_number) { for(startLEDX; startLEDX <= endLEDX; startLEDX++) { // Serial.println(F("yessss")); if(checkX1) { this_led_colorX = shiftUp(); } else { this_led_colorX = 0x000000; } for(char color_bit = 23 ; color_bit != 255 ; color_bit--) { //Feed color bit 23 first (red data MSB) CKI = 0x00; //Only change data when clock is low long mask = 1L << color_bit; //The 1'L' forces the 1 to start as a 32 bit number, otherwise it defaults to 16-bit. if(this_led_colorX & mask) SDI = 0xff; else SDI = 0x00; CKI = 0xff; //Data is latched when clock goes high } } //Pull clock low to put strip into reset/post mode CKI = 0x00; wait_us(500); } if(startLEDX1 == LED_number) { for(startLEDX1; startLEDX1 <= endLEDX1; startLEDX1++) { // Serial.println(F("yessss")); if(checkX2) { this_led_colorX = shiftUp(); } else { this_led_colorX = 0x000000; } for(char color_bit = 23 ; color_bit != 255 ; color_bit--) { //Feed color bit 23 first (red data MSB) CKI = 0x00; //Only change data when clock is low long mask = 1L << color_bit; //The 1'L' forces the 1 to start as a 32 bit number, otherwise it defaults to 16-bit. if(this_led_colorX & mask) SDI = 0xff; else SDI = 0x00; CKI = 0xff; //Data is latched when clock goes high } } //Pull clock low to put strip into reset/post mode CKI = 0x00; wait_us(500); } if(startLEDX2 == LED_number) { for(startLEDX2; startLEDX2 <= endLEDX2; startLEDX2++) { // Serial.println(F("yessss")); if(checkX3) { this_led_colorX = shiftUp(); } else { this_led_colorX = 0x000000; } for(char color_bit = 23 ; color_bit != 255 ; color_bit--) { //Feed color bit 23 first (red data MSB) CKI = 0x00; //Only change data when clock is low long mask = 1L << color_bit; //The 1'L' forces the 1 to start as a 32 bit number, otherwise it defaults to 16-bit. if(this_led_colorX & mask) SDI = 0xff; else SDI = 0x00; CKI = 0xff; //Data is latched when clock goes high } } //Pull clock low to put strip into reset/post mode CKI = 0x00; wait_us(500); } else { this_led_color = 0x000000; //24 bits of color data } for(char color_bit = 23 ; color_bit != 255 ; color_bit--) { //Feed color bit 23 first (red data MSB) CKI = 0x00; //Only change data when clock is low long mask = 1L << color_bit; //The 1'L' forces the 1 to start as a 32 bit number, otherwise it defaults to 16-bit. if(this_led_color & mask) SDI = 0xff; else SDI = 0x00; CKI = 0xff; //Data is latched when clock goes high } } //Pull clock low to put strip into reset/post mode CKI = 0x00; wait_us(500); //delay(200); }
2 Answers
10 years, 9 months ago.
/media/uploads/Nishant/notworkingbinarysda-1-.mp4 /media/uploads/Nishant/workingbinarysda-2-.mp4
Clearly as you can see it doesnt have any signals for the not working binary. These are from a 25Mhz scope
EDIT:
So after 2 days of suffering and troubleshooting, got to know that it was all due to the library update , then I reverted to old mbed library builds and it all started working finally!
I extent to which I was able to go was towards revision number 39 thats when the CMSIS core was updated to 3.0 and that's it if I go above it doesnt work.
10 years, 9 months ago.
This code is difficult to understand without digging deeper. You say it compiles, sometimes it runs well, sometimes it misbehaves even depending on what was running before. That could be initialisation issues. Depending on what is left behind in memory things behave differently. Do you get any warnings when compiling. Fix those if you have them. I noticed for example that the first for-loop in run uses a variable a that is not initialised. Is it some global that has a defined start value?
"variable a that is not initialised. Is it some global that has a defined start value?"
Yes its a global whose value changes to accommodate new sine waves generated.
I said it runs well with the binary ,the binary where in I got those post_frame() functions posted out of the if conditions worked well , but once I compiled as its posted above wherein I got the post_frame() funtions within the if condition it all messed up the compiler stuff somewhere and from then on even correcting any errors or get the code even in the old very workable form doesnt light up anything.
posted by 15 Feb 2014
Thats alot of code. But now also your old binary doesn't work which used to work? It is not really clear to me what now happens. Does it work fine or not? What does work, what doesn't? Because this code doesn't show anything special. Compile all from the compile dropdown menu can sometimes be needed to completely recompile everything, but it really shouldn't be needed for code like this.
And I see printfs, are they still written if it doesn't work or not?
posted by Erik - 15 Feb 2014erik this is like 40% of the complete code, but its the main thing!
STILL THE OLD BINARY WORKS COMPLETE FINE AS IT SHOULD. I have tried all sorts of mbed library deletion and creation of a fresh project, even creation of a fresh account and then a fresh program.
I AGAIN REPEAT THE OLD BINARY WORKS
posted by Nishant Sood 15 Feb 2014Then why write:
Quote:
future code that is loaded on the mbed even after formatting it won't let the mbed work as it was working before
From that I get the idea it doesn't work fine anymore. But do the printfs continue to work?
posted by Erik - 15 Feb 2014What I want to convey is that I got the binary before putting that post_frame() function within the if(checkX) conditions and that binary was working fine! but then after putting that post_frame() function within that if(checkX) and so on similar conditions as you can see above the further code compilations of even the code that was working all very fine before do not turn on any animation and seen died on the scope!
Try to understand I'm in a problem which is like not normal at all and depicting it in words is even more hard! its not your fault at all but not even mine
posted by Nishant Sood 15 Feb 2014Eirk,
The mbed shows all fine! as a drive and gets code on it and save it BUT....... I just tried to see the printfs and noticed that the mbed SERIAL PORT IS GONE! the mbed is not emulating a serial port!
posted by Nishant Sood 15 Feb 2014and..... I just noticed that its the mbed Serial Port only thats not showing other microcontrollers are being recognized and also getting programmed so its something bad with my mbeds only! after I got that code, How to fix my mbeds for this now?
The mbed used to emulate a very healthy COM20 on my system! now its not there
posted by Nishant Sood 15 Feb 2014Erik,
Okay I got the Serial port working and I'm getting the printfs all fine as I should from the mbed serial port ,they say wave1done, wave2done, so its executing all that code!
posted by Nishant Sood 15 Feb 2014You may have a different mbed module now. Remember that the serial driver must be installed for each specific mbed.
posted by Wim Huiskamp 15 Feb 2014Wim,,
Its the same mbed that I got to show up on the serial, I updated the serial driver!
posted by Nishant Sood 15 Feb 2014