Home › Forums › Mastering STM32 book support forum › Ch8 UART and Terminal
- This topic has 7 replies, 3 voices, and was last updated 8 years, 8 months ago by olivier.cornez@me.com. 
- 
		AuthorPosts
- 
		
			
				
February 6, 2017 at 4:29 pm #6047olivier.cornez@me.com ParticipantHi, 
 I am on OS X 10.10 and the terminal does not work in Eclipse Neon 2.
 Msg is kermit command unknown while it works fine in os x terminal.I decided to use CoolTerm but I get strange output when I use HAL_UART_Transmit_IT: 
 output like this “…….**…..#……………..”
 It seems the txBuf points to an unallocated memory address.
 I try to debug but cannot figure out what is going on the terminal output seems not to match what i can see in debug window inside Eclipse (pData is correct in debug)???Could somebody help? February 6, 2017 at 4:31 pm #6049Carmine Noviello KeymasterWhat about the terminal speed? Does it match the UART baudrate? XOR/XOFF, parity, bits?!? February 6, 2017 at 5:28 pm #6050olivier.cornez@me.com ParticipantYes terminal speed matches (115200 – 8 – 1 – N default setup from CubeMX) 
 The HAL_UART_Transmit works fine, the Receive_IT works fine but only HAL_UAT_Transmit_IT produces strange outputs.February 6, 2017 at 5:49 pm #6052Carmine Noviello KeymasterDo you properly wait for transmit completion before calling again the HAL_UART_Transmit_IT()? If not, the transmit buffer is overridden. The CPU is much faster than the UART. February 6, 2017 at 5:58 pm #6054olivier.cornez@me.com ParticipantI am using the example from the book with the ringBuffer. 
 right now I modified the code to use only once the UART_Transmit function for the prompt and it seems to work.
 But if I use several call s to UART_Transmit inside the processInput() then I get strange outputsFebruary 7, 2017 at 4:27 pm #6066olivier.cornez@me.com ParticipantHi, As far as I understand the problem comes with the msg. 
 If it stores only 1 character as in your book example it works fine but if I change the message then I get strange output like thisWelcome to the Nucleo management console 
 Select the option you are interested in:
 .1. Toggle LD2 LED
 .2. Read USER BUTTON status
 .3. Clear screen and print this message
 Selection: > You sele….Ë…∫…˛..
 Selection: > Yo….ˇˇ….Ë…….˛..
 Selection: > Yo….ˇˇ….Ë…….˛P.
 Selection: > You sele….Ë…….˛..
 Selection: > Yo..˘ˇˇˇˇ…Ë……….
 Selection: >uint8_t processUserInput(uint8_t opt) { 
 char msg[30];if(!(opt >= 1 && opt <= 3)) 
 return 0;//sprintf(msg, “%d”, opt); 
 sprintf(msg, “You selected option %d\r\n”, opt);UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg)); switch(opt) { 
 case 1:
 HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
 break;
 case 2:
 sprintf(msg, “\r\nUSER BUTTON status: %s”, HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_RESET ? “PRESSED” : “RELEASED”);As far as I understand if the UART is not HAL_BUZY the UART_Transmit() directly the first char while if HAL_BUZY it stores the string in the txBuf. 
 After that point I am not sure…
 What is going on with the next call tovoid HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart){ 
 //trace_puts(“UART Tx IT Complete\n”);
 if(RingBuffer_GetDataLength(&txBuf) > 0){
 RingBuffer_Read(&txBuf, &txData, 1);
 HAL_UART_Transmit_IT(huart, &txData, 1);
 }
 }Could you clarify this to help? Thank you so much February 13, 2017 at 5:42 pm #6141Skalibur ParticipantI have the same problem. Without interrupt no have problem, but with interrupt I need to increase CPU clock above to 48Mhz. February 15, 2017 at 3:59 pm #6154olivier.cornez@me.com ParticipantAs far as understand is related to msg array being out of scope when using interlocks. 
 If you move the msg[30] to a global scope then it works fine for me.
 Note: I was also getting wrong info from the debugger not flashing the firmware on restart.
- 
		AuthorPosts
- You must be logged in to reply to this topic.
