#define NOP __asm__ __volatile__ ("nop")
void setup() {
DDRB |= 0b00100000;
cli();
}
// the loop function runs over and over again forever
void loop() {
PORTB |= 0b00100000;
//digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
NOP;
NOP;
NOP;
..... many more NOPS;
then code to turn it on
}
hi guys,
WHERE is that stupid function like add -z to assembly to don't skip NOP blocks? cannot find it anywhere..
timing is ignored. with delay - code works. thanx for help!
#define NOP __asm__ __volatile__ ("nop")
void setup() {
DDRB |= 0b00100000;
cli();
}
// the loop function runs over and over again forever
void loop() {
PORTB |= 0b00100000;
__builtin_avr_delay_cycles (800);
PORTB &= ~0b00100000;
__builtin_avr_delay_cycles (800);
}
even this code doesn't work.. should wait 50ms which is visible as blinking (tested with delay(50))
biely123:
WHERE is that stupid function
Evidently not in the Arduino reference, so perhaps you can draw your own conclusions.
with delay - code works.
So why not use it?
This was not hard to find.
https://forum.arduino.cc/index.php?topic=43333.0
I have found out. it was not 800 but 800000 cycles to have 50ms.. my bad...