Question for Ladyada

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
nemesisrobot
 
Posts: 25
Joined: Tue Jan 01, 2008 3:27 am

Question for Ladyada

Post by nemesisrobot »

I was looking through your AFSoftSerial library, and came across this piece of code in your WhackDelay function:

Code: Select all

  asm volatile("sbiw    %0, 0x01 \n\t"
	       "ldi %1, 0xFF \n\t"
	       "cpi %A0, 0xFF \n\t"
	       "cpc %B0, %1 \n\t"
	       "brne .-10 \n\t"
	       : "+r" (delay), "+a" (tmp)
	       : "0" (delay)
	       );
I'm not very good with asm, but could you please tell me what's going on here? I was just a bit curious. Thanks!

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Post by adafruit »

its just a loop that takes a very specific amount time so that the UART has perfect timing!

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”