Joystick Setup Configuration 🎮
Before to do the configuration on STM32CubeMX take a look of all pin configurations in this table
1. Connecting Joystick Sensor to STM32 board
Joystick Pin |
STM32 Board Pin > Pin CubeMX Config |
Connection Diagram |
VRx |
A5 > PC_0 |
|
VRy |
A4 > PC_1 |
SW |
D2 > PA_10 |
GND |
GND pin of Board |
2.1 Add ADC1 to DMA
In this section we set the two ADC1 channels to DMA in this way:
- Goes in the Configuration settings as before and click on DMA Settings
- Click on Add and select ADC1
- After we select the Mode as Normal and the other parameter as Word as we see in the picture
2. GPIO Configuration
- Configure GPIO pin for joystick button:
- Navigate to the GPIO Configuration tab.
- Set the pin PA_10 as a GPIO input.
- The final configuration look like that
3. Clock Configuration
- Ensure that the ADC clock is configured correctly in the RCC settings:
- Navigate to the RCC Configuration tab that is situated in “System Core”.
- Set High Speed Clock HSE as “Crystal/Ceramic Resonator”
- Clock configuration Tab
- Take a look on the schema and we need to modify:
- In PLL Source MUX select HSE
- In System Clock MUX select HSI and the last value in the HCLK(MHz) select the maximum value that the board support
Now go back