Results 1 to 5 of 5
Thread: (avr-gcc)
Hybrid View
-
26th June 2012 01:08 #1
(avr-gcc)
! AVR . , PWM, - . - , - , ? switch , , ? - , ?
, , .D80; 50/1.8D; Tamron 70-300; 18-55 VR;
-
26th June 2012 01:11 #2Registered User
Join Date: Oct:2003
Location:
Posts: 4,317
-
26th June 2012 02:16 #3
: timer0_init . , CLK, , interrupt, , saw tooth trig wave, PWM , PWM ..
- switch. , , datasheet-a.
- , .
( , , ):
, :Code:int timer0_init(const int top, const int prescl, const int pina, const int pinb) { // Warning: Set bits manually to avoid glitches in time-critical implementations TCCR0A=top; //set the initial compare value of the counter TCCR0B&=0b11111000; switch(prescl){ case 0 :; break; case 1 : TCCR0B|=0b00000001; break; case 8 : TCCR0B|=0b00000010; break; case 64 : TCCR0B|=0b00000011; break; case 256 : TCCR0B|=0b00000100; break; case 1024 : TCCR0B|=0b00000101; break; case -1 : TCCR0B|=0b00000110; break; //negative edge case -2 : TCCR0B|=0b00000111; break; //positive edge default :;}; TCCR0A&=0b00111111; switch(pina){ case 0 :; break; //OC0A turned off case 1 : TCCR0A|=0b01000000; break; //Toggle OC0A on Compare Match case 2 : TCCR0A|=0b10000000; break; //Clear case 3 : TCCR0A|=0b11000000; break; //Set default :;}; TCCR0A&=0b11001111; switch(pina){ case 0 :; break; //OC0A turned off case 1 : TCCR0A|=0b00010000; break; //Toggle OC0A on Compare Match case 2 : TCCR0A|=0b00100000; break; //Clear case 3 : TCCR0A|=0b00110000; break; //Set default :;}; TCCR0A|=1<<WGM00; sei(); }
Code:timer0_init(0, 1, 2, 0);
Code:TCCR0A=top; //set the initial compare value of the counter TCCR0B|=0b00000001; TCCR0A|=0b10000000; TCCR0A|=0b00000000; TCCR0A|=1<<WGM00; sei(); //standard enable interrupt
D80; 50/1.8D; Tamron 70-300; 18-55 VR;
-
26th June 2012 06:04 #4
" ", - link time code generation . ..
: , , :
1. .c ,
2. .c .o/.obj ( ) .
3. .o . , , .
4. , . , , ( ).
.., , .c , , , .
, libc (rand() , strlen() ..)
- switch()- , .
- . LTCG, . 3 - , .c , , , . "" - , "".
- . .c - foo() bar(). , bar() . foo() .
, . .
"640K ught to be enough for anybody" - Bill Gates, 1981
::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel
-
29th June 2012 23:19 #5
, , anrieff

( -Os (optimize for size) avr-gcc):
, (4 - include statement-a , )
- switch- .
, , , - , .Last edited by KaloyanP; 30th June 2012 at 00:08.
D80; 50/1.8D; Tamron 70-300; 18-55 VR;




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in