Example description
USART_HyperTerminal_Interrupt USART Hyperterminal interrupt Example
Example Description
This example provides a description of how to use the EVAL_COM1 Transmit and Receive
interrupts to communicate with the hyperterminal.
First, the EVAL_COM1 sends the TxBuffer to the hyperterminal and still waiting for
a string from the hyperterminal that you must enter.
The string that you have entered is stored in the RxBuffer array. The receive
buffer have a RxBufferSize bytes as maximum (the reception is stopped when this
maximum receive value is reached).
The EVAL_COM1 is configured as follow:
- BaudRate = 9600 baud
- Word Length = 8 Bits (7 data bit + 1 parity bit)
- Two Stop Bit
- Odd parity
- Hardware flow control disabled (RTS and CTS signals)
- Receive and transmit enabled
When the parity is enabled, the computed parity is inserted at the MSB
position of the transmitted data.
Directory contents
- USART/HyperTerminal_Interrupt/stm32f2xx_conf.h Library Configuration file
- USART/HyperTerminal_Interrupt/stm32f2xx_it.h Interrupt handlers header file
- USART/HyperTerminal_Interrupt/stm32f2xx_it.c Interrupt handlers source file
- USART/HyperTerminal_Interrupt/main.c Main program
- USART/HyperTerminal_Interrupt/system_stm32f2xx.c STM32F2xx system source file
The "system_stm32f2xx.c" is generated by an automatic clock configuration
tool and can be easily customized to your own configuration.
To select different clock setup, use the "STM32F2xx_Clock_Configuration_V1.0.0.xls" tool.
Hardware and Software environment
- This example runs on STM32F2xx Devices.
- This example has been tested with STM322xG-EVAL RevB and can be easily tailored
to any other development board.
- STM322xG-EVAL Set-up
- Connect a null-modem female/female RS232 cable between the DB9 connector
CN16 (USART3) and PC serial port if you want to display data on the HyperTerminal.
Make sure that jumper JP22 is in position 1-2
- Hyperterminal configuration:
- Word Length = 7 Bits
- Two Stop Bit
- Odd parity
- BaudRate = 9600 baud
- flow control: None
===============================================================================
USART_Smartcard USART Smart Card example
Example Description
This example describes a firmware Smartcard Interface based on the STM32F2xx USART
peripheral. The main purpose of this firmware example is to provide resources
facilitating the development of an application using the USART peripheral in
smartcard mode.
The firmware interface is composed of library source files developed in order to
support ISO7816-3/4 specification, an application example is also provided.
This example is based on the AN2598 "Smartcard interface with the STM32F101xx
and STM32F103xx" application note. For more details, please refer to AN2598
available on www.st.com
Directory contents
- USART/SmartCard/platform_config.h Evaluation board specific configuration file
- USART/SmartCard/stm32f2xx_conf.h Library Configuration file
- USART/SmartCard/stm32f2xx_it.h Interrupt handlers header file
- USART/SmartCard/smartcard.h Smart card Header file
- USART/SmartCard/stm32f2xx_it.c Interrupt handlers
- USART/SmartCard/smartcard.c Smart Card firmware functions
- USART/SmartCard/main.c Main program
- USART/SmartCard/system_stm32f2xx.c STM32F2xx system source file
Hardware and Software environment
- This example runs on STM32F2xx Devices.
- This example has been tested with STM322xG-EVAL RevB and can be easily tailored
to any other development board.
- STM322xG-EVAL Set-up
- Use LED1, LED2, LED3 and LED4 connected respectively to PG.06, PG.08, PI.09
and PC.07 pins
- Make sure that JP21 is closed.
===============================================================================
USART_Printf USART_Printf
Example Description
This example shows how to retarget the C library printf function to the USART.
This implementation output the printf message on the Hyperterminal using USART3.
The USARTx is configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled (RTS and CTS signals)
- Receive and transmit enabled
Directory contents
- USART/USART_Printf/system_stm32f2xx.c STM32F2xx system clock configuration file
- USART/USART_Printf/stm32f2xx_conf.h Library Configuration file
- USART/USART_Printf/stm32f2xx_it.h Interrupt handlers header file
- USART/USART_Printf/stm32f2xx_it.c Interrupt handlers
- USART/USART_Printf/main.c Main program
The "system_stm32f2xx.c" is generated by an automatic clock configuration
tool and can be easily customized to your own configuration.
To select different clock setup, use the "STM32F2xx_Clock_Configuration_V1.0.0.xls" tool.
Hardware and Software environment
- This example runs on STM32F2xx Devices.
- This example has been tested with STM322xG-EVAL RevB and can be easily tailored
to any other development board.
- STM322xG-EVAL Set-up
- Connect a null-modem female/female RS232 cable between the DB9 connector
CN16 (USART3) and PC serial port if you want to display data on the HyperTerminal.
Make sure that jumper JP22 is in position 1-2
- Hyperterminal configuration:
- Word Length = 8 Bits
- One Stop Bit
- No parity
- BaudRate = 115200 baud
- flow control: None
===============================================================================
USART_DataExchangeDMA USART Communication Boards Data Exchange using DMA example
Example Description
This example provides a small application in which joystick buttons are used
to trigger USART communications using DMA and though using USART firmware library.
- Hardware Description
To use this example, you need to load it on two STM32 boards (let's call them
BoardA and BoardB) then connect these two boards through USART lines and GND.
*------------------------------------------------------------------------------*
| BoardA BoardB |
| ____________________ ____________________ |
| | | | | |
| | | | | |
| | __________ | | __________ | |
| | | USART |____|TX_____________RX|____| USART | | |
| | | Device1 |____|RX_____________TX|____| Device2 | | |
| | |__________| | | |__________| | |
| | | | | |
| | O LD1 | | O LD1 | |
| | O LD2 Joystick | | O LD2 Joystick | |
| | O LD3 _ | | O LD3 _ | |
| | O LD4 |_| | | O LD4 |_| | |
| | | | | |
| | GND O--|-----------------|--O GND | |
| |____________________| |____________________| |
| |
| |
*------------------------------------------------------------------------------*
- The connection between the pins should use a common Ground.
- Software Description
On BoardA, at each joystick buttons press:
- The USART BoardA sends the specific command to the USART BoardB (the command
contains the transaction code (CMD_RIGHT, CMD_LEFT, CMD_UP, CMD_DOWN or CMD_SEL)
followed by the number of data to be transmitted (CMD_RIGHT_SIZE, CMD_LEFT_SIZE,
CMD_UP_SIZE, CMD_DOWN_SIZE or CMD_SEL_SIZE)
- The USART BoardB receives the command and sends the CMD_ACK command to the USART BoardA
- The USART BoardA receives the CMD_ACK command and sends the number of bytes
from TxBuffer to the USART BoardB.
- The USART BoardB compares the number of bytes received with the defined ones into
his TxBuffer.
Received data correctness is signaled by LED lightening and though as follow:
- Joystick RIGHT and data correctly received ==> LD2, LD3 ON and LD4 OFF
- Joystick LEFT and data correctly received ==> LD4 ON, LD2 and LD3 are OFF
- Joystick UP and data correctly received ==> LD2 ON, LD3 and LD4 are OFF
- Joystick DOWN and data correctly received ==> LD3 ON, LD2 and LD4 are OFF
- Joystick SEL and data correctly received ==> LD2, LD3 and LD4 are ON
The steps described above can be also initiated and ensured by BoardB.
In both boards(BoardA or BoardB), the data transfers is managed using the USART
Tx/Rx channels DMA requests.
The SysTick is configured to generate interrupt each 10ms. A dedicated counter
inside the SysTick ISR is used to toggle the LD1 each 100ms indicating that the
firmware is running.
These operations can be repeated infinitely.
A defined communication timeout is insuring that the application will not remain
stuck if the USART communication is corrupted.
You can adjust this timeout through the USER_TIMEOUT define inside main.h file
depending on CPU frequency and application conditions (interrupts routines,
number of data to transfer, baudrate, CPU frequency...).
When a given operation is not finished within the defined timeout, a callback is
made to the function "TimeOut_UserCallback()", this function is used to manage
timeout communication failure. In this example, this callback implements a simple
infinite loop, but user can add his own implementation to manage timeout failure.
Directory contents
- USART/USART_TwoBoards/DataExchangeDMA/stm32f2xx_conf.h Library Configuration file
- USART/USART_TwoBoards/DataExchangeDMA/stm32f2xx_it.c Interrupt handlers
- USART/USART_TwoBoards/DataExchangeDMA/stm32f2xx_it.h Interrupt handlers header file
- USART/USART_TwoBoards/DataExchangeDMA/main.c Main program
- USART/USART_TwoBoards/DataExchangeDMA/main.h Main program header file
- USART/USART_TwoBoards/DataExchangeDMA/system_stm32f2xx.c STM32F2xx system source file
The "system_stm32f2xx.c" is generated by an automatic clock configuration
tool and can be easily customized to your own configuration.
To select different clock setup, use the "STM32F2xx_Clock_Configuration_V1.0.0.xls" tool.
Hardware and Software environment
- This example runs on STM32F2xx Devices.
- This example has been tested with STM322xG-EVAL RevB and can be easily tailored
to any other development board.
- STM322xG-EVAL Set-up
- Use LED1, LED2, LED3 and LED4 connected respectively to PG.06, PG.08, PI.09
and PC.07 pins
- Use the Joystick buttons
- Connect BoardA USART3 TX pin (PC.10) to BoardB USART3 RX pin (PC.11)
- Connect BoardA USART3 RX pin (PC.11) to BoardB USART3 TX pin (PC.10)
===============================================================================
USART_DataExchangeInterrupt USART Communication Boards Data Exchange using Interrupt example
Example Description
This example provides a small application in which joystick buttons are used
to trigger USART communication using interrupts and though using USART firmware
library.
- Hardware Description
To use this example, you need to load it on two STM32 boards (let's call them
BoardA and BoardB) then connect these two boards through UART lines and GND.
*------------------------------------------------------------------------------*
| BoardA BoardB |
| ____________________ ____________________ |
| | | | | |
| | | | | |
| | __________ | | __________ | |
| | | UART |____|TX_____________RX|____| UART | | |
| | | Device1 |____|RX_____________TX|____| Device2 | | |
| | |__________| | | |__________| | |
| | | | | |
| | O LD1 | | O LD1 | |
| | O LD2 Joystick | | O LD2 Joystick | |
| | O LD3 _ | | O LD3 _ | |
| | O LD4 |_| | | O LD4 |_| | |
| | | | | |
| | GND O--|-----------------|--O GND | |
| |____________________| |____________________| |
| |
| |
*------------------------------------------------------------------------------*
- The connection between the pins should use a common Ground.
- Software Description
On BoardA, at each joystick buttons press:
- The USART BoardA sends the specific command to the USART BoardB (the command
contains the transaction code (CMD_RIGHT, CMD_LEFT, CMD_UP, CMD_DOWN or CMD_SEL)
followed by the number of data to be transmitted (CMD_RIGHT_SIZE, CMD_LEFT_SIZE,
CMD_UP_SIZE, CMD_DOWN_SIZE or CMD_SEL_SIZE)
- The USART BoardB receives the command and sends the CMD_ACK command to the USART BoardA
- The USART BoardA receives the CMD_ACK command and sends the number of bytes
from TxBuffer to the USART BoardB.
- The USART BoardB compares the number of bytes received with the defined ones into
his TxBuffer.
Received data correctness is signaled by LED lightening and though as follow:
- Joystick RIGHT and data correctly received ==> LD2, LD3 ON and LD4 OFF
- Joystick LEFT and data correctly received ==> LD4 ON, LD2 and LD3 are OFF
- Joystick UP and data correctly received ==> LD2 ON, LD3 and LD4 are OFF
- Joystick DOWN and data correctly received ==> LD3 ON, LD2 and LD4 are OFF
- Joystick SEL and data correctly received ==> LD2, LD3 and LD4 are ON
The steps described above can be also initiated and ensured by BoardB.
In both boards(BoardA or BoardB), the data transfers is managed using USARTx_IRQHandler
in stm32f2xx_it.c file.
The SysTick is configured to generate interrupt each 10ms. A dedicated counter
inside the SysTick ISR is used to toggle the LD1 each 100ms indicating that the
firmware is running.
These operations can be repeated infinitely.
A defined communication timeout is insuring that the application will not remain
stuck if the USART communication is corrupted.
You can adjust this timeout through the USER_TIMEOUT define inside main.h file
depending on CPU frequency and application conditions (interrupts routines,
number of data to transfer, baudrate, CPU frequency...).
When a given operation is not finished within the defined timeout, a callback is
made to the function "TimeOut_UserCallback()", this function is used to manage
timeout communication failure. In this example, this callback implements a simple
infinite loop, but user can add his own implementation to manage timeout failure.
Directory contents
- USART/USART_TwoBoards/DataExchangeInterrupt/stm32f2xx_conf.h Library Configuration file
- USART/USART_TwoBoards/DataExchangeInterrupt/stm32f2xx_it.c Interrupt handlers
- USART/USART_TwoBoards/DataExchangeInterrupt/stm32f2xx_it.h Interrupt handlers header file
- USART/USART_TwoBoards/DataExchangeInterrupt/main.c Main program
- USART/USART_TwoBoards/DataExchangeInterrupt/main.h Main program header file
- USART/USART_TwoBoards/DataExchangeInterrupt/system_stm32f2xx.c STM32F2xx system source file
The "system_stm32f2xx.c" is generated by an automatic clock configuration
tool and can be easily customized to your own configuration.
To select different clock setup, use the "STM32F2xx_Clock_Configuration_V1.0.0.xls" tool.
Hardware and Software environment
- This example runs on STM32F2xx Devices.
- This example has been tested with STM322xG-EVAL RevB and can be easily tailored
to any other development board.
- STM322xG-EVAL Set-up
- Use LED1, LED2, LED3 and LED4 connected respectively to PG.06, PG.08, PI.09
and PC.07 pins
- Use the Joystick buttons
- Connect BoardA USART3 TX pin (PC.10) to BoardB USART3 RX pin (PC.11)
- Connect BoardA USART3 RX pin (PC.11) to BoardB USART3 TX pin (PC.10)