Question
how to debug (terminal) a UART modul connected to usart2 ?
Posted on December 07, 2011 at 02:00
Hi, its me again :)
i have my stm32f103ze USART2 with 38400 baud connected to a bluetooth modul that uses rx, tx, rts, cts. I must send some commands to the bluetooth device via USART:/* USART2 Clock an*/
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); /*Init USART2 USART2: CTS PA0, RTS PA1, TX PA2, RX PA3 */ /* Configure USART2 RTS and USART2 Tx as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Configure USART2 CTS and USART2 Rx as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); USART_InitStructure.USART_BaudRate = 38400; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_RTS_CTS; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART2, &USART_InitStructure); USART_Cmd(USART2, ENABLE); /* Init BT */ IMU_Led1_On(); Delay(100); send_string(''STWMOD=0\r\n''); send_string(''STBD=38400\r\n''); Delay(200); send_string(''STNA=IMU\r\n''); send_string(''STAUTO=0\r\n''); send_string(''STOAUT=1\r\n''); send_string(''STPIN=0000\r\n''); Delay(200); send_string(''INQ=0\r\n''); Delay(200);/* send_string function for BT */
void send_string(const char *str) { while (*str) { while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); USART_SendData(USART2, *str++); } } How can I check the Echo from the Module in my Keil Debugger? I cant connect the modul to my PC RS232 because its hard mounted (SMD) on the PCB. And is there a possiblity in the debugger to write commands for testing if the commands that im sending are correct? with regards sam