My first inline assembly for arduino

To implement bitbanging I need to generate code that has precise timing. Each instruction’s cycles count.

Inline assembly directives are new to me and I got some feedback from the arduino community.

It turns out  it’s not needed: PORTB |= 1<<pin is directly compiled to sei etc. so the cost is a known 2 cycles. For delays __builtin_avr_delay_cycles(n) generates an optimal spinning loop.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s