msr Posted April 21, 2009 at 10:02 PM Report #258086 Posted April 21, 2009 at 10:02 PM Olá, Tenho visto algumas linhas de código que nao tenho entendido. Se me pudessem esclarecer, agradecia. Aqui vao elas: uint8_t pidTimer:1; uint8_t dummy:7; TCCR0A = (1<<CS00); TIFR |= _BV(OCIE0)|_BV(TOIE0); UBRR0H = (BAUD_RR >> 8) & 0xff; Será que me podem explicar o que é feito (de forma genérica) em cada uma destas linhas? COMPONENT ORGANIZER easily organize your electronic parts and application notes
Baderous Posted April 22, 2009 at 12:09 AM Report #258111 Posted April 22, 2009 at 12:09 AM uint8_t pidTimer:1; uint8_t dummy:7; Isto define pidTimer como uma variável do tipo uint8_t, mas só será formada por 1 bit, assim como dummy só será formada por 7 bits. São os chamados bit fields. TCCR0A = (1<<CS00); Realiza o shift aritmético à esquerda do 1. TIFR |= _BV(OCIE0)|_BV(TOIE0); Realiza o OR (bit a bit) entre TIFR, _BV(OCIE0) e _BV(TOIE0) http://en.wikipedia.org/wiki/Bitwise_operation UBRR0H = (BAUD_RR >> 8) & 0xff; Faz o shift aritmético à direita e depois realiza o AND bit a bit entre o resultado e o 0xff.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now