Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 16000000UL
- //#include "mydelay.h"
- #include <avr/io.h>
- #include "kernel.h"
- #include <util/delay_basic.h>
- #define NULL (void *) 0
- #ifndef __HAS_DELAY_CYCLES
- #define __HAS_DELAY_CYCLES 1
- #endif
- // Base frequency for the buzzer
- #define BASE_FREQ 200
- int pwm_val = 0;
- int pwm_val2 = 0;
- unsigned adc_val = 0;
- long __tmp;
- void
- _my_delay_ms(long __ms)
- {
- uint16_t __ticks;
- #if !__HAS_DELAY_CYCLES || (__HAS_DELAY_CYCLES && !defined(__OPTIMIZE__)) || defined (__DELAY_BACKWARD_COMPATIBLE__)
- __tmp = ((F_CPU) / 4000) * __ms;
- if (__tmp < 1)
- __ticks = 1;
- else if (__tmp > 65535)
- {
- // __ticks = requested delay in 1/10 ms
- __ticks = (uint16_t)(__ms * 10);
- while(__ticks)
- {
- // wait 1/10 ms
- _delay_loop_2(((F_CPU) / 4e3) / 10);
- __ticks --;
- }
- return;
- }
- else
- __ticks = (uint16_t)__tmp;
- _delay_loop_2(__ticks);
- #endif
- }
Add Comment
Please, Sign In to add comment