Hasznos ismeretek Hogyan bővítsük ismereteinket AVRDUDEflags -E noreset
A winavr-ről Winavr-manual/library reference, avr-libc Modules Meg lehet nézni a programozásban használható parancsokat és a kommenteket. Pl delay a util/delay.h állomány Header file (.h):itt függvények leírása van ami a használathoz kell, a függvény törzse a megfelelő.c állományban. –void _delay_ms ( double __ms ) Perform a delay of __ms milliseconds, using _delay_loop_2(). The macro F_CPU is supposed to be defined to a constant defining the CPU clock frequency (in Hertz). The maximal possible delay is ms / F_CPU in MHz._delay_loop_2() –void _delay_us ( double __us ) Perform a delay of __us microseconds, using _delay_loop_1(). The macro F_CPU is supposed to be defined to a constant defining the CPU clock frequency (in Hertz). The maximal possible delay is 768 us / F_CPU in MHz._delay_loop_1() –void _delay_loop_1 ( uint8_t __count ) Delay loop using an 8-bit counter __count, so up to 256 iterations are possible. (The value 256 would have to be passed as 0.) The loop executes three CPU cycles per iteration, not including the overhead the compiler needs to setup the counter register.uint8_t
stdlib.h –Function Documentation int abs ( int __i ) The abs() function computes the absolute value of the integer i.abs() Note: –The abs() and labs() functions are builtins of gcc.abs()labs() double atof ( const char * __nptr ) The atof() function converts the initial portion of the string pointed to by nptr to double representation. It is equivalent to calling strtod(nptr, (char **)NULL);atof()strtod : Special function registers –#define bit_is_set(sfr, bit) (_SFR_BYTE(sfr) & _BV(bit))bit_is_set –#define bit_is_clear(sfr, bit) (!(_SFR_BYTE(sfr) & _BV(bit)))bit_is_clear –#define loop_until_bit_is_set(sfr, bit) do { } while (bit_is_clear(sfr, bit))loop_until_bit_is_set –#define loop_until_bit_is_clear(sfr, bit) do { } while (bit_is_set(sfr, bit))loop_until_bit_is_clear - #define _BV(bit) (1 << (bit))_BV
Portok Porting programs that use sbi/cbi As described above, access to the AVR single bit set and clear instructions are provided via the standard C bit manipulation commands. The sbi and cbi commands are no longer directly supported. sbi (sfr,bit) can be replaced by sfr |= _BV(bit). ie: sbi(PORTB, PB1); is now PORTB |= _BV(PB1);_BV(bit)sbi(PORTB, PB1)_BV(PB1) This actually is more flexible than having sbi directly, as the optimizer will use a hardware sbi if appropriate, or a read/or/write if not. You do not need to keep track of which registers sbi/cbi will operate on. Likewise, cbi (sfr,bit) is now sfr &= ~(_BV(bit));_BV(bit)
Mások programjai #include //Az I/O konyvtar #include //A kesleltetes-beallitas konyvtar #include "lcd.h" #include int main(void) //A foprogram kezdete { DDRA = 0xFF; //A PORT A kimenet, LCD PORTA = 0x00; //A PORT A (PA0-PA5) kimeneteit 0-ra allitjuk, a (PA6-PA7) - 1-re lcd4_init(); //Az LCD kijelzo inicializalasa (4 bit, 2 sor) // int i,k,l; int s; //secundumok char sx[3]; //ez lesz a secundumok stringje // nyomógombokhoz kell E-port DDRE=0x00; PORTE=0xFF; // loop_until_bit_is_clear(PINE,4); //megakad a futas amig a 4. kapcs. for(;;) { for(s=0;k<10;s++) { if(bit_is_clear(PINE,5)){for(;;){}} for (i=0; i<5;i++) _delay_ms(200); itoa(s,sx,10); /s egszbol sx string, 10es szr. // // lcd4_init(); //Az LCD kijelzo inicializalasa (4 bit, 2 sor) // lcd4_com(0x01); //itt törölni kellene és a kurzort előre hozni lcd4_com(0x00); lcd4_dat('S'); lcd4_dat('e'); lcd4_dat('c'); lcd4_dat(':'); lcd4_dat(sx[0]); } return(0); }