|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2012-5-28 22:12:37
|
显示全部楼层
millwood0 发表于 2012-5-28 21:35 ![](static/image/common/back.gif)
use this instead:you will need to see the assembly listing to see how many instructions / cycles for ...
It uses 4 cycles to toggle an IO with your method. The frequency is about 1.87MHz (frc=15MHz).- LED_FLP(PA5);
- aa: 90 e2 ldi r25, 0x20 ; 32
- ac: 82 b1 in r24, 0x02 ; 2
- ae: 89 27 eor r24, r25
- b0: 82 b9 out 0x02, r24 ; 2
- b2: fc cf rjmp .-8 ; 0xac <main+0x18>
复制代码 While use “|=” and "&=" operand, the compiler is smart enough to translate it to "cbi" and "sbi" instuction. (but the duty cycle is not 50%, a nop is needed)- LED_ON;
- aa: 15 98 cbi 0x02, 5 ; 2
- LED_OFF;
- ac: 15 9a sbi 0x02, 5 ; 2
- ae: fd cf rjmp .-6 ; 0xaa <main+0x16>
复制代码 |
|