RenHao

mainProject_IRQ

Jan 9th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include "Definitions.h"
  2.  
  3. ISR(USART0_RX_vect)
  4. {
  5.     while( !(UCSR0A & (1 << RXC0)) )
  6.     //wait for RXC flag
  7.         ;
  8.        
  9.     /* Loop-back test */
  10.     //PORTB |= (1 << PB7);
  11.     //test_data = UDR0;
  12.     TxFlag = true;
  13.     //enableUDRI0();
  14.    
  15.    
  16.     //PORTB &= ~(1 << PB7);
  17.     //PORTB |= (1 << PB7);
  18.     RxBuffer[rxcount++] = UDR0;
  19.     if( !(rxcount < RX_BUF_SZ) )    //rxcount = 0;
  20.     {
  21.         PORTB |= (1 << PB7);
  22.         RxFlag = true;
  23.     }
  24.    
  25.    
  26. }
  27.  
  28. ISR(USART0_UDRE_vect)
  29. {
  30.     while( !(UCSR0A & (1 << UDRE0)) )
  31.     //wait for udr to be empty
  32.         ;
  33.    
  34.     /* Loop-back test */
  35.     //UDR0 = test_data;
  36.     UDR0 = 0x30 + rxcount;
  37.    
  38.     //for(int i = 0; i < 2; i++)
  39.         //UDR0 = 0x55;
  40.    
  41.     //PORTB &= ~(1 << PB7);
  42.     disableUDRI0();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment