Develop a syntactically correct C program for the asynchronous serial communications protocol as follows. Your program should set up the USART1 Module of the STM32F4 microcontroller to communicate (transmit and receive) at the rate of approx. 50000 Baud. You should choose suitable clock rates for this problem. The frame should consist of a start bit, seven data bits, even parity bit, and one stop bit. It is up to you to decide whether you want to work with interrupts or with the polling method. The program first waits for a syn character (syn=0x16) but will only accept it if no receive error flags (FE, PE, or ORE) are set. If any error flags are set the program shall respond by sending a nak character (nak=0x15), it will send an ack character (ack=0x06), otherwise. The process repeats until a received syn character is accepted. However, the program should keep a syn receive error count. If the error count reached the value 5 then the program would enter an infinite waiting loop with return (1). Otherwise, the communication protocol will move on to the next phase in which the program will wait for a single, visible, valid ASCII character. If it is received without any error (see above), the program shall respond by sending an ack, it will send a nak, otherwise. The process repeats until the ASCII character is received without any error. The accepted character should be written to a memory location. Again, if the character receive error count reached the value 5 then the program would enter an infinite waiting loop with return (2). Having successfully received a character the program should be terminated by an infinite waiting loop with return (0).
Hi! Can you please help me with the code for this? It's written using CubeMX and IAR for the STM32F429ZI microcontroller board.
Develop a syntactically correct C
protocol as follows. Your program should set up the USART1 Module of the STM32F4
microcontroller to communicate (transmit and receive) at the rate of approx. 50000 Baud.
You should choose suitable clock rates for this problem. The frame should consist of a
start bit, seven data bits, even parity bit, and one stop bit. It is up to you to decide
whether you want to work with interrupts or with the polling method.
The program first waits for a syn character (syn=0x16) but will only accept it if no
receive error flags (FE, PE, or ORE) are set. If any error flags are set the program shall
respond by sending a nak character (nak=0x15), it will send an ack character
(ack=0x06), otherwise. The process repeats until a received syn character is accepted.
However, the program should keep a syn receive error count. If the error count reached
the value 5 then the program would enter an infinite waiting loop with return (1).
Otherwise, the communication protocol will move on to the next phase in which the
program will wait for a single, visible, valid ASCII character. If it is received without
any error (see above), the program shall respond by sending an ack, it will send a nak,
otherwise. The process repeats until the ASCII character is received without any error.
The accepted character should be written to a memory location. Again, if the character
receive error count reached the value 5 then the program would enter an infinite waiting
loop with return (2). Having successfully received a character the program should be
terminated by an infinite waiting loop with return (0).
I've been trying to get the polling method to work, but I'm incredibly stuck.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps