1 / 5

Hasznos ismeretek

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

vilina
Download Presentation

Hasznos ismeretek

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hasznos ismeretek Hogyan bővítsük ismereteinket AVRDUDEflags -E noreset

  2. 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 262.14 ms / F_CPU in MHz. • 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. • 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.

  3. stdlib.h • Function Documentation • int abs ( int __i  )   The abs() function computes the absolute value of the integer i. • Note: • The abs() and labs() functions are builtins of gcc. • 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); • <avr/sfr_defs.h>: Special function registers • #define bit_is_set(sfr, bit)   (_SFR_BYTE(sfr) & _BV(bit)) • #define bit_is_clear(sfr, bit)   (!(_SFR_BYTE(sfr) & _BV(bit))) • #define loop_until_bit_is_set(sfr, bit)   do { } while (bit_is_clear(sfr, bit)) • #define loop_until_bit_is_clear(sfr, bit)   do { } while (bit_is_set(sfr, bit)) - #define _BV(bit)   (1 << (bit))

  4. 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); • 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));

  5. Mások programjai • #include <avr/io.h> //Az I/O konyvtar • #include <util/delay.h> //A kesleltetes-beallitas konyvtar • #include "lcd.h" • #include<stdlib.h> • 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); • }

More Related