hello I write blow code with STcubemx and arm keil. I want to send a string data from MCU TO GSM module for calls. but nothing happend, when programing the chip. my question is , when send serial data with printf command , which port that command is sent (I use STM32F103C8T6 that has 3 usart)
how can I reslove this problem?
char phoneNO[]="093XXXXXX"; int main(void) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_USART2_UART_Init(); printf("AT"); HAL_Delay(1000); printf("ATD"); printf(phoneNO); HAL_Delay(8000); printf("ATH"); while (1) { }
.
I want to send a string data from MCU TO GSM module for calls over Usart2?
Use the HAL_UART_Transmit function (or equivalent - HAL_UART_Transmit_IT / HAL_UART_Transmit_DMA)
HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
my question is , when send serial data with printf command , which port that command is sent
You need to decide and configure it to go somewhere. "Retargeting" is one way to do this. You could retarget fputc (which printf will call) to use Usart2 in which case what you wrote would work.