help please,
does 1 have idea why following code outputs jittery signal? attached scope image.
thanks!!
does 1 have idea why following code outputs jittery signal? attached scope image.
thanks!!
code: [select]
int pinone = 9;
int pintwo = 10;
#define fastwrite(_pin_, _state_) ( _pin_ < 8 ? (_state_ ? portd |= 1 << _pin_ : portd &= ~(1 << _pin_ )) : (_state_ ? portb |= 1 << (_pin_ -8) : portb &= ~(1 << (_pin_ -8) )))
// macro sets or clears appropriate bit in port d if pin less 8 or port b if between 8 , 13
void setup() {
pinmode(pinone, output); // set outpin pin output
pinmode(pintwo, output);
}
void loop()
{
fastwrite(pinone, high); // set pin high
//delaymicroseconds(20); // waits "on" microseconds
fastwrite(pintwo, high);
delaymicroseconds(20);
fastwrite(pinone, low); // set pin low
//delaymicroseconds(20); //wait "off" microseconds
fastwrite(pintwo, low);
delaymicroseconds(20);
}
main() has call loop() , there interrupts going on in background micros()/millis() time tracking.
try this:
will main() , loop() jitteryness anyway.
try this:
code: [select]
void loop(){
while (1)
{
fastwrite(pinone, high); // set pin high
//delaymicroseconds(20); // waits "on" microseconds
fastwrite(pintwo, high);
delaymicroseconds(20);
fastwrite(pinone, low); // set pin low
//delaymicroseconds(20); //wait "off" microseconds
fastwrite(pintwo, low);
delaymicroseconds(20);
}
}
[color=#222222]
will main() , loop() jitteryness anyway.
Arduino Forum > Using Arduino > Programming Questions > FastWrite
arduino
Comments
Post a Comment