Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include "stdlib.h"
  2. #include "avr/io.h"
  3. #include "util/delay.h"
  4.  
  5. void serial();
  6.  
  7. static int rpos=0;
  8.  
  9. int main()
  10. {
  11. DDRA &= ~(0b00000101); // for the USI input clk nd di
  12. DDRA |= 0b00000010;
  13.  
  14. while(1)
  15. {
  16. serial();
  17. }
  18.  
  19. return 0;
  20. }
  21.  
  22.  
  23. void serial()
  24. {
  25. USICR = 0b00011000;
  26. USIPP = 0x01;
  27. USIDR = 0b10101010;
  28.  
  29. //wait for 16 edges and counter overflow flag to be set
  30. while(!(USISR & (1<<USIOIF)));
  31.  
  32. rpos=USIBR;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement