Locate the UART Generic chapter and find the function for transmitting for UART in blocking mode, HAL_UART_Transmit.Scroll down to the list of functions, and find the description for HAL_GPIO_ReadPin which takes the port and pin of interest and returns its state. Open the STM32F3 HAL datasheet that you downloaded and find the GPIO Generic Driver chapter.It also encapsulates a lot of the lower layer hardware details that we might otherwise have to worry about. STM’s HAL layer allows us to use the same functions regardless of the particular STM chip we are using, minimizing the number of changes we would have to make if we changed chips. We need a function that will allow us to read the pushbutton state and a function to send our message over UART. We will fill the while loop with code that will send “hello world” through UART whenever we push the blue USER pushbutton. *Initialize all configured peripherals */ * Reset of all peripherals, Initializes the Flash interface and the Systick. Navigate to the main.c file and scroll down to the main() function.ĬubeMX automatically wrote in our initializations for us and an infinite while loop that currently does nothing.We’ll need to configure the same settings on the PC side. Our UART is configured with a baud of 115200, 8 bits per word with 1 stop bit, no parity, and some other features. Remember this for later. To view our UART configuration, open the usart.c file and look for the MX_USART1_UART_Init function.HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct) GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING You’ll also see our UART TX and RX pins and LED 2. You’ll see a configuration for the USER pushbutton pin which is labeled B1 on the development board, but this is NOT port B, pin 1 on the chip. Open the newly generated TrueSTUDIO project.ĬubeMX has generated a very simple project with some basic settings for you.If so, click Yes to download it and wait for it to finish. You may get a popup explaining you need a firmware package.Hit Open Project at the popup prompt and your project should open up in TrueSTUDIO. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |