2013-03-21 12:24 AM
I have the STM32F4 communicating with hyperterminal on windows 7 using a serial cable. My discovery board is plugged into an Embest expansion board which breaks out to an RS232 serial port and at the PC end I have a usb to serial converter as I have no serial port. I have gone back to the UART example Embest provide in their examples folder for the expansion board. All works fine hyperterminal receives the printf data.
I want to replace the serial cable with a Roving networks Rn-41-ms bluetooth device. I have fitted the Rn-41 to my board with a 3V supply and ground and I can talk to it via hyperterminal fine i.e can use get/set comands to confirm change settings on the device. I am using a bluetooth dongle at PC end. My problem comes when trying to transmit from my program via the bluetooth device to hyperterminal. In the UART example COM1 is used for UART6 which is the serial port on the expansion board, so I have selected COM3 for UART1 which is shown STM32F4_discovery.h file. The way I have changed to COM3 is by basically changing all the COM1's in the main.c to COM3 but I've also enabled hardware flow control as this is required for the RN-41 device. The program compiles and downloads fine but no data is recieved by hyperterminal when run on the ST board? I have set board rate, parity, stop bits etc the same on ST program, Rn-41 bluetooth device, PC bluetooth dongle and hyperterminal. Any ideas or advice on other settings I should consider when changing com ports or debugging methods for UART appreciated, I don't have use of an oscilloscope until monday. Expansion board http://www.embest-tech.com/shop/product/dm-stf4bb-base-board.html Bluetooth module http://uk.farnell.com/jsp/displayProduct.jsp?sku=2144010&CMP=e-2072-00001000&gross_price=true&mckv=YKMwxwd8|pcrid|14164337469|plid|{placement} #stm32f4 #rn-41 #bluetooth2013-04-02 07:18 AM
Clive1
That's what I was missing!! I was focused on Chip level and not board level!! and yes I've moved to USART3 PD8 (TX) PD9 (RX) and that seems to work fine!!CS2014-12-24 05:49 AM
Hi Clive1,
I am trying to send a charactor using USART2 to hyperterminal.Board:STM32F4 DiscoveryLibrary: STM32F4 Discovery STD Peripheral Driver (STM32F4xx_DSP_StdPeriph_Lib_V1.3.0) I am using Library function''USART_SendData(USART2, 'V');
''The code is passing through the function and exiting the function, but no charactor is sent to Hyperterminal.I have checked my hardware setup like Max232, Max3232 Serial to USB cable etc, all are working fine.I have modified The built in function in the following wayvoid USART_SendData(USART_TypeDef* USARTx, uint16_t Data){ /* Check the parameters */ assert_param(IS_USART_ALL_PERIPH(USARTx)); assert_param(IS_USART_DATA(Data)); /* Transmit Data */ USARTx->DR = (Data & (uint16_t)0x01FF); /*wait for TX*/while ((USART2->SR & USART_SR_TXE) == 0);
}Program is stuck inwhile ((USART2->SR & USART_SR_TXE) == 0);
It means Data is not being sent, the buffer is still full.I have tried all the resources available online.Please Help me to resolve this issue2014-12-24 07:37 AM
Why would you need to modify the library routine? You should really be front testing for TXE, before you put data out.
If the register values are always zero, then you might have forgotten to enable the clock to the USART2014-12-24 09:37 PM
Below quoted is my Init_usart() function. I am enabling the peripheral clock
usingRCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
command
void init_usart(void){ int dummyRead;/*used to read the junk character, not mandatory*/ GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; /* enable peripheral clock for USART2 */RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
/* GPIOA clock enable */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); /* GPIOA Configuration: USART2 TX on PA2 */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Connect USART2 pins to AF2 */ // TX = PA2 GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_USART2); // RX = PA3 GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_USART2); //USART_ClockInitTypeDef.USART_Clock = 1; //USART_ClockInit(USART2,HSE_VALUE);//InitTypeDef.USART_Clock = 1; //USART_ClockInitStructure.USART_Clock= USART_Clock_Enable; USART_InitStructure.USART_BaudRate = 9600; 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_None; USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; //Enables Both Receive and Transmit USART_Init(USART2, &USART_InitStructure); USART_Cmd(USART2, ENABLE); // enable USART2 dummyRead=USART_ReceiveData(USART2); //To Clear the Junk value in DR}