Upper computer control LED

Source: Internet
Author: User

  

Using library functions, the result of debugging is on the red program,
int main (void)
{
U8 A;
U8 T;
U8 Len;
U16 Times=0;
Delay_init (); Time-lapse function initialization
Nvic_configuration (); Set Nvic Interrupt grouping 2:2-bit preemption priority, 2-bit response priority
Uart_init (9600); Serial port initialized to 9600
Led_init (); LED Port Initialization
Key_init (); Initializing the hardware interface to the key connection
while (1)
{
if (usart_rx_sta&0x8000)
{
len=usart_rx_sta&0x3fff;//get the length of the data received
printf ("\ r \ n You sent the message: \r\n\r\n");
for (t=0;t<len;t++)
{
Usart_senddata (USART1, usart_rx_buf[t]);//Send data to serial 1
A=usart_rx_buf[t];
while (Usart_getflagstatus (USART1,USART_FLAG_TC)!=set);//wait for Send to end
}
printf ("\r\n\r\n");//Insert line break
usart_rx_sta=0;
}else
{
times++;
if (times%5000==0)
{
printf ("\r\nstm32 Export Control led\r\n");
}
if (times%200==0) printf ("Please enter data, end with enter \ n");
if (a== ' 0 ') led0=0;//flashes LED0, prompting the system to be running.
if (a== ' 1 ') led0=1;//flashes LED1, prompting the system to be running.
if (a== ' 2 ') led1=0;//flashes LED0, prompting the system to be running.
if (a== ' 3 ') led1=1;//flashes LED1, prompting the system to be running.

Delay_ms (10);
}
}
}
It is proved feasible in serial debugging.

Upper computer control LED

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.