Results 1 to 5 of 5

Thread: (avr-gcc)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    a.k.a. Kal KaloyanP's Avatar
    Join Date: Dec:2005
    Location: UK
    Posts: 3,750

    (avr-gcc)

    ! AVR . , PWM, - . - , - , ? switch , , ? - , ?

    , , .
    D80; 50/1.8D; Tamron 70-300; 18-55 VR;

  2. #2
    Registered User
    Join Date: Oct:2003
    Location:
    Posts: 4,317
    Quote Originally Posted by KaloyanP View Post
    ........ , ?
    .
    switch , , ?
    switch ? , , switch?

  3. #3
    a.k.a. Kal KaloyanP's Avatar
    Join Date: Dec:2005
    Location: UK
    Posts: 3,750
    Quote Originally Posted by bsb View Post
    switch ? , , switch?
    : 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;

  4. #4
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    " ", - 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

  5. #5
    a.k.a. Kal KaloyanP's Avatar
    Join Date: Dec:2005
    Location: UK
    Posts: 3,750
    , , 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;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |