cancel
Showing results for 
Search instead for 
Did you mean: 

Multiprocessor mode with address mark detection only receives data which has '0' as MSB. After waking up (RWU=0) when the correct address is received subsequent bytes should be received normally, and not interpreted as another address?

RWedu.1
Associate II

I have configured the UART for multiprocessor communication over RS485. I can receive and transmit data correctly, but if the data contains a '1' as MSB it is interpreted as an address. Now it is clear from the documentation that this is the correct behavior, but after the correct address is received (RWU set to 0 and RXNE set to 1, confirmed by debugging) I can only receive data < the defined address. For example, if I set wordlength to 9bit and the address to 4, the correct address will be 132 (10000100) which is expected. But subsequent bytes are still interpreted as addresses. Sending 132,55,45,150 (via RealTerm) will only receive 132,55,45 as 132 is the correct address and 44,55 has '0' as MSB. 150 is interpreted as a new address and RWU is again set to 1 since it is incorrect and I can no longer receive data.

My question is how can i interpret subsequent bytes after an correct address as pure data bytes, before I go back to listening for an address again? If I understand correctly, RWU and RXNE is set by HW in this mode? Or is there something specific I should do in FW? My implementation is interrupt-based for now.

EDIT: The MCU is F303K8

I'll attach some pictures, code and documentation for details and clarity.

Thanks!

Reference manual:

0693W000007Ehc9QAC.png0693W000007EhcsQAC.pngCode/debug:

0693W000007EhgBQAS.png 

int main(void)
{
  /* USER CODE BEGIN 1 */
  testvar = testvar + 1;
  /* USER CODE END 1 */
 
  /* 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_USART1_UART_Init();
  /* USER CODE BEGIN 2 */
 
  HAL_UART_Transmit(&huart1, (uint8_t*)test, strlen(test), 100);
 
  HAL_MultiProcessor_EnableMuteMode(&huart1);
  HAL_MultiProcessor_EnterMuteMode(&huart1);
 
  /* Listen for address */
  if(HAL_UART_Receive_IT(&huart1, (uint8_t*)rx_buffer, BUFSIZE) != HAL_OK){
	  Error_Handler();
  }
  //HAL_MultiProcessor_EnterMuteMode(&huart1);
 
  /* USER CODE END 2 */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
 
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
	//testvar = 64;
 
	/* ADDRESS received! Begin listening for data(COMMANDS)
	 * When CMDs handled, enter mute mode again in order to listen for address byte again */
 
	if(HAL_UART_Receive_IT(&huart1, (uint8_t*)rx_buffer, BUFSIZE) != HAL_OK){
	  Error_Handler();
	}
 
}

0693W000007EhjoQAC.jpg

0 REPLIES 0