We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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) { }
.
printf("ATD%s\n", phoneNO); // OR \r\n
hellooo friends
my problem is solved, very thanks
for other people that have my problem, I send all code that works good on chip. (IMPORTANT OF main.c code only) softwares: cubemx 4.18, cubef1 1.4, keil uvision 5.24
#include "main.h" #include "stm32f1xx_hal.h" UART_HandleTypeDef huart2; void SystemClock_Config(void); void Error_Handler(void); static void MX_GPIO_Init(void); static void MX_USART2_UART_Init(void); #ifdef __GNUC__ #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #else #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) #endif int main(void) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_USART2_UART_Init(); printf("AT\r"); HAL_Delay(4000); printf("AT+CMGF=1\r"); printf("AT+CMGS=09372274293\r"); printf("hellooo\x1A"); while (1) { } } PUTCHAR_PROTOTYPE /**RETARGET PRINTF TO UART2***/ { HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, 0xFFFF); return ch; }