UART Transmitting problem
Hello,
I am using the stm8l151... mcu and I am trying to send different strings via Uart1 to HTerminal. I have three different strings to send. The first two strings are transmitted completely but when the third one is being sent, it is truncated and it starts to send the first and second string again and repeatedly.
I have attached the output from Hterm (uart_com) for better understanding and also some parts of my code(uart transmit and uart_init)
Just for better understanding of the attached output, the strings(cmd 1, 2 and 3) are at+nrb, at+cfun=1, and at+cops=1,2,"26201"
Please Any suggestions will be greatly appreciated.:smiling_face_with_smiling_eyes:
void nbiot_buf_transmit(void){
PAL_UART1_RX_DISABLE();
PAL_UART1_TX_ENABLE();
for(int i=0 ; i < sizeof(cmd1);i++){
USART_SendData8(USART1,((uint8_t)cmd1[i]));
while(USART_GetFlagStatus(USART1,USART_FLAG_TXE)==RESET);
}
for(int i=0 ; i < sizeof(cmd2);i++){
USART_SendData8(USART1,((uint8_t)cmd2[i]));
while(USART_GetFlagStatus(USART1,USART_FLAG_TXE)==RESET);
}
for(int i=0 ; i < sizeof(cmd3);i++){
USART_SendData8(USART1,((uint8_t)cmd3[i]));
while(USART_GetFlagStatus(USART1,USART_FLAG_TXE)==RESET);
}
}void uart_init(void){
/* init Tx and Rx Pins */
GPIO_Init(GPIOC, GPIO_Pin_3, GPIO_Mode_Out_PP_High_Fast); //tx pin output
GPIO_Init(GPIOC, GPIO_Pin_2, GPIO_Mode_In_FL_No_IT); //rx pin input
/* enable usart1 clk */
PAL_SWITCH_USART1_CLK_ON();
/* config for GPIO mode */
PAL_SWITCH_COMP_CLK_ON();
PAL_UART1_CONFIG_RI();
PAL_UART1_SET_RI_GPIO();
PAL_SWITCH_COMP_CLK_OFF();
/* init usart peripheral */
USART_Init(USART1,
(PAL_dwCLK_FREQ_VALUE/9600),
USART_WordLength_8b,
USART_StopBits_1,
USART_Parity_No,
USART_Mode_Rx); //Tx enable
ITC->ISPR8 &= 0xFC; // Set USART1_RX_IRQn on ITC_PriorityLevel_2
ITC->ISPR7 &= 0x3F; // Set USART1_TX_IRQn on ITC_PriorityLevel_2
/* configure usart interrupts */
//enable transmit interrupt
//USART_ITConfig(USART1, USART_IT_TXE, ENABLE);
//USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
/* enable usart1 peripheral */
USART_Cmd(USART1,ENABLE);
}