GAS LISTING /tmp/cc3xivid.s page 1 1 .file "test.c" 2 __SP_H__ = 0x3e 3 __SP_L__ = 0x3d 4 __SREG__ = 0x3f 5 __tmp_reg__ = 0 6 __zero_reg__ = 1 9 .text 10 .Ltext0: 104 .global delay_ms 106 delay_ms: 107 .stabd 46,0,0 1:test.c **** #include 2:test.c **** #include 3:test.c **** #include 4:test.c **** #include 5:test.c **** 6:test.c **** #include "avr_print.h" 7:test.c **** 8:test.c **** #define THRESHOLD 0x70 9:test.c **** #define THRESHOLD_OFF 0x30 10:test.c **** 11:test.c **** 12:test.c **** void delay_ms(uint32_t time) { 109 .LM0: 110 .LFBB1: 111 0000 0F93 push r16 112 0002 1F93 push r17 113 /* prologue: function */ 114 /* frame size = 0 */ 115 /* stack size = 2 */ 116 .L__stack_usage = 2 13:test.c **** uint32_t i; 14:test.c **** for (i = 0; i < time; i++) { 118 .LM1: 119 0004 00E0 ldi r16,0 120 0006 10E0 ldi r17,0 121 0008 9801 movw r18,r16 122 .L2: 124 .LM2: 125 000a 0617 cp r16,r22 126 000c 1707 cpc r17,r23 127 000e 2807 cpc r18,r24 128 0010 3907 cpc r19,r25 129 0012 01F0 breq .L5 130 .LBB4: 131 .LBB5: 133 .Ltext1: 1:/usr/lib/avr/include/util/delay.h **** /* Copyright (c) 2002, Marek Michalkiewicz 2:/usr/lib/avr/include/util/delay.h **** Copyright (c) 2004,2005,2007 Joerg Wunsch 3:/usr/lib/avr/include/util/delay.h **** Copyright (c) 2007 Florin-Viorel Petrov 4:/usr/lib/avr/include/util/delay.h **** All rights reserved. 5:/usr/lib/avr/include/util/delay.h **** 6:/usr/lib/avr/include/util/delay.h **** Redistribution and use in source and binary forms, with or without 7:/usr/lib/avr/include/util/delay.h **** modification, are permitted provided that the following conditions are met: 8:/usr/lib/avr/include/util/delay.h **** 9:/usr/lib/avr/include/util/delay.h **** * Redistributions of source code must retain the above copyright 10:/usr/lib/avr/include/util/delay.h **** notice, this list of conditions and the following disclaimer. GAS LISTING /tmp/cc3xivid.s page 2 11:/usr/lib/avr/include/util/delay.h **** 12:/usr/lib/avr/include/util/delay.h **** * Redistributions in binary form must reproduce the above copyright 13:/usr/lib/avr/include/util/delay.h **** notice, this list of conditions and the following disclaimer in 14:/usr/lib/avr/include/util/delay.h **** the documentation and/or other materials provided with the 15:/usr/lib/avr/include/util/delay.h **** distribution. 16:/usr/lib/avr/include/util/delay.h **** 17:/usr/lib/avr/include/util/delay.h **** * Neither the name of the copyright holders nor the names of 18:/usr/lib/avr/include/util/delay.h **** contributors may be used to endorse or promote products derived 19:/usr/lib/avr/include/util/delay.h **** from this software without specific prior written permission. 20:/usr/lib/avr/include/util/delay.h **** 21:/usr/lib/avr/include/util/delay.h **** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22:/usr/lib/avr/include/util/delay.h **** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23:/usr/lib/avr/include/util/delay.h **** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24:/usr/lib/avr/include/util/delay.h **** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25:/usr/lib/avr/include/util/delay.h **** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26:/usr/lib/avr/include/util/delay.h **** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27:/usr/lib/avr/include/util/delay.h **** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28:/usr/lib/avr/include/util/delay.h **** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29:/usr/lib/avr/include/util/delay.h **** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30:/usr/lib/avr/include/util/delay.h **** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31:/usr/lib/avr/include/util/delay.h **** POSSIBILITY OF SUCH DAMAGE. */ 32:/usr/lib/avr/include/util/delay.h **** 33:/usr/lib/avr/include/util/delay.h **** /* $Id$ */ 34:/usr/lib/avr/include/util/delay.h **** 35:/usr/lib/avr/include/util/delay.h **** #ifndef _UTIL_DELAY_H_ 36:/usr/lib/avr/include/util/delay.h **** #define _UTIL_DELAY_H_ 1 37:/usr/lib/avr/include/util/delay.h **** 38:/usr/lib/avr/include/util/delay.h **** #ifndef __HAS_DELAY_CYCLES 39:/usr/lib/avr/include/util/delay.h **** #define __HAS_DELAY_CYCLES 1 40:/usr/lib/avr/include/util/delay.h **** #endif 41:/usr/lib/avr/include/util/delay.h **** 42:/usr/lib/avr/include/util/delay.h **** #include 43:/usr/lib/avr/include/util/delay.h **** #include 44:/usr/lib/avr/include/util/delay.h **** #include 45:/usr/lib/avr/include/util/delay.h **** 46:/usr/lib/avr/include/util/delay.h **** /** \file */ 47:/usr/lib/avr/include/util/delay.h **** /** \defgroup util_delay : Convenience functions for busy-wait delay loops 48:/usr/lib/avr/include/util/delay.h **** \code 49:/usr/lib/avr/include/util/delay.h **** #define F_CPU 1000000UL // 1 MHz 50:/usr/lib/avr/include/util/delay.h **** //#define F_CPU 14.7456E6 51:/usr/lib/avr/include/util/delay.h **** #include 52:/usr/lib/avr/include/util/delay.h **** \endcode 53:/usr/lib/avr/include/util/delay.h **** 54:/usr/lib/avr/include/util/delay.h **** \note As an alternative method, it is possible to pass the 55:/usr/lib/avr/include/util/delay.h **** F_CPU macro down to the compiler from the Makefile. 56:/usr/lib/avr/include/util/delay.h **** Obviously, in that case, no \c \#define statement should be 57:/usr/lib/avr/include/util/delay.h **** used. 58:/usr/lib/avr/include/util/delay.h **** 59:/usr/lib/avr/include/util/delay.h **** The functions in this header file are wrappers around the basic 60:/usr/lib/avr/include/util/delay.h **** busy-wait functions from . They are meant as 61:/usr/lib/avr/include/util/delay.h **** convenience functions where actual time values can be specified 62:/usr/lib/avr/include/util/delay.h **** rather than a number of cycles to wait for. The idea behind is 63:/usr/lib/avr/include/util/delay.h **** that compile-time constant expressions will be eliminated by 64:/usr/lib/avr/include/util/delay.h **** compiler optimization so floating-point expressions can be used 65:/usr/lib/avr/include/util/delay.h **** to calculate the number of delay cycles needed based on the CPU 66:/usr/lib/avr/include/util/delay.h **** frequency passed by the macro F_CPU. 67:/usr/lib/avr/include/util/delay.h **** GAS LISTING /tmp/cc3xivid.s page 3 68:/usr/lib/avr/include/util/delay.h **** \note In order for these functions to work as intended, compiler 69:/usr/lib/avr/include/util/delay.h **** optimizations must be enabled, and the delay time 70:/usr/lib/avr/include/util/delay.h **** must be an expression that is a known constant at 71:/usr/lib/avr/include/util/delay.h **** compile-time. If these requirements are not met, the resulting 72:/usr/lib/avr/include/util/delay.h **** delay will be much longer (and basically unpredictable), and 73:/usr/lib/avr/include/util/delay.h **** applications that otherwise do not use floating-point calculations 74:/usr/lib/avr/include/util/delay.h **** will experience severe code bloat by the floating-point library 75:/usr/lib/avr/include/util/delay.h **** routines linked into the application. 76:/usr/lib/avr/include/util/delay.h **** 77:/usr/lib/avr/include/util/delay.h **** The functions available allow the specification of microsecond, and 78:/usr/lib/avr/include/util/delay.h **** millisecond delays directly, using the application-supplied macro 79:/usr/lib/avr/include/util/delay.h **** F_CPU as the CPU clock frequency (in Hertz). 80:/usr/lib/avr/include/util/delay.h **** 81:/usr/lib/avr/include/util/delay.h **** */ 82:/usr/lib/avr/include/util/delay.h **** 83:/usr/lib/avr/include/util/delay.h **** #if !defined(__DOXYGEN__) 84:/usr/lib/avr/include/util/delay.h **** static inline void _delay_us(double __us) __attribute__((always_inline)); 85:/usr/lib/avr/include/util/delay.h **** static inline void _delay_ms(double __ms) __attribute__((always_inline)); 86:/usr/lib/avr/include/util/delay.h **** #endif 87:/usr/lib/avr/include/util/delay.h **** 88:/usr/lib/avr/include/util/delay.h **** #ifndef F_CPU 89:/usr/lib/avr/include/util/delay.h **** /* prevent compiler error by supplying a default */ 90:/usr/lib/avr/include/util/delay.h **** # warning "F_CPU not defined for " 91:/usr/lib/avr/include/util/delay.h **** # define F_CPU 1000000UL 92:/usr/lib/avr/include/util/delay.h **** #endif 93:/usr/lib/avr/include/util/delay.h **** 94:/usr/lib/avr/include/util/delay.h **** #ifndef __OPTIMIZE__ 95:/usr/lib/avr/include/util/delay.h **** # warning "Compiler optimizations disabled; functions from won't work as designed" 96:/usr/lib/avr/include/util/delay.h **** #endif 97:/usr/lib/avr/include/util/delay.h **** 98:/usr/lib/avr/include/util/delay.h **** #if __HAS_DELAY_CYCLES && defined(__OPTIMIZE__) && \ 99:/usr/lib/avr/include/util/delay.h **** !defined(__DELAY_BACKWARD_COMPATIBLE__) && \ 100:/usr/lib/avr/include/util/delay.h **** __STDC_HOSTED__ 101:/usr/lib/avr/include/util/delay.h **** # include 102:/usr/lib/avr/include/util/delay.h **** #endif 103:/usr/lib/avr/include/util/delay.h **** 104:/usr/lib/avr/include/util/delay.h **** /** 105:/usr/lib/avr/include/util/delay.h **** \ingroup util_delay 106:/usr/lib/avr/include/util/delay.h **** 107:/usr/lib/avr/include/util/delay.h **** Perform a delay of \c __ms milliseconds, using _delay_loop_2(). 108:/usr/lib/avr/include/util/delay.h **** 109:/usr/lib/avr/include/util/delay.h **** The macro F_CPU is supposed to be defined to a 110:/usr/lib/avr/include/util/delay.h **** constant defining the CPU clock frequency (in Hertz). 111:/usr/lib/avr/include/util/delay.h **** 112:/usr/lib/avr/include/util/delay.h **** The maximal possible delay is 262.14 ms / F_CPU in MHz. 113:/usr/lib/avr/include/util/delay.h **** 114:/usr/lib/avr/include/util/delay.h **** When the user request delay which exceed the maximum possible one, 115:/usr/lib/avr/include/util/delay.h **** _delay_ms() provides a decreased resolution functionality. In this 116:/usr/lib/avr/include/util/delay.h **** mode _delay_ms() will work with a resolution of 1/10 ms, providing 117:/usr/lib/avr/include/util/delay.h **** delays up to 6.5535 seconds (independent from CPU frequency). The 118:/usr/lib/avr/include/util/delay.h **** user will not be informed about decreased resolution. 119:/usr/lib/avr/include/util/delay.h **** 120:/usr/lib/avr/include/util/delay.h **** If the avr-gcc toolchain has __builtin_avr_delay_cycles(unsigned long) 121:/usr/lib/avr/include/util/delay.h **** support, maximal possible delay is 4294967.295 ms/ F_CPU in MHz. For 122:/usr/lib/avr/include/util/delay.h **** values greater than the maximal possible delay, overflows results in 123:/usr/lib/avr/include/util/delay.h **** no delay i.e., 0ms. 124:/usr/lib/avr/include/util/delay.h **** GAS LISTING /tmp/cc3xivid.s page 4 125:/usr/lib/avr/include/util/delay.h **** Conversion of __us into clock cycles may not always result in integer. 126:/usr/lib/avr/include/util/delay.h **** By default, the clock cycles rounded up to next integer. This ensures that 127:/usr/lib/avr/include/util/delay.h **** the user gets atleast __us microseconds of delay. 128:/usr/lib/avr/include/util/delay.h **** 129:/usr/lib/avr/include/util/delay.h **** Alternatively, user can define __DELAY_ROUND_DOWN__ and __DELAY_ROUND_CLOSEST__ 130:/usr/lib/avr/include/util/delay.h **** to round down and round to closest integer. 131:/usr/lib/avr/include/util/delay.h **** 132:/usr/lib/avr/include/util/delay.h **** Note: The new implementation of _delay_ms(double __ms) with 133:/usr/lib/avr/include/util/delay.h **** __builtin_avr_delay_cycles(unsigned long) support is not backward compatible. 134:/usr/lib/avr/include/util/delay.h **** User can define __DELAY_BACKWARD_COMPATIBLE__ to get a backward compatible delay. 135:/usr/lib/avr/include/util/delay.h **** Also, the backward compatible 136:/usr/lib/avr/include/util/delay.h **** algorithm will be chosen if the code is compiled in a freestanding 137:/usr/lib/avr/include/util/delay.h **** environment (GCC option \c -ffreestanding), as the math functions 138:/usr/lib/avr/include/util/delay.h **** required for rounding are not available to the compiler then. 139:/usr/lib/avr/include/util/delay.h **** 140:/usr/lib/avr/include/util/delay.h **** */ 141:/usr/lib/avr/include/util/delay.h **** void 142:/usr/lib/avr/include/util/delay.h **** _delay_ms(double __ms) 143:/usr/lib/avr/include/util/delay.h **** { 144:/usr/lib/avr/include/util/delay.h **** double __tmp ; 145:/usr/lib/avr/include/util/delay.h **** #if __HAS_DELAY_CYCLES && defined(__OPTIMIZE__) && \ 146:/usr/lib/avr/include/util/delay.h **** !defined(__DELAY_BACKWARD_COMPATIBLE__) && \ 147:/usr/lib/avr/include/util/delay.h **** __STDC_HOSTED__ 148:/usr/lib/avr/include/util/delay.h **** uint32_t __ticks_dc; 149:/usr/lib/avr/include/util/delay.h **** extern void __builtin_avr_delay_cycles(unsigned long); 150:/usr/lib/avr/include/util/delay.h **** __tmp = ((F_CPU) / 1e3) * __ms; 151:/usr/lib/avr/include/util/delay.h **** 152:/usr/lib/avr/include/util/delay.h **** #if defined(__DELAY_ROUND_DOWN__) 153:/usr/lib/avr/include/util/delay.h **** __ticks_dc = (uint32_t)fabs(__tmp); 154:/usr/lib/avr/include/util/delay.h **** 155:/usr/lib/avr/include/util/delay.h **** #elif defined(__DELAY_ROUND_CLOSEST__) 156:/usr/lib/avr/include/util/delay.h **** __ticks_dc = (uint32_t)(fabs(__tmp)+0.5); 157:/usr/lib/avr/include/util/delay.h **** 158:/usr/lib/avr/include/util/delay.h **** #else 159:/usr/lib/avr/include/util/delay.h **** //round up by default 160:/usr/lib/avr/include/util/delay.h **** __ticks_dc = (uint32_t)(ceil(fabs(__tmp))); 161:/usr/lib/avr/include/util/delay.h **** #endif 162:/usr/lib/avr/include/util/delay.h **** 163:/usr/lib/avr/include/util/delay.h **** __builtin_avr_delay_cycles(__ticks_dc); 135 .LM3: 136 0014 E7E8 ldi r30,lo8(4999) 137 0016 F3E1 ldi r31,hi8(4999) 138 0018 3197 1: sbiw r30,1 139 001a 01F4 brne 1b 140 001c 00C0 rjmp . 141 001e 0000 nop 142 .LBE5: 143 .LBE4: 145 .Ltext2: 147 .LM4: 148 0020 0F5F subi r16,-1 149 0022 1F4F sbci r17,-1 150 0024 2F4F sbci r18,-1 151 0026 3F4F sbci r19,-1 152 0028 00C0 rjmp .L2 153 .L5: 154 /* epilogue start */ GAS LISTING /tmp/cc3xivid.s page 5 15:test.c **** _delay_ms(1); 16:test.c **** } 17:test.c **** } 156 .LM5: 157 002a 1F91 pop r17 158 002c 0F91 pop r16 159 002e 0895 ret 164 .Lscope1: 166 .stabd 78,0,0 168 .global __vector_2 170 __vector_2: 171 .stabd 46,0,0 18:test.c **** 19:test.c **** #define NOOP asm volatile("nop" ::) 20:test.c **** 21:test.c **** static void setup_clock( void ) 22:test.c **** { 23:test.c **** /*Examine Page 33*/ 24:test.c **** 25:test.c **** CLKPR = 0x80; /*Setup CLKPCE to be receptive*/ 26:test.c **** CLKPR = 0x00; /*No scalar*/ 27:test.c **** 28:test.c **** PLLCSR = _BV(PLLE) | _BV( PCKE ); 29:test.c **** OSCCAL = 0x80; 30:test.c **** } 31:test.c **** 32:test.c **** volatile uint8_t overflow; 33:test.c **** 34:test.c **** //If pin breaches, this has to get called. 35:test.c **** ISR( PCINT0_vect, ISR_NAKED ) 36:test.c **** { 173 .LM6: 174 .LFBB2: 175 /* prologue: naked */ 176 /* frame size = 0 */ 177 /* stack size = 0 */ 178 .L__stack_usage = 0 37:test.c **** asm volatile( "reti" ); 180 .LM7: 181 /* #APP */ 182 ; 37 "test.c" 1 183 0030 1895 reti 184 ; 0 "" 2 185 /* epilogue start */ 38:test.c **** } 187 .LM8: 188 /* #NOAPP */ 190 .Lscope2: 192 .stabd 78,0,0 194 .global __vector_9 196 __vector_9: 197 .stabd 46,0,0 39:test.c **** 40:test.c **** //Handle if pin is down too long. 41:test.c **** ISR( TIMER1_COMPB_vect ) 42:test.c **** { 199 .LM9: GAS LISTING /tmp/cc3xivid.s page 6 200 .LFBB3: 201 0032 1F92 push r1 202 0034 0F92 push r0 203 0036 0FB6 in r0,__SREG__ 204 0038 0F92 push r0 205 003a 1124 clr __zero_reg__ 206 003c 8F93 push r24 207 /* prologue: Signal */ 208 /* frame size = 0 */ 209 /* stack size = 4 */ 210 .L__stack_usage = 4 43:test.c **** overflow = 1; 212 .LM10: 213 003e 81E0 ldi r24,lo8(1) 214 0040 8093 0000 sts overflow,r24 215 /* epilogue start */ 44:test.c **** } 217 .LM11: 218 0044 8F91 pop r24 219 0046 0F90 pop r0 220 0048 0FBE out __SREG__,r0 221 004a 0F90 pop r0 222 004c 1F90 pop r1 223 004e 1895 reti 225 .Lscope3: 227 .stabd 78,0,0 229 .global TakeReading 231 TakeReading: 232 .stabd 46,0,0 45:test.c **** 46:test.c **** //Takes reading from 0..127 of touch pressure. 47:test.c **** uint8_t TakeReading() 48:test.c **** { 234 .LM12: 235 .LFBB4: 236 /* prologue: function */ 237 /* frame size = 0 */ 238 /* stack size = 0 */ 239 .L__stack_usage = 0 49:test.c **** uint8_t ret; 50:test.c **** 51:test.c **** sleep_enable(); 241 .LM13: 242 0050 85B7 in r24,0x35 243 0052 8062 ori r24,lo8(32) 244 0054 85BF out 0x35,r24 52:test.c **** TCNT1 = 0; 246 .LM14: 247 0056 1FBC out 0x2f,__zero_reg__ 53:test.c **** TIFR |= _BV(TOV1); 249 .LM15: 250 0058 88B7 in r24,0x38 251 005a 8460 ori r24,lo8(4) 252 005c 88BF out 0x38,r24 54:test.c **** TIMSK |= _BV(OCIE1B); 254 .LM16: 255 005e 89B7 in r24,0x39 GAS LISTING /tmp/cc3xivid.s page 7 256 0060 8062 ori r24,lo8(32) 257 0062 89BF out 0x39,r24 55:test.c **** overflow = 0; 259 .LM17: 260 0064 1092 0000 sts overflow,__zero_reg__ 56:test.c **** 57:test.c **** DDRB &= ~_BV(3); 262 .LM18: 263 0068 BB98 cbi 0x17,3 58:test.c **** PORTB |= _BV(3); 265 .LM19: 266 006a C39A sbi 0x18,3 59:test.c **** 60:test.c **** TCNT1 = 0; 268 .LM20: 269 006c 1FBC out 0x2f,__zero_reg__ 61:test.c **** sleep_cpu(); 271 .LM21: 272 /* #APP */ 273 ; 61 "test.c" 1 274 006e 8895 sleep 275 276 ; 0 "" 2 62:test.c **** ret = TCNT1; 278 .LM22: 279 /* #NOAPP */ 280 0070 8FB5 in r24,0x2f 63:test.c **** if( overflow ) ret = 0xff; 282 .LM23: 283 0072 9091 0000 lds r25,overflow 284 0076 9111 cpse r25,__zero_reg__ 285 0078 8FEF ldi r24,lo8(-1) 286 .L9: 64:test.c **** TIMSK &= ~_BV(OCIE1B); 288 .LM24: 289 007a 99B7 in r25,0x39 290 007c 9F7D andi r25,lo8(-33) 291 007e 99BF out 0x39,r25 65:test.c **** 66:test.c **** PORTB &=~_BV(3); 293 .LM25: 294 0080 C398 cbi 0x18,3 67:test.c **** DDRB |= _BV(3); 296 .LM26: 297 0082 BB9A sbi 0x17,3 68:test.c **** 69:test.c **** return ret>>1; 70:test.c **** } 299 .LM27: 300 0084 8695 lsr r24 301 0086 0895 ret 306 .Lscope4: 308 .stabd 78,0,0 310 .global Take64Reading 312 Take64Reading: 313 .stabd 46,0,0 71:test.c **** GAS LISTING /tmp/cc3xivid.s page 8 72:test.c **** uint16_t Take64Reading() 73:test.c **** { 315 .LM28: 316 .LFBB5: 317 0088 1F93 push r17 318 008a CF93 push r28 319 008c DF93 push r29 320 /* prologue: function */ 321 /* frame size = 0 */ 322 /* stack size = 3 */ 323 .L__stack_usage = 3 325 .LM29: 326 008e 10E4 ldi r17,lo8(64) 74:test.c **** uint8_t i; 75:test.c **** uint16_t ret = 0; 328 .LM30: 329 0090 C0E0 ldi r28,0 330 0092 D0E0 ldi r29,0 331 .L13: 76:test.c **** for( i = 0; i < 64; i++ ) 77:test.c **** { 78:test.c **** ret += TakeReading(); 333 .LM31: 334 0094 00D0 rcall TakeReading 335 0096 C80F add r28,r24 336 0098 D11D adc r29,__zero_reg__ 337 009a 1150 subi r17,lo8(-(-1)) 76:test.c **** for( i = 0; i < 64; i++ ) 339 .LM32: 340 009c 01F4 brne .L13 79:test.c **** } 80:test.c **** return ret; 81:test.c **** } 342 .LM33: 343 009e CE01 movw r24,r28 344 /* epilogue start */ 345 00a0 DF91 pop r29 346 00a2 CF91 pop r28 347 00a4 1F91 pop r17 348 00a6 0895 ret 353 .Lscope5: 355 .stabd 78,0,0 356 .section .text.startup,"ax",@progbits 358 .global main 360 main: 361 .stabd 46,0,0 82:test.c **** 83:test.c **** int main( ) 84:test.c **** { 363 .LM34: 364 .LFBB6: 365 /* prologue: function */ 366 /* frame size = 0 */ 367 /* stack size = 0 */ 368 .L__stack_usage = 0 85:test.c **** uint16_t minimum = 0xffff; 86:test.c **** uint8_t wasdown = 0; GAS LISTING /tmp/cc3xivid.s page 9 87:test.c **** uint16_t i; 88:test.c **** 89:test.c **** uint8_t reduxct = 0; 90:test.c **** cli(); 370 .LM35: 371 /* #APP */ 372 ; 90 "test.c" 1 373 0000 F894 cli 374 ; 0 "" 2 91:test.c **** 92:test.c **** DDRB |= _BV(4); 376 .LM36: 377 /* #NOAPP */ 378 0002 BC9A sbi 0x17,4 379 .LBB9: 380 .LBB10: 25:test.c **** CLKPR = 0x00; /*No scalar*/ 382 .LM37: 383 0004 80E8 ldi r24,lo8(-128) 384 0006 86BD out 0x26,r24 26:test.c **** 386 .LM38: 387 0008 16BC out 0x26,__zero_reg__ 28:test.c **** OSCCAL = 0x80; 389 .LM39: 390 000a 96E0 ldi r25,lo8(6) 391 000c 97BD out 0x27,r25 29:test.c **** } 393 .LM40: 394 000e 81BF out 0x31,r24 395 .LBE10: 396 .LBE9: 93:test.c **** 94:test.c **** setup_clock(); 95:test.c **** setup_spi(); 398 .LM41: 399 0010 00D0 rcall setup_spi 96:test.c **** 97:test.c **** PORTB &= ~_BV(3); 401 .LM42: 402 0012 C398 cbi 0x18,3 98:test.c **** DDRB |= _BV(3); 404 .LM43: 405 0014 BB9A sbi 0x17,3 99:test.c **** MCUCR &= ~_BV(PUD); 407 .LM44: 408 0016 85B7 in r24,0x35 409 0018 8F7B andi r24,lo8(-65) 410 001a 85BF out 0x35,r24 100:test.c **** 101:test.c **** TCCR1 = _BV(CS11); 412 .LM45: 413 001c 82E0 ldi r24,lo8(2) 414 001e 80BF out 0x30,r24 102:test.c **** 103:test.c **** set_sleep_mode( SLEEP_MODE_IDLE ); 416 .LM46: GAS LISTING /tmp/cc3xivid.s page 10 417 0020 85B7 in r24,0x35 418 0022 877E andi r24,lo8(-25) 419 0024 85BF out 0x35,r24 104:test.c **** 105:test.c **** GIMSK |= _BV(PCIE); 421 .LM47: 422 0026 8BB7 in r24,0x3b 423 0028 8062 ori r24,lo8(32) 424 002a 8BBF out 0x3b,r24 106:test.c **** PCMSK |= _BV(3); 426 .LM48: 427 002c AB9A sbi 0x15,3 107:test.c **** 108:test.c **** OCR1A = OCR1B = 0xff; 429 .LM49: 430 002e 8FEF ldi r24,lo8(-1) 431 0030 8BBD out 0x2b,r24 432 0032 8EBD out 0x2e,r24 109:test.c **** 110:test.c **** sei(); 434 .LM50: 435 /* #APP */ 436 ; 110 "test.c" 1 437 0034 7894 sei 438 ; 0 "" 2 111:test.c **** 112:test.c **** Take64Reading(); 440 .LM51: 441 /* #NOAPP */ 442 0036 00D0 rcall Take64Reading 89:test.c **** cli(); 444 .LM52: 445 0038 00E0 ldi r16,0 86:test.c **** uint16_t i; 447 .LM53: 448 003a 10E0 ldi r17,0 85:test.c **** uint8_t wasdown = 0; 450 .LM54: 451 003c CFEF ldi r28,lo8(-1) 452 003e DFEF ldi r29,lo8(-1) 453 .L15: 454 .LBB11: 113:test.c **** 114:test.c **** while(1) 115:test.c **** { 116:test.c **** uint16_t j; 117:test.c **** i = 0; 118:test.c **** 119:test.c **** i = Take64Reading(); 456 .LM55: 457 0040 00D0 rcall Take64Reading 120:test.c **** if( i < minimum ) minimum = i; //Immediately snap to current if it's lower. 459 .LM56: 460 0042 8C17 cp r24,r28 461 0044 9D07 cpc r25,r29 462 0046 00F0 brlo .L21 121:test.c **** else if( i > minimum ) //Very slowly recalibrate down. GAS LISTING /tmp/cc3xivid.s page 11 464 .LM57: 465 0048 C817 cp r28,r24 466 004a D907 cpc r29,r25 467 004c 00F4 brsh .L16 122:test.c **** { 123:test.c **** if( ( reduxct & 0x3f ) == 0 ) 469 .LM58: 470 004e 202F mov r18,r16 471 0050 2F73 andi r18,lo8(63) 472 0052 01F4 brne .L16 124:test.c **** minimum++; 474 .LM59: 475 0054 2196 adiw r28,1 476 0056 00C0 rjmp .L16 477 .L21: 478 0058 EC01 movw r28,r24 479 .L16: 125:test.c **** } 126:test.c **** i -= minimum; 481 .LM60: 482 005a 8C1B sub r24,r28 483 005c 9D0B sbc r25,r29 127:test.c **** reduxct++; 485 .LM61: 486 005e 0F5F subi r16,lo8(-(1)) 128:test.c **** 129:test.c **** if( wasdown ) 488 .LM62: 489 0060 1123 tst r17 490 0062 01F0 breq .L17 130:test.c **** { 131:test.c **** if( i < THRESHOLD_OFF ) wasdown = 0; 492 .LM63: 493 0064 C097 sbiw r24,48 494 0066 00F0 brlo .L18 495 0068 00C0 rjmp .L19 496 .L17: 132:test.c **** } 133:test.c **** else 134:test.c **** { 135:test.c **** if( i > THRESHOLD ) wasdown = 1; 498 .LM64: 499 006a 8137 cpi r24,113 500 006c 9105 cpc r25,__zero_reg__ 501 006e 00F0 brlo .L18 502 .L19: 136:test.c **** } 137:test.c **** 138:test.c **** if( wasdown ) 139:test.c **** PORTB |= _BV(4); 504 .LM65: 505 0070 C49A sbi 0x18,4 506 0072 11E0 ldi r17,lo8(1) 507 0074 00C0 rjmp .L15 508 .L18: 140:test.c **** else 141:test.c **** PORTB &=~_BV(4); GAS LISTING /tmp/cc3xivid.s page 12 510 .LM66: 511 0076 C498 cbi 0x18,4 512 0078 10E0 ldi r17,0 513 007a 00C0 rjmp .L15 514 .LBE11: 521 .Lscope6: 523 .stabd 78,0,0 524 .comm overflow,1,1 526 .text 528 .Letext0: 529 .ident "GCC: (GNU) 4.8.1" 530 .global __do_clear_bss GAS LISTING /tmp/cc3xivid.s page 13 DEFINED SYMBOLS *ABS*:0000000000000000 test.c /tmp/cc3xivid.s:2 *ABS*:000000000000003e __SP_H__ /tmp/cc3xivid.s:3 *ABS*:000000000000003d __SP_L__ /tmp/cc3xivid.s:4 *ABS*:000000000000003f __SREG__ /tmp/cc3xivid.s:5 *ABS*:0000000000000000 __tmp_reg__ /tmp/cc3xivid.s:6 *ABS*:0000000000000001 __zero_reg__ /tmp/cc3xivid.s:106 .text:0000000000000000 delay_ms /tmp/cc3xivid.s:170 .text:0000000000000030 __vector_2 /tmp/cc3xivid.s:196 .text:0000000000000032 __vector_9 *COM*:0000000000000001 overflow /tmp/cc3xivid.s:231 .text:0000000000000050 TakeReading /tmp/cc3xivid.s:312 .text:0000000000000088 Take64Reading /tmp/cc3xivid.s:360 .text.startup:0000000000000000 main UNDEFINED SYMBOLS setup_spi __do_clear_bss GAS LISTING /tmp/cc3xivid.s page 1 1 .file "avr_print.c" 2 __SP_H__ = 0x3e 3 __SP_L__ = 0x3d 4 __SREG__ = 0x3f 5 __tmp_reg__ = 0 6 __zero_reg__ = 1 9 .text 10 .Ltext0: 114 .global sendchr 116 sendchr: 117 .stabd 46,0,0 1:avr_print.c **** /* AVR PRINTING (C) 2011 <>< Charles Lohr - This file may be licensed under the MIT/x11 or New BSD 2:avr_print.c **** //Use tinyispterm to use this: https://github.com/cnlohr/tinyispterm 3:avr_print.c **** 4:avr_print.c **** #include 5:avr_print.c **** #include 6:avr_print.c **** #include 7:avr_print.c **** #include 8:avr_print.c **** #include 9:avr_print.c **** 10:avr_print.c **** #ifndef MUTE_PRINTF 11:avr_print.c **** 12:avr_print.c **** #if defined (__AVR_ATtiny2313__) || defined (__AVR_ATtiny2313A__) 13:avr_print.c **** #define SPI_DDR_SET {DDRB&=0x1F;DDRB|=0x40;} 14:avr_print.c **** #define SPI_TINY 15:avr_print.c **** #define SPI_USI 16:avr_print.c **** 17:avr_print.c **** 18:avr_print.c **** #elif defined (__AVR_ATtiny85__) || defined (__AVR_ATtiny45__) 19:avr_print.c **** #define SPI_DDR_SET {DDRB&=~(_BV(2)|_BV(0));DDRB|=_BV(1);} 20:avr_print.c **** #define SPI_TINY 21:avr_print.c **** #define SPI_USI 22:avr_print.c **** 23:avr_print.c **** #elif defined (__AVR_ATtiny261__) || defined (__AVR_ATtiny261A__) 24:avr_print.c **** #define SPI_DDR_SET {DDRA&=0xFA;DDRA|=0x02;} 25:avr_print.c **** #define SPI_TINY 26:avr_print.c **** 27:avr_print.c **** #elif defined (__AVR_ATtiny44__) || defined (__AVR_ATtiny44A__) || \ 28:avr_print.c **** defined (__AVR_ATtiny24__) || defined (__AVR_ATtiny24A__) || \ 29:avr_print.c **** defined (__AVR_ATtiny84__) || defined (__AVR_ATtiny84A__) 30:avr_print.c **** #define SPI_DDR_SET {DDRA&=0xAF;DDRA|=0x20;} 31:avr_print.c **** #define SPI_TINY 32:avr_print.c **** #define SPI_USI 33:avr_print.c **** 34:avr_print.c **** 35:avr_print.c **** #elif defined (__AVR_ATmega32U2__) || defined( __AVR_ATmega8U2__ ) 36:avr_print.c **** #define SPI_MEGA 37:avr_print.c **** #define SPI_DDR_SET { DDRB |= _BV(3); DDRB &= ~(_BV(0)|_BV(1)|_BV(2)); } 38:avr_print.c **** 39:avr_print.c **** 40:avr_print.c **** #elif defined (__AVR_ATmega168__) || defined( __AVR_ATmega328__) 41:avr_print.c **** #define SPI_DDR_SET {DDRB&=0xD3;DDRB|=0x10;} 42:avr_print.c **** #define SPI_MEGA 43:avr_print.c **** 44:avr_print.c **** #else 45:avr_print.c **** #error UNDEFINED PIN ASSIGNMENTS 46:avr_print.c **** GAS LISTING /tmp/cc3xivid.s page 2 47:avr_print.c **** #endif 48:avr_print.c **** 49:avr_print.c **** //OPTIONAL!!! 50:avr_print.c **** //#ifdef SPI_TINY 51:avr_print.c **** //#define USE_SPI_INTERRUPT 52:avr_print.c **** //#endif 53:avr_print.c **** 54:avr_print.c **** 55:avr_print.c **** #ifdef USE_SPI_INTERRUPT 56:avr_print.c **** 57:avr_print.c **** volatile unsigned char ThisCharToSend = 0; 58:avr_print.c **** volatile unsigned char BackChar = 0; 59:avr_print.c **** #ifdef SPI_MEGA 60:avr_print.c **** ISR( SPI_STC_vect ) 61:avr_print.c **** { 62:avr_print.c **** BackChar = SPDR; 63:avr_print.c **** SPDR = ThisCharToSend; 64:avr_print.c **** ThisCharToSend = 0; 65:avr_print.c **** } 66:avr_print.c **** #elif defined( SPI_TINY ) 67:avr_print.c **** ISR( USI_OVF_vect ) 68:avr_print.c **** { 69:avr_print.c **** USIBR = ThisCharToSend; 70:avr_print.c **** ThisCharToSend = 0; 71:avr_print.c **** USISR |= (1<>4 ); 109:avr_print.c **** sendhex1( i&0x0f ); 110:avr_print.c **** } 111:avr_print.c **** void sendhex4( unsigned int i ) 112:avr_print.c **** { 113:avr_print.c **** sendhex2( i>>8 ); 114:avr_print.c **** sendhex2( i&0xFF); 115:avr_print.c **** } 116:avr_print.c **** 117:avr_print.c **** 118:avr_print.c **** static int SPIPutCharInternal(char c, FILE *stream) 119:avr_print.c **** { 149 .LM4: 150 .LFBB2: 151 /* prologue: function */ 152 /* frame size = 0 */ 153 /* stack size = 0 */ 154 .L__stack_usage = 0 120:avr_print.c **** sendchr( c ); 156 .LM5: 157 000c 00D0 rcall sendchr 121:avr_print.c **** return 0; 122:avr_print.c **** } 159 .LM6: 160 000e 80E0 ldi r24,0 161 0010 90E0 ldi r25,0 162 0012 0895 ret 164 .Lscope2: 166 .stabd 78,0,0 169 .global sendhex1 171 sendhex1: 172 .stabd 46,0,0 103:avr_print.c **** sendchr( (i<10)?(i+'0'):(i+'A'-10) ); GAS LISTING /tmp/cc3xivid.s page 4 174 .LM7: 175 .LFBB3: 176 /* prologue: function */ 177 /* frame size = 0 */ 178 /* stack size = 0 */ 179 .L__stack_usage = 0 104:avr_print.c **** } 181 .LM8: 182 0014 8A30 cpi r24,lo8(10) 183 0016 00F4 brsh .L7 104:avr_print.c **** } 185 .LM9: 186 0018 805D subi r24,lo8(-(48)) 187 001a 00C0 rjmp .L8 188 .L7: 104:avr_print.c **** } 190 .LM10: 191 001c 895C subi r24,lo8(-(55)) 192 .L8: 104:avr_print.c **** } 194 .LM11: 195 001e 00C0 rjmp sendchr 197 .Lscope3: 199 .stabd 78,0,0 202 .global sendhex2 204 sendhex2: 205 .stabd 46,0,0 107:avr_print.c **** sendhex1( i>>4 ); 207 .LM12: 208 .LFBB4: 209 0020 CF93 push r28 210 /* prologue: function */ 211 /* frame size = 0 */ 212 /* stack size = 1 */ 213 .L__stack_usage = 1 214 0022 C82F mov r28,r24 108:avr_print.c **** sendhex1( i&0x0f ); 216 .LM13: 217 0024 8295 swap r24 218 0026 8F70 andi r24,lo8(15) 219 0028 00D0 rcall sendhex1 109:avr_print.c **** } 221 .LM14: 222 002a 8C2F mov r24,r28 223 002c 8F70 andi r24,lo8(15) 224 /* epilogue start */ 110:avr_print.c **** void sendhex4( unsigned int i ) 226 .LM15: 227 002e CF91 pop r28 109:avr_print.c **** } 229 .LM16: 230 0030 00C0 rjmp sendhex1 232 .Lscope4: 234 .stabd 78,0,0 236 .global sendhex4 238 sendhex4: 239 .stabd 46,0,0 GAS LISTING /tmp/cc3xivid.s page 5 112:avr_print.c **** sendhex2( i>>8 ); 241 .LM17: 242 .LFBB5: 243 0032 CF93 push r28 244 /* prologue: function */ 245 /* frame size = 0 */ 246 /* stack size = 1 */ 247 .L__stack_usage = 1 248 0034 C82F mov r28,r24 113:avr_print.c **** sendhex2( i&0xFF); 250 .LM18: 251 0036 892F mov r24,r25 252 0038 00D0 rcall sendhex2 114:avr_print.c **** } 254 .LM19: 255 003a 8C2F mov r24,r28 256 /* epilogue start */ 115:avr_print.c **** 258 .LM20: 259 003c CF91 pop r28 114:avr_print.c **** } 261 .LM21: 262 003e 00C0 rjmp sendhex2 264 .Lscope5: 266 .stabd 78,0,0 268 .global setup_spi 270 setup_spi: 271 .stabd 46,0,0 123:avr_print.c **** 124:avr_print.c **** static FILE mystdout = FDEV_SETUP_STREAM( SPIPutCharInternal, NULL, _FDEV_SETUP_WRITE ); 125:avr_print.c **** 126:avr_print.c **** 127:avr_print.c **** void setup_spi( void ) 128:avr_print.c **** { 273 .LM22: 274 .LFBB6: 275 /* prologue: function */ 276 /* frame size = 0 */ 277 /* stack size = 0 */ 278 .L__stack_usage = 0 129:avr_print.c **** SPI_DDR_SET; 280 .LM23: 281 0040 87B3 in r24,0x17 282 0042 8A7F andi r24,lo8(-6) 283 0044 87BB out 0x17,r24 284 0046 B99A sbi 0x17,1 130:avr_print.c **** 131:avr_print.c **** #ifdef SPI_TINY 132:avr_print.c **** USICR = (1<