Hello,
My plan is just basic LED control on my custom board with HC 05 Bluetooth module. Actually, a code, which was found in Youtube (
), runs successfully such as send 'Hello' but the light is constantly on. So, I want to control with 1 and 0 for led on-off control. FYI, the crystal on the board is 32.768kHZ so I set RCC as low speed, and Baud Rate is set as 115200 in CubeMX. Do anyone know about this control?
The code is in stm32f7xx_it.c file is
/* Includes ------------------------------------------------------------------*/
#include "stm32f7xx_hal.h"
#include "stm32f7xx.h"
#include "stm32f7xx_it.h"
/* USER CODE BEGIN 0 */
uint8_t Rx_Byte[1];
uint8_t Rx_Data[10];
uint8_t Rx_DataCnt;
uint8_t Rx_Flag;
/* USER CODE END 0 */
....
void USART2_IRQHandler(void)
{
/* USER CODE BEGIN USART2_IRQn 0 */
HAL_UART_Receive(&huart2,(uint8_t*)Rx_Byte,1,100);
/* USER CODE END USART2_IRQn 0 */
HAL_UART_IRQHandler(&huart2);
/* USER CODE BEGIN USART2_IRQn 1 */
Rx_Data[Rx_DataCnt++]=Rx_Byte[0];
if(Rx_DataCnt>=5)
{
Rx_Flag=1;
Rx_DataCnt=0;
}
/* USER CODE END USART2_IRQn 1 */
}
The code is in main.c file is
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
extern uint8_t Rx_Byte[1];
extern uint8_t Rx_Data[10];
extern uint8_t Rx_DataCnt;
extern uint8_t Rx_Flag;
/* USER CODE END PV */
...
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
if(Rx_Flag == 1)
{
HAL_UART_Transmit(&huart2,Rx_Data,5,100);
HAL_GPIO_WritePin(LED_1_GPIO_Port,LED_1_Pin,GPIO_PIN_SET);
Rx_Flag=0;
}
}