Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3. #include <util/delay.h>
  4. volatile unsigned char data=0; //buffer secondaire
  5.  
  6. ISR(USART_RX_vect)/**interuption pour le Rx**/
  7. {
  8. data=UDR;
  9. PORTA=~PORTA ;
  10. }
  11.  
  12. int main(void)
  13. {
  14. DDRA = 0xFF ;
  15. DDRB = 0xFF ;
  16. SREG=0x80; //active interrup générales
  17. UCSRB=(1<<RXCIE)|(1<<RXEN);
  18. UBRRL=(unsigned char) 60; //vitesse max!
  19. UCSRC=(1<<URSEL)|(1<<UPM1)|(3<<UCSZ0); //parametres du bus 8/P/1
  20. PORTA=0x00 ;
  21. PORTB=0x00 ;
  22. while(1)
  23. {
  24. if (data==0x01)
  25. {
  26. PORTB=~PORTB;
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement