Go Down

Topic: Sketching is not running after first sketch ran- Again (Read 1 time) previous topic - next topic

0x60BB1C0D

Sep 17, 2017, 10:02 pm Last Edit: Sep 17, 2017, 10:31 pm by 0x60BB1C0D
I am trying to write a code to an Ardunio Uno (328p) but after I uploaded the sketch, nothing is being ran. It Verifies. It Uploads. Does not show any error, but the sketches doesn`t seem to run not even the SETUP part.
It is the second time that this happens. It happened with my LightBlue Bean+ (an 328p based board with Bluetooth). After that, a simple "digitalWrite(PORT,LOW)" does not work.

I think that the code that broke it is the part bellow, since it was the last think added before breaking it (for both time)
Code: [Select]

TCCR2A = 0x02;     // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE //COM2A1 COM2A0 COM2B1 COM2B0 - - WGM21=1 WGM20
TCCR2B = 0x05;     // DON'T FORCE COMPARE, 128 PRESCALER //FOC2A FOC2B - - WGM22 CS22=1 CS21 CS20=1
// WGM = 010 CTC
OCR2A = 0X7C;      // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE //register of the value that is going to be compared
TIMSK2 = 0x02;     // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A
TCNT2 = 0;
sei();             // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED


but for completions sakes, I am attaching my whole code (it is messy as right know).

After running the code attached, I can't even run a code as simples as
Code: [Select]

#define BUZZER_PORT 0
setup(){digitalWrite(BUZZER_PORT,LOW)}
loop(){}



Thank you in advance for your time

pert

I can't even run a code as simples as
Code: [Select]

setup(){digitalWrite(BUZZER_PORT,LOW)}
loop(){}

What do you mean by "can't even run"? That code won't compile because BUZZER_PORT isn't declared.

0x60BB1C0D

Sorry for not being clearer.
I Missed the
Code: [Select]
#define BUZZER_PORT 0
It does not run. It is compiled and it doesn't show any errors.

Grumpy_Mike

Writing to pins 0 & 1 are a bad idea because they handle the uploading of code.

That simple code will run but may not do what you think. This is because you haven't set that pin to be an output and by default all pins power up as inputs. So what you are actually doing by writing to an input pin is turning the pull up resistor on and off.



0x60BB1C0D

Writing to pins 0 & 1 are a bad idea because they handle the uploading of code.

That simple code will run but may not do what you think. This is because you haven't set that pin to be an output and by default all pins power up as inputs. So what you are actually doing by writing to an input pin is turning the pull up resistor on and off.
Thank you a lot! that fixed the problem on the Arduino, that was the main reason of the question. I had a VERY SIMILAR problem with another development Board (lightblue bean+) and when the problem appeard on the Arduino I already jumped to the conclusion that it was my code without testing another pin.

Also posted at: https://stackoverflow.com/q/46268541
Is bad use of the forum posting it here AND on stackoverflow even though they are 2 different forums?

And here.
That problem is still looking for an answer. The way the problem was fixed here did not worked on the Bean+.


Overall, thank you all for the help, and I if anyone have any idea how to solve the problem with the LIGHTBLUE bean+, I would be very, very grateful. But this can be done on the other post.
https://forum.arduino.cc/index.php?topic=499670.0

pert

Is bad use of the forum posting it here AND on stackoverflow even though they are 2 different forums?
I'm not super crazy about that practice but when I spoke out against it a couple times in the past a bunch of forum regulars disagreed with me so I guess it's considered to be fine here. However, if you're going to do it it's essential to add links to the other places you posted (as I did in the comments here and on Stack Overflow). This is important for two reasons:
  • Prevent us wasting time due to duplicating efforts that were already made on the other post. It's very annoying for me to spend 5 minutes writing an answer here only to browse to Stack Exchange and see that someone else already gave you the same answer half an hour earlier.
  • Help others who have the same problem and find your post to find all the available information.


I would also request that you take the time to answer your own question on Stack Overflow, as is the recommended practice on Stack Exchange sites when you find a solution before anyone else has provided an answer. Do this as an answer rather than editing your question.

Wawa

Spreading the same problem across different treads and in different forums is disrespectful to the people who put time and efford in helping you. As pert says, adding a link softens that a bit.
I try to avoid helping crossposters.
Leo..

Go Up