#include
#include
int k=0,i=0,j=0;
char s[4];
/*
*The function of the program is to send back the data sent from the computer
*/
void usart0_init()
{
UCSR0A=0X00;
UCSR0B = 0x00;
UCSR0C=0X00;
UCSR0C=(1<
UBRR0H=0;
UCSR0B=(1<
DDRE=0X02; //MCU ports RX0 and TX0 must be functional, the PE buckle corresponding to RX0 must be set to input mode, and the pull-up must be enabled, and TX0 must be set to output mode
}
int main(void)
{
DDRA=0XFF;
PORTA=0XFF;
DDRB=0XFF;
PORTB=0X00;
usart0_init();
sei();
while(1)
{
PORTA=(s[0]<<8)+s[0];
}
}
/*
*Receive end interrupt
*/
ISR(USART0_RX_vect)
{
cli();
if(i<2)
{
s[i]=UDR0;//Accept 4 characters each time
i++;
}
else
{
i=0;
while(!(UCSR0A&(1<
UDR0=s[0];
}
}
/*
*Send end interrupt
*/
ISR(USART0_TX_vect)
{
cli();
j++;
while(!(UCSR0A&(1<
else j=0;
sei();
}
Previous article:AVR microcontroller timer T0 basic interrupt using ICCAVR
Next article:Use interrupt timing to send a string of characters
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Popular Science丨Six Elements of Brushless DC Motor Control
- Play with HDMI2.1 source test
- Microcontroller Course Design
- 555 Classic: 1-100 Minute Timer Circuit
- Features of Storage Products for Embedded and Industrial Applications
- 【CH579M-R1】Drive OLED to prepare for the project
- [Repost] Only these 8 tips are needed to restore the circuit board to the circuit diagram
- Anxinke NB-IoT module evaluation-Shangdian
- After more than two months of hard work, it is finally finished. Haha
- Live Review: Renesas Electronics R-Car Advanced Driver Assistance System Solution