In stm32 wifi transmission and reception

Viewed 28
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MPU Configuration--------------------------------------------------------*/
  MPU_Config();

  /* Enable I-Cache---------------------------------------------------------*/
  SCB_EnableICache();

  /* Enable D-Cache---------------------------------------------------------*/
  SCB_EnableDCache();

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_TIM6_Init();
  MX_UART7_Init();
  MX_USART3_UART_Init();
  MX_UART5_Init();
  MX_USART1_UART_Init();
  MX_USART6_UART_Init();
  MX_UART8_Init();
  MX_SPI2_Init();
  MX_SPI3_Init();
  MX_SPI5_Init();
  MX_I2C1_Init();
  MX_RNG_Init();
  MX_TIM3_Init();
  MX_USB_OTG_FS_PCD_Init();
  MX_RTC_Init();
  MX_FMC_Init();
  MX_TIM7_Init();
  /* USER CODE BEGIN 2 */
  HAL_UART_Receive_DMA(&huart3, (uint8_t*)RX_BUFFER3, RX_BUFFER3_SIZE);
  HAL_UART_Receive_DMA(&huart7, (uint8_t*)RX_BUFFER7, RX_BUFFER7_SIZE);
  
  
#if BW16_ENABLE
  
  HAL_UART_Receive_DMA(&huart5, (uint8_t*)BW_BUFFER5, BW_BUFFER5_SIZE);
  
  // BW16 RESET
   bw16_Reset();
  
  // BW16 Init
  bw16_init(&huart5);
  
    RxCntUart5 = __HAL_DMA_GET_COUNTER(huart5.hdmarx);  
    if(BW_BUFFER5_SIZE != RxCntUart5)
    {
      __HAL_DMA_DISABLE(huart5.hdmarx); 
      __HAL_DMA_SET_COUNTER(huart5.hdmarx, BW_BUFFER5_SIZE);
      __HAL_DMA_ENABLE(huart5.hdmarx);       
       
    }
    
#endif
   
  /* USER CODE END 2 */

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  HAL_TIM_Base_Start_IT(&htim6);
  HAL_TIM_Base_Start_IT(&htim7);
  /* USER CODE END RTOS_QUEUES */

  /* Create the thread(s) */
  /* definition and creation of defaultTask */
  osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 256);
  defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);

  /* definition and creation of TcpTask */
  osThreadDef(TcpTask, Tcp_Task, osPriorityIdle, 0, 256);
  TcpTaskHandle = osThreadCreate(osThread(TcpTask), NULL);

  /* definition and creation of Usart3Task */
  osThreadDef(Usart3Task, Usart3_Task, osPriorityIdle, 0, 256);
  Usart3TaskHandle = osThreadCreate(osThread(Usart3Task), NULL);

  /* definition and creation of Uart7Task */
  osThreadDef(Uart7Task, Uart7_Task, osPriorityIdle, 0, 256);
  Uart7TaskHandle = osThreadCreate(osThread(Uart7Task), NULL);

  /* definition and creation of BWdataTask */
  osThreadDef(BWdataTask, bwdata_Task, osPriorityIdle, 0, 256);
  BWdataTaskHandle = osThreadCreate(osThread(BWdataTask), NULL);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */ 

  /* USER CODE END RTOS_THREADS */

  /* Start scheduler */
  osKernelStart();

  /* We should never get here as control is now taken by the scheduler */
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

void bwdata_Task(void const * argument)
{
  /* USER CODE BEGIN bwdata_Task */
  /* Infinite loop */
  for(;;)
  {
        SCB_InvalidateDCache_by_Addr ((uint32_t *)BW_BUFFER5, BW_BUFFER5_SIZE);

    pos2 =  __HAL_DMA_GET_COUNTER(huart5.hdmarx);

    pos = BW_BUFFER5_SIZE - pos2;
        

    if(pos != old_pos) 
        {
           
                
        if(pos > old_pos) 
                {
            memcpy(rx_temBuffer, &BW_BUFFER5[old_pos], pos - old_pos);

            rx_size =+ pos - old_pos;
        } 
                else 
                {
            memcpy(rx_temBuffer, &BW_BUFFER5[old_pos], get_dma_total_size() - old_pos);
            rx_size += get_dma_total_size() - old_pos;


            if(pos > 0){
                memcpy(&rx_temBuffer[get_dma_total_size() - old_pos], &BW_BUFFER5[0], pos);
                rx_size += pos;
            }
        }

        old_pos = pos;
                

        if(rx_size > 0) 
                {
                    HAL_UART_Receive_DMA(&huart5, (uint8_t*)BW_BUFFER5, BW_BUFFER5_SIZE);
                    printf("%s\n\r", (char*)&BW_BUFFER5);
                  
#if BW16_ENABLE
                  
                    bw16_send_data (&huart5, rx_size, "1", rx_temBuffer);
#endif
                  
        }
                rx_size = 0;
    }
        
    
  }
  /* USER CODE END bwdata_Task */
}

I want to write the code above so that I can send and receive wifi, but the wifi connection is good.

However, if I send a message from the server to the client (stm32), it will be printed only once, and I receive a message after that, but it doesn't printf. It says there is a problem like below, how can I solve it?

An MPU or Execute Never (XN) default memory map access violation has occurred on an instruction fetch (CFSR.IACCVIOL, MMFAR).

It's a reaction that comes out if you send it only once below.

enter image description here

enter image description here

0 Answers
Related